1

i am trying to post my question understable.

I have 2 strings.xml one is for english and another is for Indian Local Language, let it be Tamil.

I have kept the meanings of all the attributes of strings.xml(english) in my tamil strings.xml

Initially my application will load english strings.xml (as normal)

I have button somewhere which should be used to change the language (tamil in this case) Upon clicking that - my whole app should be reading my tamil strings.xml ..

I know below code only works for default LOCALE

Resources res = getResources();
      DisplayMetrics dm = res.getDisplayMetrics();
      Configuration conf = res.getConfiguration();
      conf.locale = Locale.GERMANY;
      res.updateConfiguration(conf, dm);

Can this be tweaked to read the my customized strings.xml on the fly?

Any ideas are greatly appreciated.

Sanjay Herle
  • 313
  • 2
  • 4
  • 15
  • Please check my answer of this thread http://stackoverflow.com/questions/4022566/custom-multi-language-support/4873524#4873524.I think it may help. – Shashank_Itmaster Dec 06 '11 at 07:50
  • Hi Shashank, thanks for your response.. but my question was like - is this possible to create new folder like values-ta (ta for tamil) and use the method you have posted in your thread... "ja" isn't for Japan? which is in OEM (Default kind of thing).. so i can change it on the fly.. but Tamil is not there in LOCALE i believe.. i am just creating one (Customized folder and strings.xml for tamil meanings) – Sanjay Herle Dec 06 '11 at 09:48

2 Answers2

0

That is not possible. It's only possible to change the language of your phone and than you will change the language for your app.

why don't you make a settings activity and in there you put an option to change the language that will transfer you user to a locale and text in the settings page on phone?

Tell me if you need a code or something like that.

Brock Adams
  • 90,639
  • 22
  • 233
  • 295
Jovan
  • 1,741
  • 4
  • 19
  • 38
  • Hi Brock. thanks for your response.. Correct!! its possible only if the locale is in Android OEM... All i am trying to create strings.xml and keep that in values-ta (ta for tamil).. and update the configuration using its method.. is this possible? – Sanjay Herle Dec 06 '11 at 09:45
  • As far as i know that is not possibile...if i find something like that i will write it here... – Jovan Dec 06 '11 at 10:31
0

Do you mean you want to change your language on demand from English to Tamil within your app?

I call this method in my activity onCreate:

public void setupLocale(Activity c, String NewLocale) {
    Resources res = c.getBaseContext().getResources();
    Configuration newConfig = new Configuration(res.getConfiguration());
    newConfig.locale = new Locale(NewLocale);
    res.updateConfiguration(newConfig, null);
}

Where c is my activity and NewLocale is the locale string I want to use. e.g "fr" for french, "da" for Danish. Don't know what Tamil is but you probably do.

Kuffs
  • 35,581
  • 10
  • 79
  • 92
  • Hi Kuffs, thanks for your response.. but my question was like - is this possible to create new folder like values-ta (ta for tamil) and use the method you have posted.. .. so i can change it on the fly.. but Tamil is not there in LOCALE i believe.. i am just creating one (Customized folder and strings.xml for tamil meanings) – Sanjay Herle Dec 06 '11 at 09:49