NSLocale currentLocale always returns “en_US” not user's current language

后端 未结 9 1657
夕颜
夕颜 2020-11-30 21:28

I\'m in the processes of internationalizing an iPhone app - I need to make programmatic changes to certain views based on what the user\'s current locale is. I\'m going nut

相关标签:
9条回答
  • 2020-11-30 21:52

    It shows the correct locale when on a real iPad. However, the simulator has it´s own iOS which by default is set to en-US. Go to the simulator iOS preferences and switch language & region to the one you want.

    That does the trick.

    0 讨论(0)
  • 2020-11-30 21:53

    To get the current device language use this instead:

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

    As described here: Getting current device language in iOS?

    0 讨论(0)
  • 2020-11-30 21:54

    [NSLocale currentLocale] is based on the device's Region Format settings, not the language. If the region is set to United States you will get en_US regardless of which language you're using.

    0 讨论(0)
提交回复
热议问题