I
I
Igor Tkachenko2014-01-11 03:30:39
Django
Igor Tkachenko, 2014-01-11 03:30:39

How to implement localization in django (display conditions)?

There is a line, it should be only in / ru, if the active localization is / en, do not show this line, for example {% if locale = ru %} show {% endif %}, respectively, if it does not fall under the condition, do not show it.
How to implement?

Answer the question

In order to leave comments, you need to log in

2 answer(s)
D
Dmitry Astrikov, 2014-01-11
@foozzi

Use the get_current_language tag in templates.
For example:

{% get_current_language as LANGUAGE_CODE %}

{% if LANGUAGE_CODE == "ru" %}
       Ваша строка
{% endif %}

A
alternativshik, 2014-01-11
@alternativshik

Well, if it’s completely on the forehead, then just make an empty line in the localization file for en

Didn't find what you were looking for?

Ask your question

Ask a Question

731 491 924 answers to any question