使用 Xcode 10 进行基础国际化
声明:本页面是StackOverFlow热门问题的中英对照翻译,遵循CC BY-SA 4.0协议,如果您需要使用它,必须同样遵循CC BY-SA许可,注明原文地址和作者信息,同时你必须将它归于原作者(不是我):StackOverFlow
原文地址: http://stackoverflow.com/questions/51742614/
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
Base internationalisation with Xcode 10
提问by cyanide
My project declares two languages: English as development and French as additional. Also it has Use Base Internationalization
ticked.
我的项目声明了两种语言:英语作为开发语言,法语作为附加语言。它也Use Base Internationalization
打勾了。
When I localise a Strings file in Xcode 9, I normally move the content to French, then tick Base
in Localization
list. This gives two copies of the new Strings file one in Base.lproj
(containing English text), another in fr.lproj
, so English will be used for a language other than French.
当我在 Xcode 9 中本地化一个字符串文件时,我通常将内容移动到法语,然后Base
在Localization
列表中打勾。这提供了新字符串文件的两个副本,一个 in Base.lproj
(包含英文文本),另一个 in fr.lproj
,因此英语将用于法语以外的语言。
With Xcode 10, the Localization
doesn't list Base
, so I can't see a way to use Base.lproj
other than doing localisation in Xcode 9 and then revert to Xcode 10 with Base file already created.
使用 Xcode 10,Localization
则没有列出Base
,因此Base.lproj
除了在 Xcode 9 中进行本地化然后恢复到已创建 Base 文件的 Xcode 10 之外,我看不到其他使用方法。
Is that a bug, or this is how it is meant to be?
这是一个错误,或者这就是它的本意?
Update 20Sep18.
18 年 9 月 20 日更新。
Now there is an official release of XCode 10 and the issue persists even though Use Base Internationalization
flag is still there.
If this is not a bug, can someone explain what is going on? There should be an Apple documentation to discuss that.
现在有了 XCode 10 的正式版本,即使Use Base Internationalization
flag 仍然存在,问题仍然存在。如果这不是错误,有人可以解释发生了什么吗?应该有一个 Apple 文档来讨论这个问题。
BTW, a storyboard
or a nib
still list Base when localised. Only a Strings
file appears to have the issue.
顺便说一句,本地化时的一个storyboard
或一个nib
静止列表基地。只有一个Strings
文件似乎有问题。
回答by zhi zhou
This happens because iOS doesn't only looks for the current system language. It looks for the first supported language in the list of preferred languages.
发生这种情况是因为 iOS 不仅会查找当前的系统语言。它会在首选语言列表中查找第一个支持的语言。
But when you choose language in system preferences, iOS automatically adds this language to the list of preferred languages (Settings -- General -- Language & Region -- "Preferred language order" section).
但是当您在系统偏好设置中选择语言时,iOS 会自动将此语言添加到首选语言列表(设置--通用--语言和区域--“首选语言顺序”部分)。
Thus, when you change language to unsupported language, the app selected the second language in the "Preferred language order" list.
因此,当您将语言更改为不受支持的语言时,应用程序会在“首选语言顺序”列表中选择第二种语言。
So, the "Base.lproj" file doesn't work.
因此,“Base.lproj”文件不起作用。
Perhaps for this reason, Apple removed "Base.lproj" from Xcode 10.
也许正是因为这个原因,Apple 从 Xcode 10 中删除了“Base.lproj”。