Уведомления

Группа в Telegram: @pythonsu

#1 Ноя. 14, 2010 01:12:19

Remoteroot
От:
Зарегистрирован: 2010-11-14
Сообщения: 9
Репутация: +  0  -
Профиль   Отправить e-mail  

trans в yesno и default_if_none

Подскажите, как правильно перевести с помочу trans слово “Неизвестно” в данном коде?

{{ institution.city|default_if_none:"Неизвестно" }}
Аналогично и для yesno:
{{ hotel.cafe_availability|yesno:"Да, Нет, Неизвестно" }}



Офлайн

#2 Ноя. 14, 2010 14:11:40

tmt
От:
Зарегистрирован: 2010-03-26
Сообщения: 51
Репутация: +  0  -
Профиль   Отправить e-mail  

trans в yesno и default_if_none

Обращаемся к документации. http://docs.djangoproject.com/en/1.2/topics/i18n/internationalization/#other-tags

Translation hooks are also available within any template block tag that accepts constant strings. In those cases, just use _() syntax to specify a translation string:

{% some_special_tag _("Page not found") value|yesno:_("yes,no") %}
In this case, both the tag and the filter will see the already-translated string, so they don't need to be aware of translations.

Note
In this example, the translation infrastructure will be passed the string “yes,no”, not the individual strings “yes” and “no”. The translated string will need to contain the comma so that the filter parsing code knows how to split up the arguments. For example, a German translator might translate the string “yes,no” as “ja,nein” (keeping the comma intact).



Офлайн

Board footer

Модераторировать

Powered by DjangoBB

Lo-Fi Version