0

I have in my res\values\strings.xml a translation to Norwegian. enter image description here

How can I use this file when the users language is Norwegian? I tried it on my mobile phone, and this language did not load.

My code:

public void setLanguage(){
   // Get user language
   String lang3 = Locale.getDefault().getISO3Language();
   String lang2 = lang3.substring(0, 2);
   Toast.makeText(this, lang2, Toast.LENGTH_LONG).show();

   // Get recourse
   Resources res = this.getResources();

   // Change locale settings in the app.
   DisplayMetrics dm = res.getDisplayMetrics();
   android.content.res.Configuration conf = res.getConfiguration();
   conf.setLocale(new Locale(lang3.toLowerCase())); // API 17+ only.
}
Solo
  • 569
  • 1
  • 7
  • 27
  • 1
    maybe duplicate of this : https://stackoverflow.com/questions/34573201/change-languages-in-app-via-strings-xml – SAYE Jun 28 '17 at 04:30
  • Thanks Abbas Nikzad, I will look at that thread. – Solo Jun 28 '17 at 04:37
  • 1
    Possible duplicate of [Change languages in app via strings.xml](https://stackoverflow.com/questions/34573201/change-languages-in-app-via-strings-xml) – rma Jun 28 '17 at 04:54

0 Answers0