Search code examples
djangointernationalizationtranslation

Translate a Django app in Arabic and also make forms LTR to RTL


I have translated a Django app in multiple languages and everything works fine. But when I switch it to Arabic language I want to make all forms LTR to RTL. How can I achieve this in Django?


Solution

  • I'm not familiar with RTL, but this guide covers it. It seems that you just have to add this to your root HTML file:

    {% load i18n %}
    {% get_current_language_bidi as LANGUAGE_BIDI %}  <!-- 1 -->
    <html dir="{% if LANGUAGE_BIDI %}rtl{% else %}ltr{% endif %}">  <!-- 2 -->
    I am displayed in the right direction.
    </html>