8

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).

TN888
  • 7,659
  • 9
  • 48
  • 84
Aviran
  • 5,160
  • 7
  • 44
  • 76

3 Answers3

9

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.

TN888
  • 7,659
  • 9
  • 48
  • 84
  • 2
    values-zh works fine, but I need to differentiate between Simplified Chinese and Traditional Chinese. I tried to load the locale manually, using Locale and getBaseContext().getResources().updateConfiguration(). But still, if the values are in values-zh-rCN they are not being loaded. for some reason they are ignored. any idea why? – Aviran Jul 24 '13 at 21:18
  • Did you read that article : http://stackoverflow.com/questions/2264874/changing-locale-within-the-app-itself ? – TN888 Jul 24 '13 at 21:22
  • @aviran use zh_CN if you want to load the contents of zh_rCN if you set the locale manually. – steven0529 Jan 09 '15 at 09:27
9

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());
Sunil Parmar
  • 1,223
  • 1
  • 13
  • 22
3

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.

Connor Tumbleson
  • 3,270
  • 2
  • 25
  • 37
  • 4
    This is incorrect. You should place your Chinese (Traditional) translations into values-zh so that locales other than zh-TW will still get Traditional Chinese translations. If your user is form Macau (zh_MO), or Hong Kong (zh_HK), and you don't include a values-zh directory, they would see English text instead of Traditional Chinese. Place your Simplified Chinese translation in values-zh-rCN because Simplified Chinese is used in fewer locales. – Sky Kelsey Aug 28 '13 at 23:15
  • The user had asked for Simplified & Traditional which I provided. There was no mention in the OP about using `values-zh` or anything like that so thanks for the -1. – Connor Tumbleson Aug 29 '13 at 14:49
  • Exactly what I need. Thanks. – TPG Aug 08 '15 at 09:05