I am running python2.7 with django 1.4.
I have the following code in my views.py page which returns the language names in a select list:
python code: (views.py)
available_languages = []
for lv in language_versions:
language = LANGUAGES[lv.language_code]
if lv.language_code == user_language_code:
language_label = (lv.language_code, u"%s" % (language.name_native))
else:
language_label = (lv.language_code, u"%s / %s" % (language.name, language.name_native))
available_languages.append(language_label)
....
available_languages = sorted(available_languages, key=lambda x: x[1], cmp=compare)
return available_languages
HTML code:
{{ field }}
select list:
German / Deutsch
Polish / polski
Portuguese (Brasil) / português (Brasil)
Spanish (Latin America) / español (Latinoamérica)
Russian / pусский
The problem is when the page is viewed in a rtl language like Arabic the select list is rendered as follows with the brackets of the ltr text in the wrong positions:
لألمانية / Deutsch
البولندية / polski
البرتغالية) لبرتغال) / português) Portugal)
لإسبانية أمريكا) اللاتينية) / español) Latinoamérica)
الروسية / pусский
How do I write the code in the view.py file to correctly display the bidi brackets?
I have read quite a few threads and tried many different ways to fix the issue, but I have run out of ideas.
One attempt that did not work was bookending the language names with the Unicode control (directional) characters & #8234; & #8236; & rlm; in the view.py file - the & #8234; & #8236; & rlm; is rendered to the select list in the page. For example:
& #8234;إسبانية أمريكا) اللاتينية) / português (Brasil)& #8236; & rlm;
Also adding the following to the css has no effect:
direction: rtl; unicode-bidi: embed