Welcome, Guest
Username: Password: Remember me

TOPIC: Arabic fix when language is LTR

Arabic fix when language is LTR 4 days 22 hours ago #2629

  • arisbrink
  • arisbrink's Avatar
  • Offline
  • New Member
  • Posts: 2
  • Karma: 0
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?
The administrator has disabled public write access.

Arabic fix when language is LTR 4 days 22 hours ago #2630

  • arisbrink
  • arisbrink's Avatar
  • Offline
  • New Member
  • Posts: 2
  • Karma: 0
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.
The administrator has disabled public write access.

Arabic fix when language is LTR 4 days 14 hours ago #2635

  • Frank
  • Frank's Avatar
  • Offline
  • Administrator
  • Posts: 915
  • Thank you received: 196
  • Karma: 58
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
The administrator has disabled public write access.
Time to create page: 0.548 seconds
Colors