views:

456

answers:

4

I develop an application for MacOSX.

Therefore I want to change indication contents by the language locale (English, Spanish, etc.) of the application user,

How to get information which language use ?

I'm happy , If you give me some example codes

+6  A: 

You can use the NSLocale API to get that information, but it isn't necessary to do what you want to do. OS X has support for localization built into the OS — all you need to do is supply the appropriate language files and the user can select which language he wants.

Chuck
Yes. Do NOT write code that says "if english, do this... if spanish, do this." This is a software problem that occurs all over the place - and the OS provides good ways of handling it!
Ben Gotow
Thank you so much! I'm happy , If you give me some example codes
ffffff
It's not exactly the sort of thing where you can just give example code, since Mac user interfaces are usually stored in nibs and thus there isn't really any code responsible. Basically, there's a directory structure your app's resources need to follow and the OS will handle the rest for you. Read the localization docs in the link I gave you and you'll see how it works. For occasions where you are rendering text programmatically, you'll generally use the NSLocalizedString() function.
Chuck
+3  A: 

You're looking to "localize" your application. To get started, check out the Apple docs here: Internationalization - Apple Developer Docs. Without knowing more about your specific application, it'd be hard to suggest anything more here!

Ben Gotow
+1  A: 
NSLog(@"localeIdentifier: %@", [[NSLocale currentLocale] localeIdentifier]);
chaostheory
A: 

Hi, I would like to know how is it possible to let the user change the current language?! If he wants to have french language, how can I specify that I want to use my fr.strings file ?!