Localizing android app with a project that uses RTL language as default - android

I'm working on localizing an app of mine, and I was reading through the android documentation on localization here. and this line caught my attention:
Put the app's default text in res/values/strings.xml.
The text strings in res/values/strings.xml should use the default language, which is the language that you expect most of your app's users to speak.
now my question is, what if the app's default text is in a right-to-left language lets say Arabic, and you build all the layouts to fit the Arabic language, then how would you deal with LTR languages? how would you tell android that the default language is RTL and Layouts were designed for RTL languages, and to actually flip the layouts when the user choses a LTR languages?

After couple of days of research, reading articles on localization and some tinkering with xml it seems like using an RTL language as the default language and building all your UI in RTL by default is not a good option, and though can be done as explained below, I wouldn't advise doing it this way unless you have an app that has already been build with only RTL language in mind and now you want to support LTR languages without having to go and fix all your layouts manually.
the only thing that you need to do is to force android to use LTR for layouts directions (yes, LTR not RTL, since you already build layouts in RTL but android is expecting it to be LTR and will flip it, so you have to flip it again) and you can do that easily by adding <item name="android:layoutDirection">ltr</item> into you app theme in styles.xml.
After that you should create another styles.xml with a localized qualifier of the supported LTR language(s) and override your app theme and use rtl for layoutDirection this time.

Related

How to declare the fallback language on Android for TalkBack?

I have an Android app that currently only has a fallback language, so all strings are in res/values/strings.xml and are in English. This works fine with TalkBack while the OS is also set to English. However, as soon as I change the OS language to anything other than English, TalkBack starts to speak those English words using the pronunciation of the OS language, which is weird and hard to understand.
How can I declare to the Android OS what the language of my fallback resources is so that TalkBack can choose the correct pronunciation to use?
Unfortunately, as far as I know Talkback doesn't support auto language switching. Google TTS seems to do some auto switching based on non-latin characters these days, but for latin languages it just doesn't do anything except keep the phone language. So, I'm afraid there's nothing you can do to facilitate this.
Create a strings.xml variation for english and leave it like this
<resources ...>
</resources>
According to the official doc:
https://developer.android.com/training/basics/supporting-devices/languages
https://developer.android.com/guide/topics/resources/providing-resources#AlternativeResources
You can create different values-xx folder to support different languages!
Hope this can help you!

Android Library to Support Indian Languages

I am writing an app in which I have to support all Indian languages and for that I am looking for some third party library (free or paid)
I googled many times for the same but I did not get any decent option (library)
I just got use strings.xml for (English, Hindi) in their respective folders.
But I have seen in Whatsapp there is a multilanguage option, which supports almost all major indian languages
For an Example : If I do select Hindi language, so it translates complete app in Hindi language only
Same kind of functionality, I need in my app, like in drop down, If user do tap on any of the Indian language, my app has to converted in same one only (Like: Hindi, Telugu, Marathi, Gujarati and others)
What would be the best way of doing this and getting it done?
It depends what do you mean by "support"
Android supports all Indic languages. But it is not localized in all them.
Because of that, some of them cannot be selected from Settings.
But if you can provide string.xml files for all of them, and put them in the proper values-xy folder.
Possible problems:
How to select a language that the OS does not support? Have your own language selection. Once a locale is selected, call Locale.setDefault (to change the formatters), and change the resource loading configuration (Set Locale programmatically)
You see squares. This means missing fonts. Android has fonts for all the Indic scripts. But older phones might miss some. And OEMs might remove some to reduce size. So you can embed the proper Noto fonts in your application and use them (https://www.google.com/get/noto/). Use styles, and have language specific style sheets.
Keyboard missing. Install one. Here is the Google one: https://play.google.com/store/apps/details?id=com.google.android.apps.inputmethod.hindi. But there are also third party ones, for instance https://play.google.com/store/apps/details?id=org.smc.inputmethod.indic

How can I detect system Chinese, Korean, and English fonts without embedding one for each? (AIR mobile on Android and IOS)

My learning app requires displaying Korean, English and Chinese. One solution I have is to embed a Korean/English font and a Chinese font. Then put together a string with different TextFormats.
The thing is, I'm positive that IOS and Android devices should contain native Chinese, Korean and English fonts already, and I'd much rather refer to and use those fonts instead of packing them.
I tried detecting fonts by using Font.enumerateFonts(true), but when I use font.hasGlyphs('你'), I don't get a true, or anything, so I don't know how to choose the proper device font.
If that doesn't work, is there a font that contains all of those Characters? Or maybe a font-builder program that'd allow me to customize a font to include
This was something that I wrote sometime back
http://blogs.adobe.com/airodynamics/2012/08/21/supporting-languages-with-unicode-characters/
Hopefully it helps you
You can always know the name of font specific to the language. May be this http://support.apple.com/kb/HT5878.
Now based on the language you want to show just change the value of font in the statement format.font and the correct language should come up.

Localization testing on Android - Change Application or System locale

I'm finally trying out some localization stuff on our application, and I've seem some posts regarding changing the application locale, and changing the System locale.
I've wondered if within the scope of our application, does it matters if I change the System locale or the application locale?
As far as I could notice, changing the application or the system Locale is not different with a side note that one would have to refresh the views.
I've wrote a post about my experience with Multi-Languages... leave your comments at the bottom.

What is the status of Right To Left languages on Android?

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:
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.
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.
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.
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.
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) :
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
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
No, there is qualifiers for Arabic/Hebrew etc.. where you can change practically everything. But good device implementation will not need anything but translations.
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:
people from countries that use rtl usually have devices which process it pretty good if not then its their problem.
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

Categories

Resources