在 iOS 8.1 模拟器上更改语言不起作用

声明:本页面是StackOverFlow热门问题的中英对照翻译,遵循CC BY-SA 4.0协议,如果您需要使用它,必须同样遵循CC BY-SA许可,注明原文地址和作者信息,同时你必须将它归于原作者(不是我):StackOverFlow 原文地址: http://stackoverflow.com/questions/24588105/
Warning: these are provided under cc-by-sa 4.0 license. You are free to use/share it, But you must attribute it to the original authors (not me): StackOverFlow

提示:将鼠标放在中文语句上可以显示对应的英文。显示中英文
时间:2020-08-31 01:14:18  来源:igfitidea点击:

Changing language on iOS 8.1 simulator does not work

ioslocalizationios-simulatorxcode6.1ios8.1

提问by Janos

If I change the language on an iOS 8.1 simulator to anything and try to detect this from code with

如果我将 iOS 8.1 模拟器上的语言更改为任何内容并尝试从代码中检测到

NSString * language = [[NSLocale preferredLanguages] objectAtIndex:0];
NSLog(@"Language: %@", language);

I get "en" back. I've tried resetting the navigator, etc. I've tried this using the iOS 7.1 runtime (in Xcode 5.1.1), and it worked fine. Has anyone managed to find a workaround to this problem?

我得到“en”回来。我试过重置导航器等。我试过使用 iOS 7.1 运行时(在 Xcode 5.1.1 中),它工作正常。有没有人设法找到解决此问题的方法?

回答by adjwilli

According to the release notes this is a known issue. There is a work around. If you go to "Edit Scheme..." then the "Options" tab there's an "Application Language" option. This only affects the current run settings, not the app, much like changing the language of the device.

根据发行说明,这是一个已知问题。有一个解决办法。如果您转到“编辑方案...”,则“选项”选项卡有一个“应用程序语言”选项。这只会影响当前的运行设置,而不是应用程序,就像更改设备的语言一样。

enter image description here

在此处输入图片说明

回答by Adobels

My simulator is in French language. When I want to check interface in English then changing the iphone language is not enough. I have to switch the region settings minimum two times.

我的模拟器是法语。当我想查看英文界面时,更改 iphone 语言是不够的。我必须至少两次切换区域设置。

回答by Jeremy Huddleston Sequoia

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

尽管德国硬件键盘iOS8.1 模拟器的另一个骗局总是使用美式键盘布局

Known and documented bug as mentioned in the Xcode 6.1 release notes. File a radar if you want to add your +1 to the complaint list at http://bugreport.apple.com

Xcode 6.1 发行说明中提到的已知和记录的错误。如果您想将 +1 添加到http://bugreport.apple.com的投诉列表中,请提交雷达

回答by Matsumoto Kazuya

In my case, editing schema works for region but not for language. It looks overwrite by development language. Changing developmentRegion works fine with project.pbxproj like this.

就我而言,编辑模式适用于区域,但不适用于语言。它看起来被开发语言覆盖。像这样更改 developmentRegion 可以很好地与 project.pbxproj 一起使用。

developmentRegion = ja;

enter image description here

在此处输入图片说明

Xcode Version 11.3.1 (11C504)

Xcode 版本 11.3.1 (11C504)

iPhoneX iOS 13.3.1

iPhoneX iOS 13.3.1

回答by Diego

use [[NSLocale availableLocaleIdentifiers]

使用 [[NSLocale availableLocaleIdentifiers]