preferredLanguages iOS 9

前端 未结 5 2015
轻奢々
轻奢々 2020-12-11 09:36

in order to localize my App, I use the following code:

NSString * language = [[NSLocale preferredLanguages] objectAtIndex:0];  
             if ([language is         


        
5条回答
  •  一个人的身影
    2020-12-11 10:09

    You shouldn't split the NSLocale. NSLocale has some Keys, which you can retrieve with objectForKey:

    In your example you can write the following:

    [[[NSLocale currentLocale] objectForKey:NSLocaleLanguageCode]
                isEqualToString:@"fr"]
    

    [NSLocale currentLocale] is actually the same as [[NSLocale preferredLanguages] firstObject] but has some additional information where you can retrieve which decimal separator should be used or which currency symbol.

    Other relevant Keys can be found in the class reference from apple.

提交回复
热议问题