Become a MacRumors Supporter for $50/year with no ads, ability to filter front page stories, and private forums.

satyam90

macrumors regular
Original poster
Jul 30, 2007
242
0
Bangalore, India
I am using Cocoa with Obj C.
In my application I implemented "Help" using html pages. For implementing the same in different languages, I created a Help directory which has subdirectories with language code like ja for Japanese, es for Spanish, fr for French etc.
Now from my application, I am using following code in order to get the language code:
Code:
NSUserDefaults* defs = [NSUserDefaults standardUserDefaults];
NSArray* languages = [defs objectForKey:@"AppleLanguages"];
NSString* preferredLang = [languages objectAtIndex:0]; 
if( ![preferredLang hasPrefix:@"zh"] )
{
  NSString *langStrCode = [(NSString *)preferredLang substringToIndex:2];  // cut off the country and just use first two digits
}

Am I using appropriate code in getting language codes?
For Simple Chinese I am getting zh_Hans and Traditional Chinese it is zh_Hant. But from other applications I noted that the language code is zh_CN and zh_TW respectively.

Can somebody tell me how to get the language code zh_CN and zh_TW in case of Chinese programaticallly?
 
Register on MacRumors! This sidebar will go away, and you'll see fewer ads.