NSLocale preferredLanguages objectAtIndex:0 always return “en”

后端 未结 2 1439
旧时难觅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: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.

提交回复
热议问题