Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

How to get language locale of the user in Objective-C?

I am developing an application for Mac OS X. I want to change indication contents by the language locale (English, Spanish, etc.) of the application user, how do I get information of which language is used?

like image 725
freddiefujiwara Avatar asked Jul 06 '09 05:07

freddiefujiwara


People also ask

What is current locale?

A locale representing the user's region settings at the time the property is read.

How do I get current locale in Swift?

Detailed Answer: current returns the current locale, that is, the value set by Settings > General > Language & Region > Region Formats.

How do I find current device language?

You can use Locale. getDefault(). getLanguage(); to get the usual language code (e.g. "de", "en").

What is language locale?

A locale is a set that defines the language and region preferences that the user wants to see in their user interface. Usually a locale identifier includes a language code and a country or region code.


2 Answers

NSLog(@"localeIdentifier: %@", [[NSLocale currentLocale] localeIdentifier]);
like image 115
chaostheory Avatar answered Oct 27 '22 11:10

chaostheory


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.

like image 40
Chuck Avatar answered Oct 27 '22 12:10

Chuck