From 22f7d39da4853315ac808eeaa1e908b78e703e02 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Michal=20=C4=8Ciha=C5=99?= Date: Thu, 1 Mar 2012 11:11:25 +0100 Subject: [PATCH] Add filter for formatting strings --- html/translate.html | 5 +++-- trans/templatetags/__init__.py | 0 trans/templatetags/weblate.py | 12 ++++++++++++ 3 files changed, 15 insertions(+), 2 deletions(-) create mode 100644 trans/templatetags/__init__.py create mode 100644 trans/templatetags/weblate.py diff --git a/html/translate.html b/html/translate.html index e099a6702..795087273 100644 --- a/html/translate.html +++ b/html/translate.html @@ -1,5 +1,6 @@ {% extends "base.html" %} {% load i18n %} +{% load weblate %} {% block breadcums %}
  • {{ unit.translation.subproject.project }}
  • @@ -24,7 +25,7 @@ {% trans "Source" %}{% trans "Translation" %} {% if unit.is_plural %} {% else %} -{{ unit.source }} +{{ unit.source|fmttranslation }} {{ form.checksum }} {{ form.target }}
    @@ -40,7 +41,7 @@ {% if suggestions %} {% else %} diff --git a/trans/templatetags/__init__.py b/trans/templatetags/__init__.py new file mode 100644 index 000000000..e69de29bb diff --git a/trans/templatetags/weblate.py b/trans/templatetags/weblate.py new file mode 100644 index 000000000..ec336c84e --- /dev/null +++ b/trans/templatetags/weblate.py @@ -0,0 +1,12 @@ +from django.template.defaultfilters import stringfilter +from django.utils.html import escape +from django.utils.safestring import mark_safe +from django import template + +register = template.Library() + +@register.filter +@stringfilter +def fmttranslation(s): + s = escape(s) + return mark_safe(s)