NSLocale preferredLanguages objectAtIndex:0 always return “en”

◇◆丶佛笑我妖孽 提交于 2019-11-28 22:52:49
J.Williams

This is a bug. It was driving me crazy. Apple already knows it.

See this answers:

iOS8.1 Simulator always uses US keyboard layout despite german hardware keyboard

and this:

iOS 8.1 Simulator Localization broken (NSLocalizedString)

(In the answer there is a temporary fix changing the schema)

Best, gigi

My iOS simulator suddenly started reporting "en" rather than "en-US", so it seems this issue is still active.

Reproduced in:

  • Xcode 8.2.1, iOS 10
  • Xcode 9.4.1, iOS 11

I went into the language settings and English and United States were selected. I selected Canada and French, and got "fr-CA". I then switched it back and started getting "en-US" again. I've been unable to reproduce the "en" issue since.

So it appears we cannot pass the values of [NSLocale preferredLanguages] on assuming they will be Language-Region pairs.

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!