0

I am astonished how I didn't find concrete resources regarding a multilingual android app when i googled.

I have never previously performed localization on android. I did find resources on the internet which talked about changing the locale from the phone settings , in order to see the application in the selected locale.

However my client doesn't want the phone's locale to be tied up with the applications ( a reasonable request) . The phone should stay in English , however the option to change the language should be internal to the application

It would be simple, on the splash screen activity , it would ask the user , to select the language. Upon selection of the language , the subsequent activities should work in that language .

Is this really not natively possible in android and we would have to put hacks and bandages on the system to achieve the result ?

Cœur
  • 37,241
  • 25
  • 195
  • 267
Muhammad Ahmed AbuTalib
  • 4,080
  • 4
  • 36
  • 59

3 Answers3

0

You need to provide String resources for each needed locale in corresponding values folder, for example values-us, values-de etc. In each of this folders you need to place file strings.xml with all resources, you need to localize, resoutce id's must be the same for same resources in different folders.

From code you should use

Context.getstring(R.string.your_string);

To obtain needed resource.

As for switching application locale - see this link

Community
  • 1
  • 1
Alexander Semenov
  • 1,513
  • 13
  • 20
0

Changing the locale from within an app is done by creating a Locale object with the desired setting and then using Locale.setDefault(locale) to activate the custom-defined locale settings.

The official Android documentation indicates that this is often an incorrect approach, probably because it's pretty easy to get your local setting overwritten by system events (screen rotate, etc.).

There is a good code example to accomplish what you are looking for in the top answer on a similar StackOverflow question.

Community
  • 1
  • 1
Kent Butler
  • 109
  • 6
0

To support multilingual, you should create different values folder for each language, for example values-en for english, values-fr for french, etc. contains a string.xml file You can follow the Android official doc, here

cdr89
  • 958
  • 9
  • 18