I am using Django i18n translation system and there are two languages:
LANGUAGES = (
('fa', _('Persian')),
('en', _('English')),
)
Persian is Right-To-Left and I want to serve another CSS file when user change language to persian. Or maybe there is a better way to change LTR to RTL when user change the language?
I am using nginx with wsgi on a Ubuntu vps.
One possible way:
I assume you have 2 css files for example static/css/fa.css and static/css/en.css
In template, when you link your css you can do it like this:
<link type="text/css" href="{% trans 'static/css/en.css' %}">
In your Persian translation file you put then something like this:
msgid "static/css/en.css"
msgstr "static/css/fa.css"
Alternatively, if the only thing you want from css is to change LTR to RTL you could do in your template:
{%load i18n%}
{%get_current_language as LANGUAGE_CODE%}
{%get_language_info for LANGUAGE_CODE as lang%}
....
{% if lang.bidi %}
<!-- Some HTML code for RTL -->
{% else %}
<!-- Some HTML code for LTR -->
{% endif %}