Add filter for formatting strings
This commit is contained in:
parent
1c350b60db
commit
22f7d39da4
|
@ -1,5 +1,6 @@
|
||||||
{% extends "base.html" %}
|
{% extends "base.html" %}
|
||||||
{% load i18n %}
|
{% load i18n %}
|
||||||
|
{% load weblate %}
|
||||||
|
|
||||||
{% block breadcums %}
|
{% block breadcums %}
|
||||||
<li><a href="{{ unit.translation.subproject.project.get_absolute_url }}">{{ unit.translation.subproject.project }}</a></li>
|
<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>
|
<tr><th class="source">{% trans "Source" %}</th><th>{% trans "Translation" %}<th></tr>
|
||||||
{% if unit.is_plural %}
|
{% if unit.is_plural %}
|
||||||
{% else %}
|
{% else %}
|
||||||
<tr><td class="translatetext">{{ unit.source }}</td><td>
|
<tr><td class="translatetext">{{ unit.source|fmttranslation }}</td><td>
|
||||||
{{ form.checksum }}
|
{{ form.checksum }}
|
||||||
{{ form.target }}
|
{{ form.target }}
|
||||||
<br />
|
<br />
|
||||||
|
@ -40,7 +41,7 @@
|
||||||
{% if suggestions %}
|
{% if suggestions %}
|
||||||
<ul>
|
<ul>
|
||||||
{% for suggestion in suggestions %}
|
{% 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 %}
|
{% endfor %}
|
||||||
</ul>
|
</ul>
|
||||||
{% else %}
|
{% else %}
|
||||||
|
|
0
trans/templatetags/__init__.py
Normal file
0
trans/templatetags/__init__.py
Normal file
12
trans/templatetags/weblate.py
Normal file
12
trans/templatetags/weblate.py
Normal 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)
|
Loading…
Reference in New Issue
Block a user