Xcode:使用指定的本地化运行项目

发布于 2024-12-22 04:03:20 字数 118 浏览 4 评论 0原文


我的 Cocoa 项目已本地化为意大利语(我的语言)和英语。
如果我运行它,我会看到意大利语的所有内容(当然,我的操作系统是意大利语!)。
如何在不更改操作系统语言的情况下运行它来测试英语本地化?

My Cocoa project is localized in Italian (my language) and English language.
If I run it, i see everything in Italian (of course, my OS is italian!).
How can I run it to test the English localization without changing the OS language?

如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。

扫码二维码加入Web技术交流群

发布评论

需要 登录 才能够评论, 你可以免费 注册 一个本站的账号。

评论(2

夜司空 2024-12-29 04:03:20

在过去,Leopard 和之前的版本中,Finder 中的获取信息窗口可以让
您选择可用的语言。所以这是一个取消选择的问题
您不想使用的语言,它将“默认”为另一种语言。

现在,您可以使用像这个这样的实用程序。我很想知道它是什么
但在幕后确实如此。


我终于在 cocoa-dev 邮件列表中找到了一个很好的解决方案档案
显然,您可以更改传递给的参数中的默认域
您的可执行文件,这会导致全局首选项被覆盖。它
可以使用 -AppleLanguages 标志来实现,传递语言列表
按首选顺序:

~/apath/AppName.app/Contents/MacOS/AppName -AppleLanguages "(Italian, English)"

从终端运行此命令,它应该为
语言。请注意,您还可以指定单个元素列表“(意大利语)”
——对于测试目的来说更有意义。

要在 Xcode 中执行此操作并避免使用终端,请转到菜单 Product >编辑
计划……
。然后,在运行配置中切换到参数选项卡并
创建一个新的并在启动时传递。添加-AppleLanguages“(日语)”
给它发短信。与此类似的内容:

Xcode Screen Shot

In the old times, Leopard and before, the get info window in Finder would let
you choose the available languages. So it was a matter of deselecting the
language that you don't want to use and it would "default" to the other.

These days you can use an utility like this one. I'd love to know what it
does behind the scenes though.


I finally found a nice solution in the cocoa-dev mailing list archives.
Apparently, you can change the default domain within the arguments passed to
your executable, and this causes the global preference to be overwritten. It
can be achieved with the -AppleLanguages flag, pass a list of the languages
in the preferred order:

~/apath/AppName.app/Contents/MacOS/AppName -AppleLanguages "(Italian, English)"

Run this from your terminal and it should give a different precedence for the
language. Notice you can also specify a single element list "(Italian)"
—makes more sense for testing purposes.

To do it within Xcode and avoid the terminal, go to the menu Product > Edit
Scheme…
. Then, in your run configuration switch to the Arguments tab and
create a new one to be passed on launch. Add -AppleLanguages "(Japanese)"
text to it. Something similar to this:

Xcode Screen Shot

勿挽旧人 2024-12-29 04:03:20

假设您有一个包含所有字符串的文件,请交换文件的名称。或者,如果您的项目中有 it.lproj 和 en.lproj 组,只需将您的 InfoPlist.strings (或您命名的任何名称)移动到另一个组中,反之亦然。

Assuming you have a file that holds all the strings, swap the names of the files. Or, if you've got a it.lproj and en.lproj group in your project, just move your InfoPlist.strings (or whatever you named it) into the other group and vice versa.

~没有更多了~
我们使用 Cookies 和其他技术来定制您的体验包括您的登录状态等。通过阅读我们的 隐私政策 了解更多相关信息。 单击 接受 或继续使用网站,即表示您同意使用 Cookies 和您的相关数据。
原文