24
20

Delete article

Deleted articles cannot be recovered.

Draft of this article would be also deleted.

Are you sure you want to delete this article?

More than 5 years have passed since last update.

iOS ユーザーの設定言語が日本語かどうか判定するメソッド

Last updated at Posted at 2013-12-03

こちらに書かれている内容をメソッドにしただけですが。
http://ios-dev.info/how-to-get-selected-lang/

日本語ならYES、そうでなければNOを返します。
"ja"の部分を変えればいろんな言語に応用できます。

// 日本語かどうか判定
-(BOOL)isLocaleJapanese{
	//まず言語のリストを取得します。
	NSArray *languages = [NSLocale preferredLanguages];
	// 取得したリストの0番目に、現在選択されている言語の言語コード(日本語なら”ja”)が格納されるので、NSStringに格納します。
	NSString *languageID = [languages objectAtIndex:0];
	
	// 日本語の場合はYESを返す
	if ([languageID isEqualToString:@"ja"]) {
		return YES;
	}
	
	// 日本語の以外はNO
	return NO;
}
24
20
3

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
24
20

Delete article

Deleted articles cannot be recovered.

Draft of this article would be also deleted.

Are you sure you want to delete this article?