I need to process some language files. Most of them are in languages from left to right, but some of them are in languages from right to left. Handling problematic languages with problematic ones.
I read the variable localizedStringfrom the file.
If I print it, it reads correctly (the first line in the attached figure). However, when I run this line:
outputString = '"' + stringKey + '" = "' + localizedString + '";\n'
Arabic text fails (second line).

I can’t even insert it here properly, after inserting it fail.
How can I automatically maintain the correct order without knowing the language in advance?
I think I could do what I explained in this SO answer , but that would break languages from left to right. I am looking for an automatic way to do this regardless of language.
Note. I am using Python 2.7.6
source
share