Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Chinese locale values-zh_CN gives an error on Eclipse

I've created a values-zh_CN directory in my res folder for Simplified Chinese localization. Eclipse does not accept that folder name, it marks it as an error, the directory itself.

The problem is definitely with the directory name, if I change the directory name to values-nl for example the error comes off.

The only name Eclipse accepts is values-zh-rCN which compiles fine but the actual locale is not loaded (Default en is loaded instead).

like image 411
Aviran Avatar asked Jul 24 '13 20:07

Aviran


3 Answers

Use following code its working 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());
like image 128
Sunil Parmar Avatar answered Oct 06 '22 13:10

Sunil Parmar


If you named dir for example values-zh it will be loaded only when Chinese is chosen in system language settings. You should know about that.

Value zh-rCN is correct and everything should work correctly. Read my notice above.

like image 42
TN888 Avatar answered Oct 06 '22 14:10

TN888


The correct locales are zh-rCN and zh-rTW,so then whatever Android software your using isn't correctly setting locale values.

Look into settings -> Language & Input to double check that Language is on Chinese, and if that fails look in the market for an application called MoreLocales2, it allows you to get around some of those stock Samsung softwares that prevent locale changing from working.

like image 22
Connor Tumbleson Avatar answered Oct 06 '22 14:10

Connor Tumbleson