14
votes

I need to create an application that has strings of many languages, including RTL (right-to-left ) languages. I want to know what is the current status of RTL (Right To Left) support on Android (even on latest API), for example:

  1. is it possible to dynamically/statically check if the device's current language is RTL type? I know that it is possible to get the current locale, but i need a more general way to check if the current language is RTL. For example, for English and French it will return false, but for Arabic and Hebrew it will return true.

  2. is it possible to set a layout to automatically be mirrored for RTL languages ? For example, if a linearLayout (with horizontal orientation) had its children 1->2, now it will have 2<-1, and new children will be created on the left.

  3. is there a qualifier to add to the resources folders that will handle all RTL languages? For example, "res/layout" is for LTR (Left To Right), and "res/layout-rtl" is for RTL languages.

  4. it seems that eclipse's content assist suggests "android:layoutDirection" for linearLayout and "android:textDirection" for textView, but when I choose them, I get a compilation error that it doesn't recognize them. I also can't find out more information on the internet about those attributes. What do they mean, and how come I can't use them?

EDIT: seems that Android 4.1 has some improvement on RTL languages. Wonder what are they and where I can read about them.

2
RTL -> Right To Left. LTR -> Left To Right. It might be obvious to you but probably not for everyone :)Amokrane Chentir
thanks for modifying my question .android developer
@CommonsWare There is one. It is ldrtl.Eng.Fouad
@Eng.Fouad: That is is only for 4.1 and above. My comment was from February 2012, before 4.1 was released.CommonsWare
@CommonsWare do you know of a compatability library for hebrew handling? android 4.1 is still not so popular... btw, i think that only on 4.2 they've made the best improvement . see my post here : stackoverflow.com/a/14885782/878126android developer

2 Answers

4
votes

Starting with android 4.2 , there is a little more info known about the special RTL attributes , and there is even an option to mirror layouts automatically for RTL languages .

More info can be found here .

Hopefully , they will add more information about how to use it , including some sample code and maybe even a support library on this matter.


EDIT: now they've added some more information of how to use the new RTL support:

http://android-developers.blogspot.co.il/2013/03/native-rtl-support-in-android-42.html?utm_source=feedburner&utm_medium=feed&utm_campaign=Feed:+blogspot/hsDu+(Android+Developers+Blog)

I wonder though if the NIKUD ( Hebrew equivalent to vowels, except that they are optional and they are shown as dots instead of letters) works fine now .

EDIT: Now i've tested it, and it actually works really well (this is the first chapter of the holy bible) :

enter image description here

0
votes
  1. RTL support in android got some improvement in ICS. Before that in gingerbread, it was device specific e.g. each manufacturer/operator implemented their own BiDi solutions which caused some inconsistancy in applications

  2. its not needed. Good BiDi knows to mirror text view and canvas.draw text by initial letter utf8 code.. which let you worry less about BiDi and more about your app. Just don't force gravity and fill parent on text view

  3. No, there is qualifiers for Arabic/Hebrew etc.. where you can change practically everything. But good device implementation will not need anything but translations.

  4. that may happen if you have some old or device specific API installed. Therefore it won't work android-wide and cause compilation errors. But there are more reasons for it to happen...


Generally I advise you to ignore the BiDi issue for two reasons:

  1. people from countries that use rtl usually have devices which process it pretty good if not then its their problem.

  2. fixing your BiDi for one device will cause other devices not to comply. And that's something was done year ago.. and luckily developers finally stopped doing this mistake