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

后端 未结 6 1240
野性不改
野性不改 2021-02-06 05:41

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 informati

6条回答
  •  盖世英雄少女心
    2021-02-06 06:26

    you can use any way of both ways below:

    NSString *language = [[NSLocale currentLocale] localeIdentifier];
    NSLog(@"Language: %@", language);
    

    output: Language: en_US

    or this:

    NSString *language = [[NSLocale preferredLanguages] objectAtIndex:0];
    NSLog(@"Language: %@", language);
    

    output: Language: en

提交回复
热议问题