Simulator's language already changed to Japanese, why [[NSLocale preferredLanguages] objectAtIndex:0]
always return "en"
?
模拟器的语言已经更改为日语,为什么[NSLocale preferredLanguages] objectAtIndex:0]总是返回“en”?
Neither preferred language nor region is related to "en", where does "en"
come from?
首选语言和地区都与“en”没有关系,“en”从何而来?
Tried to get [[NSLocale preferredLanguages] objectAtIndex:
2]
, then crash shows *** Terminating app due to uncaught exception 'NSRangeException', reason: '-[__NSCFArray objectAtIndex:]: index (2) beyond bounds (1)
尝试获取[[NSLocale] objectAtIndex:2],然后崩溃显示**终止应用程序,原因是:'-[__NSCFArray objectAtIndex:]:索引(2)超出界限(1)
Does it means there is no any languages are set in simulator? So weird!
这是否意味着在模拟器中没有设置任何语言?这么奇怪!
This never happened before upgrading to Xcode 6.1 with iOS8.1/7.1.
这在使用iOS8.1/7.1升级到Xcode 6.1之前从未发生过。
Meanwhile, tried same thing on my iPhone 5, console output correct thing.
与此同时,我在iPhone 5上尝试了同样的操作,控制台输出正确。
Why so weird? Does anybody have such problems?
为什么这么奇怪?有人有这样的问题吗?
Updates: 1
- Delete Xcode as well as simulators, and reinstall it by downloading from Mac Store.
- 删除Xcode和模拟器,并通过从Mac Store下载重新安装。
- Create a new simple project, change simlulator's language
- 创建一个新的简单项目,改变simlulator的语言
- Still get always "en".
- 仍然会总是“嗯”。
Oh! What's wrong....
哦!怎么了....
Updates: 2
- Today, reinstalled brand new Yosemite by reformatting HD
- 今天,通过重新格式化HD重新安装了全新的优胜美地
- Download Xcode 6.1
- 下载Xcode 6.1
- Start a new simple default project
- 启动一个新的简单的默认项目
- Put these codes
- 把这些代码
- Change / Add language of simulator, Japanese, Dutch, English,
- 修改/添加模拟器语言,日语,荷兰语,英语,
- Run
- 运行
- Oh, God! Got only
"en"
again, Japanese and English not found! - 哦,上帝!又得了“en”,日语和英语都找不到!
Why still only one "en"
could be found? Where are Japanese and English?
What happened to simulators?
Is there anything I missed?
2 个解决方案
#1
27
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
iOS8.1模拟器总是使用美国键盘布局,而不使用德国硬件键盘
and this:
这:
iOS 8.1 Simulator Localization broken (NSLocalizedString)
ios8.1模拟器本地化破坏(NSLocalizedString)
(In the answer there is a temporary fix changing the schema)
(在答案中,有一个临时修复改变了模式)
Best, gigi
最好,吉吉。
#2
0
My iOS simulator suddenly started reporting "en"
rather than "en-US"
, so it seems this issue is still active.
我的iOS模拟器突然开始报告“en”而不是“en- us”,所以这个问题似乎仍然很活跃。
Xcode 8.2.1, iOS 10
Xcode 8.2.1,iOS 10
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.
我进入语言环境,选择了英语和美国。我选择了加拿大和法语,并获得了“fr-CA”。然后我又把它换回来,开始再次收到“en-US”。从那以后我就再也无法重现“en”问题了。
So it appears we cannot pass the values of [NSLocale preferredLanguages]
on assuming they will be Language-Region pairs.
因此,我们似乎不能传递[NSLocale preferredLanguages]的值,假设它们是语言区域对。
#1
27
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
iOS8.1模拟器总是使用美国键盘布局,而不使用德国硬件键盘
and this:
这:
iOS 8.1 Simulator Localization broken (NSLocalizedString)
ios8.1模拟器本地化破坏(NSLocalizedString)
(In the answer there is a temporary fix changing the schema)
(在答案中,有一个临时修复改变了模式)
Best, gigi
最好,吉吉。
#2
0
My iOS simulator suddenly started reporting "en"
rather than "en-US"
, so it seems this issue is still active.
我的iOS模拟器突然开始报告“en”而不是“en- us”,所以这个问题似乎仍然很活跃。
Xcode 8.2.1, iOS 10
Xcode 8.2.1,iOS 10
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.
我进入语言环境,选择了英语和美国。我选择了加拿大和法语,并获得了“fr-CA”。然后我又把它换回来,开始再次收到“en-US”。从那以后我就再也无法重现“en”问题了。
So it appears we cannot pass the values of [NSLocale preferredLanguages]
on assuming they will be Language-Region pairs.
因此,我们似乎不能传递[NSLocale preferredLanguages]的值,假设它们是语言区域对。