Android Hebrew (rtl) Integration
Solution 1:
I think that Android's bidi analysis algorithm has some flaws. Unicode has two invisible, strongly directional characters that might help with these problems:
- U+200E - left-to-right mark
- U+200F - right-to-left mark
For the digit order problem, try putting left-to-right marks (U+200E) on both sides of the digit sequence.
Unicode also has the following bidi formatting codes:
- U+202A - left-to-right embedding
- U+202B - right-to-left embedding
- U+202C - pop directional formatting (cancels the previous embedding or override)
- U+202D - left-to-right override
- U+202E - right-to-left override
For the problem with English fragments in Hebrew text, it might be as simple as putting a right-to-left mark before the English. (Android's algorithm may be under the impression that the paragraph is left-to-right since the first characters are English.) If that doesn't work, perhaps try surrounding selected text with some combination of formatting codes. (I'd try left-to-right embedding followed by pop directional formatting. I'd also try right-to-left embedding around everything combined with selective explicit right-to-left embeddings.)
The way these are supposed to affect text layout are defined by the Unicode Bidirectional Algorithm Unicode Standard Annex #9. However, if Android's implementation is broken (and I suspect it is), the best you can do is trial-and-error until you get things looking right. Good luck.
EDIT
As far as code is concerned, here's an example of how it might be done in Java:
Stringtext = "גרסה \u200e2.100\u200e זמינה";
In XML, it might be:
<stringname="update_available">גרסה ‎2.100‎ זמינה</string>
Solution 2:
here is an example from my hebrew string xml, Thanks to Ted Hopp's answer:
you need to add '\u200e' before the char that causes you the problem:
<string name="basic_text1">המר על תוצאת המשחק\u200e:</string>
and the result will be:
:המר על תוצאת המשחק
Post a Comment for "Android Hebrew (rtl) Integration"