Arabic fix when language is LTR

More
7 years 2 weeks ago #2629 by arisbrink
I have come upon an issue where we want dynamic texts to be in Arabic and in English.

How can we make sure that that the Arabic texts are displayed correctly even if the selected language is English?

Please Log in or Create an account to join the conversation.

More
7 years 2 weeks ago #2630 by arisbrink
What we do now is this:

internal static bool HasArabicCharacters(string text)
{
Regex regex = new Regex("[\u0600-\u06ff]");
return regex.IsMatch(text);
}

We check in our loop if the string contains Arabic characters and depending on the outcome we ApplyArabicFix or not.
LocalizationManager.ApplyRTLfix(string, 0, true);

If there is a cleaner method, please share.

Please Log in or Create an account to join the conversation.

More
7 years 2 weeks ago #2635 by Frank
I guess that what you are doing is the easiest way of doing it.

Alternatively, you could just call LocalizationManager.ApplyRTLfix to the entire string even if it doesn't have Arabic characters, that call will skip the regular characters. Just be sure to set to ignore numbers.
The issue with calling ApplyRTLfix all the time, is that when using tags (e.g. [color], [0xffffff], etc) the RTLfix tries to reorder the tags to make sense when rendering from right to left.

The other way (more reliable), is to add a tag <rtl> </rtl> to encapsulate your Arabic strings. Then, in the code that uses the translation (either your own script or a localization callback), see if you have a tag and apply rtl only to the inside, then remove the tags.

That way, its the safest, as it will deal correctly with other tag types, numbers, etc. But its a bit more involved.

Hope that helps,
Frank

Are you :-) Give I2L 5 stars!
Are you :-( Please lets us know how to improve it!
To get the betas as soon as they are ready, check this out

Please Log in or Create an account to join the conversation.

Time to create page: 0.183 seconds
Template by JoomlaShine