Add filter for formatting strings

This commit is contained in:
Michal Čihař 2012-03-01 11:11:25 +01:00
parent 1c350b60db
commit 22f7d39da4
3 changed files with 15 additions and 2 deletions

View File

@ -1,5 +1,6 @@
{% extends "base.html" %}
{% load i18n %}
{% load weblate %}
{% block breadcums %}
<li><a href="{{ unit.translation.subproject.project.get_absolute_url }}">{{ unit.translation.subproject.project }}</a></li>
@ -24,7 +25,7 @@
<tr><th class="source">{% trans "Source" %}</th><th>{% trans "Translation" %}<th></tr>
{% if unit.is_plural %}
{% else %}
<tr><td class="translatetext">{{ unit.source }}</td><td>
<tr><td class="translatetext">{{ unit.source|fmttranslation }}</td><td>
{{ form.checksum }}
{{ form.target }}
<br />
@ -40,7 +41,7 @@
{% if suggestions %}
<ul>
{% for suggestion in suggestions %}
<li><span class="translatetext">{{ suggestion.target }}</span> by {{ suggestion.user }}</li>
<li><span class="translatetext">{{ suggestion.target|fmttranslation }}</span> by {{ suggestion.user }}</li>
{% endfor %}
</ul>
{% else %}

View File

View File

@ -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)