mirror of
https://github.com/django/django.git
synced 2025-08-04 02:48:35 +00:00
Fixed #30585 -- Added {% translate %} and {% blocktranslate %} template tags.
This commit is contained in:
parent
70d95682b1
commit
d291c72bf2
14 changed files with 346 additions and 175 deletions
|
@ -2695,14 +2695,14 @@ Therefore here is our new ``change_form.html`` :
|
|||
{% load i18n admin_urls %}
|
||||
{% block object-tools-items %}
|
||||
<li>
|
||||
<a href="{% url opts|admin_urlname:'history' original.pk|admin_urlquote %}" class="historylink">{% trans "History" %}</a>
|
||||
<a href="{% url opts|admin_urlname:'history' original.pk|admin_urlquote %}" class="historylink">{% translate "History" %}</a>
|
||||
</li>
|
||||
<li>
|
||||
<a href="mylink/" class="historylink">My Link</a>
|
||||
</li>
|
||||
{% if has_absolute_url %}
|
||||
<li>
|
||||
<a href="{% url 'admin:view_on_site' content_type_id original.pk %}" class="viewsitelink">{% trans "View on site" %}</a>
|
||||
<a href="{% url 'admin:view_on_site' content_type_id original.pk %}" class="viewsitelink">{% translate "View on site" %}</a>
|
||||
</li>
|
||||
{% endif %}
|
||||
{% endblock %}
|
||||
|
|
|
@ -814,10 +814,10 @@ This would display as "It is the 4th of September".
|
|||
|
||||
You can also use the syntax ``{% now "Y" as current_year %}`` to store the
|
||||
output (as a string) inside a variable. This is useful if you want to use
|
||||
``{% now %}`` inside a template tag like :ttag:`blocktrans` for example::
|
||||
``{% now %}`` inside a template tag like :ttag:`blocktranslate` for example::
|
||||
|
||||
{% now "Y" as current_year %}
|
||||
{% blocktrans %}Copyright {{ current_year }}{% endblocktrans %}
|
||||
{% blocktranslate %}Copyright {{ current_year }}{% endblocktranslate %}
|
||||
|
||||
.. templatetag:: regroup
|
||||
|
||||
|
@ -1200,10 +1200,10 @@ image in the above example will be 88 pixels wide
|
|||
(because 175/200 = .875; .875 * 100 = 87.5 which is rounded up to 88).
|
||||
|
||||
In some cases you might want to capture the result of ``widthratio`` in a
|
||||
variable. It can be useful, for instance, in a :ttag:`blocktrans` like this::
|
||||
variable. It can be useful, for instance, in a :ttag:`blocktranslate` like this::
|
||||
|
||||
{% widthratio this_value max_value max_width as width %}
|
||||
{% blocktrans %}The width is: {{ width }}{% endblocktrans %}
|
||||
{% blocktranslate %}The width is: {{ width }}{% endblocktranslate %}
|
||||
|
||||
.. templatetag:: with
|
||||
|
||||
|
@ -2023,7 +2023,7 @@ Example::
|
|||
|
||||
You have {{ num_cherries }} cherr{{ num_cherries|pluralize:"y,ies" }}.
|
||||
|
||||
.. note:: Use :ttag:`blocktrans` to pluralize translated strings.
|
||||
.. note:: Use :ttag:`blocktranslate` to pluralize translated strings.
|
||||
|
||||
.. templatefilter:: pprint
|
||||
|
||||
|
|
|
@ -414,7 +414,7 @@ Here are some tips for working with inheritance:
|
|||
tag ``as`` syntax can't be used inside the block. For example, this template
|
||||
doesn't render anything::
|
||||
|
||||
{% trans "Title" as title %}
|
||||
{% translate "Title" as title %}
|
||||
{% block content %}{{ title }}{% endblock %}
|
||||
|
||||
* For extra readability, you can optionally give a *name* to your
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue