Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Concatenate left-to-right and right-to-left languages (arabic, etc.)

I need to process some language files. Most of them are in left-to-right languages, but some are in right-to-left languages. Processing the right-to-left languages ir problematic.

I have read a localizedString variable from a file.

If I print it reads correctly (first line in the attached picture). However, when I run this line:

    outputString = '"' + stringKey + '" = "' + localizedString + '";\n'

The arabic text gets out of order (second line).

enter image description here

I cannot even paste it here properly, upon pasting it gets out of order.

How can I automatically keep the proper order without knowing the language in advance?

I guess I could do what's explained in this SO answer, but that would break left-to-right languages. I'm looking for an automatic way of doing this regardless of the language.

Note: I'm using Python 2.7.6

like image 360
Ricardo Sanchez-Saez Avatar asked Oct 31 '22 06:10

Ricardo Sanchez-Saez


1 Answers

IMO, you could just simply concat them.

let the display problem to the edit itself. You may need convert it to .doc or .odt if you want to use it in desktop environment. Or just recompile vim with +rightleft options. However, you language file processing program can keep simple and elegant.

like image 199
yegong Avatar answered Nov 12 '22 10:11

yegong