What is the correct Android language code for simplified Chinese and Portuguese?

In my application, users are able to switch their application language to one of the other supported applications. I am having problems working Portuguese-Brazilian and Simplified Chinese. All other translations work correctly when the user changes the locale settings.

These translations work correctly if the device locale is pt-rBR or zh-rCN, so the only thing that may be wrong is the locale code that I use. However, everything I tried fails. Does anyone know the correct Android locale codes for them so that users can switch normally if they wish?

+4
source share
2 answers

Using

new Locale("pt","BR"); 

instead

 new Locale("pt_BR"); 
+5
source

Use the following code that it works for me for traditional and simplified Chinese.

 if(selectedLanguage.equals("zh_CN")) locale = Locale.SIMPLIFIED_CHINESE; else if(selectedLanguage.equals("zh_TW")) locale = Locale.TRADITIONAL_CHINESE; else locale = new Locale(selectedLanguage); Locale.setDefault(locale); Configuration config = new Configuration(); config.locale = locale; baseContext.getResources().updateConfiguration(config, baseContext.getResources().getDisplayMetrics()); 
+2
source

All Articles