Code

Ticket #4389: get_language_bidi.diff

File get_language_bidi.diff, 523 bytes (added by arien, 6 years ago)

Use only first part of language name (i.e., xx for a language xx-yy) for BiDi detection.

Line 
1Index: django/utils/translation/trans_real.py
2===================================================================
3--- django/utils/translation/trans_real.py      (revision 8435)
4+++ django/utils/translation/trans_real.py      (working copy)
5@@ -244,7 +244,8 @@
6     True = right-to-left layout
7     """
8     from django.conf import settings
9-    return get_language() in settings.LANGUAGES_BIDI
10+    base_lang = lambda x: x.split('-', 1)[0]
11+    return base_lang(get_language()) in settings.LANGUAGES_BIDI
12 
13 def catalog():
14     """