LoginSignup
12
12

More than 5 years have passed since last update.

iOSの言語環境を取得する

Last updated at Posted at 2014-04-28
NSArray *langs = [NSLocale preferredLanguages];
NSString *langID = [langs objectAtIndex:0];

とするのがよい。
別の方法として、

NSString *localeIdentifier = [[NSLocale currentLocale] localeIdentifier];

としてしまうと、言語環境を英語にしてても、初期のほうが日本のままだと取得されるのも"ja_JP"になってしまうので要注意。

英語圏の人は、言語を英語にしたら書式も英語にしてると思われるので問題はないと思いますが、preferredLanguagesをみたほうが無難そう。

NSLocale *locale = [[NSLocale alloc] initWithLocaleIdentifier:langID];

取得された文字列からNSLocaleを作成。

12
12
0

Register as a new user and use Qiita more conveniently

  1. You get articles that match your needs
  2. You can efficiently read back useful information
  3. You can use dark theme
What you can do with signing up
12
12