1

Which language does android treats default strings.xml as?

Specifically, when there are <plurals> tags inside default strings.xml, rules for which language will Android pick? Is there a way to specify that?

Matej Drobnič
  • 981
  • 10
  • 18

2 Answers2

2

It doesn't treat default values folder as a language dependant. It's basically a fallback if it doesn't find a better match. You can read more here.

Android will pick plurals rules for language that is currently selected in the phone(e.g. if users has german language then android will pick german rules).

M G
  • 1,240
  • 14
  • 26
  • So if my default values.xml is in english, but user has german language selected, it will pick rules for german plurals? How do I work around this? I can obviously add english language xml but it wouldn't matter because german phone will still pick default values.xml. – Matej Drobnič Sep 11 '15 at 18:27
  • Add german specific values. You can read about workaround [here](http://stackoverflow.com/questions/2264874/changing-locale-within-the-app-itself) but pay attention to config changes and activity recreation. This changes every localization-based files, etc. – M G Sep 14 '15 at 09:33
  • Right but that means only solution is to add values for every single language in the world which I can't do at the moment. Is there no way to keep app english-only but have proper plurals for every locale? – Matej Drobnič Sep 14 '15 at 12:49
  • What do you mean by proper plurals for every locale? Show some example. – M G Sep 14 '15 at 13:21
  • Lets say my app's default values.xml contains strings for Slovenian language. That requires singular, plural and dual form. For people with locale set to Slovenian it will work great. But if someone that knows Slovenian, but has his phone set to English locale would use the app, it would never use dual form since English language does not have it. I could solve this specific case with additional English values.xml, but that would still leave out every other language that doesn't use dual. And adding every single one of them is not really feasible. – Matej Drobnič Sep 15 '15 at 20:59
  • Get phones language, check if it is supported by your app and if not then set it to the default one that you picked(in your example it is Slovenian). – M G Sep 16 '15 at 12:26
  • But doesn't changing locale also change date format and other locale features? – Matej Drobnič Sep 16 '15 at 15:59
0

Use this to change the language by programmatically--

Locale locale = new Locale("en_US");
Locale.setDefault(locale);
Configuration config = new Configuration();
config.locale = locale;
context.getApplicationContext().getResources().updateConfiguration(config, null);

Write the countrycode of language in place of "en_US" whatever language you want...like for japanese--"ja_JP" For Arabic--"ar" or check this link for code of country--

http://code.google.com/apis/igoogle/docs/i18n.htmlenter code here