NSLocale preferredLanguages objectAtIndex:0 always return “en”

后端 未结 2 1440
旧时难觅i
旧时难觅i 2020-12-15 04:47

Simulator\'s language already changed to Japanese, why [[NSLocale preferredLanguages] objectAtIndex:0] always return "en"

相关标签:
2条回答
  • 2020-12-15 05:01

    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

    0 讨论(0)
  • 2020-12-15 05:09

    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.

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