0

有没有办法以自动方式更改 iphone 国际语言,以便在我们启动应用程序时它显示为目标区域设置 (ll-CC) 的本地化?

非常感谢您的帮助!

4

3 回答 3

0

Yes there is! I actually wrote a small bash script to do just that for my UI Automation-powered app screenshot taker. Grab it from here:

https://github.com/jonathanpenn/ui-screen-shooter/blob/master/bin/choose_sim_language

Feel free to explore it to see how it works. To use it you just need to run it with the locale code you choose.

./choose_sim_language en

All the simulator versions will be set to the one you gave it. Run the script without any parameters to have it print out the current language.

于 2013-04-10T13:07:52.673 回答
0

从这个意义上说,不确定您所说的自动化是什么意思。您需要将您的应用程序国际化,然后提供本地化翻译。如果您已针对特定语言本地化您的应用程序,那么它将在使用该语言的语言环境中工作。

可以在此处找到有关国际化(iOS 和 OS X)的基础知识。

于 2013-04-10T05:31:41.167 回答
0

如果您针对的是实际设备,则需要覆盖AppleLanguages首选项:

[[NSUserDefaults standardUserDefaults] setObject: [NSArray arrayWithObjects:lang, nil] forKey:@"AppleLanguages"];

在此处查看完整的工作解决方案:http: //aggressive-mediocrity.blogspot.com.es/2010/03/custom-localization-system-for-your.html

您不需要该文章中指出的自定义本地化宏,只需要#undef它们和#define它们来使用您的类。

您需要一些机制来更改应用程序中的语言:UI 中的某些内容或只是一个环境变量(如果您正在执行此操作,请在启动 Instruments 时在命令行中设置它)。

于 2013-04-12T10:52:47.557 回答