xcode 除了包含完全相同的“翻译”的基本本地化之外,我还需要英语吗?
声明:本页面是StackOverFlow热门问题的中英对照翻译,遵循CC BY-SA 4.0协议,如果您需要使用它,必须同样遵循CC BY-SA许可,注明原文地址和作者信息,同时你必须将它归于原作者(不是我):StackOverFlow
原文地址: http://stackoverflow.com/questions/19916359/
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
Do I need English beside Base localization which would contain the exact same 'translation'?
提问by Pieter
I'd expect the base file to contain my English words since my project has "Localization native development region" set to English.
我希望基本文件包含我的英语单词,因为我的项目将“本地化本地开发区域”设置为英语。
Update - to clarify my question:
更新 - 澄清我的问题:
采纳答案by Ali
Although I am not entirely sure if I get this correctly, I will try to answer your question TTBOMK.
虽然我不完全确定我是否正确理解,但我会尝试回答您的问题 TTBOMK。
Suppose you're using NSLocalizedString(key, comment)
from in your code. You can clearly see that the first argument is actually is a key for a string, rather than the translated (or to be translated) string itself. Therefore when you “write code” you actually don't write strings in base language — or any other language for that matter. You should think it as if you're adding string placeholders in your code.
假设您NSLocalizedString(key, comment)
在代码中使用from 。您可以清楚地看到,第一个参数实际上是字符串的键,而不是已翻译(或将被翻译)的字符串本身。因此,当您“编写代码”时,您实际上不会使用基本语言或任何其他语言编写字符串。您应该将其视为在代码中添加字符串占位符。
Later on, you're supposed to create a Localizable.strings
file for each language you would like to support, in the form of key = value;
. To make your UI appear at least in one humanly–readable language you should at least have one Localizable.strings
file with proper string values for each placeholder key.
稍后,您应该为Localizable.strings
您想要支持的每种语言创建一个文件,格式为key = value;
. 为了让你的 UI 至少以一种人类可读的语言出现,你应该至少有一个Localizable.strings
文件,每个占位符键都有正确的字符串值。
For example: if you had NSLocalizedString(@“ConfirmationButtonTitle", @“Yada yada”)
in your code, then it makes totally sense having a Localizable.strings
file that contains ”ConfirmationButtonTitle” = “Tap here to confirm”;
element in it. If you don't create a Localizable.strings
file or no Localizable.strings
file contain ConfirmationButtonTitle
key, then button title falls back to ConfirmationButtonTitle
, since it is the name of the placeholder key.
例如:如果你NSLocalizedString(@“ConfirmationButtonTitle", @“Yada yada”)
的代码中有,那么拥有一个Localizable.strings
包含”ConfirmationButtonTitle” = “Tap here to confirm”;
元素的文件是完全有意义的。如果您不创建Localizable.strings
文件或没有Localizable.strings
文件包含ConfirmationButtonTitle
键,则按钮标题将回退到ConfirmationButtonTitle
,因为它是占位符键的名称。
Having said that, most people prefer naming their keys exactly as string values for various reasons. This is arguably a convenient — and very common — practice, but could lead to conflicts in people's minds.
话虽如此,出于各种原因,大多数人更喜欢将他们的键完全命名为字符串值。这可以说是一种方便且非常常见的做法,但可能会导致人们的思想冲突。
So, if you were to create the previous NSLocalizedString
example like NSLocalizedString(@“Tap here to confirm", @“Yada yada”)
instead, then your default/base Localizable.strings
file would probably contain an element like “Tap here to confirm” = “Tap here to confirm”;
.
因此,如果您要NSLocalizedString
像创建前一个示例那样NSLocalizedString(@“Tap here to confirm", @“Yada yada”)
,那么您的默认/基本Localizable.strings
文件可能会包含像“Tap here to confirm” = “Tap here to confirm”;
.
What happens here isn't that you're repeating yourself, but instead you're naming your key exactly as your base language's string value, that's all.
这里发生的不是你在重复自己,而是你将你的键命名为你的基本语言的字符串值,仅此而已。
EDIT
编辑
There always have been a base language concept, but as I understand it Xcode 5 emphasizes this even more: that's good. If your base language is English, then you don't have to have a Localizable.strings
file for English, again.
一直有一个基本的语言概念,但据我所知,Xcode 5 更加强调这一点:这很好。如果您的基本语言是英语,那么您不必再拥有Localizable.strings
英语文件。
回答by Nick Entin
Apart from addressing question what language end-users will see, you need to consider also what will be shown in the AppStore. My current experience is that if you use Base for English, English won't appear in list of supported languages (how Apple knows in which language your base localization is) in the description of your app.
除了解决最终用户将看到什么语言的问题外,您还需要考虑 AppStore 中将显示什么。我目前的经验是,如果您使用 Base for English,英语将不会出现在您的应用程序描述中的受支持语言列表中(Apple 如何知道您的基本本地化是哪种语言)。
I've met this issue myself - base (English), German and Russian
我自己也遇到过这个问题 - 基础(英语)、德语和俄语
Target settings refer to:
目标设置参考:
Localization native development region = en
But on Appstore it appears in this form:
但在 Appstore 上,它以这种形式出现:
Languages: German, Russian
no reference to English
没有参考英文
I consider to duplicate base localization to English (not a high priority, as users see from screenshots that App works in English anyway)
我考虑将基本本地化复制为英语(不是高优先级,因为用户从屏幕截图中看到 App 无论如何都可以使用英语)
Edit:there seem to be a different behavior in iOS8 - Application Settings (Settings.bundle) seem to ignore Base translation, if any of translations match your "Preferred Language Order".
编辑:iOS8 中似乎有不同的行为 - 应用程序设置 (Settings.bundle) 似乎忽略基本翻译,如果任何翻译符合您的“首选语言顺序”。
In other words, App is localized: Base, German, Russian. iPhone is configured to use English, preferred languages order is English, German, Russian.
换句话说,App 已本地化:Base、德语、俄语。iPhone 配置为使用英语,首选语言顺序为英语、德语、俄语。
Application settings come in ... German!
应用程序设置进来......德语!
Once again: this is applied to Settings onlynot to the application itself!
再一次:这仅适用于设置而不适用于应用程序本身!
回答by Suragch
According to the documentation(scroll down to Creating Strings Files for User-Facing Text in Your Code), you shouldn't add Localizable.strings
to the Base localization. Even if your development language is English, create a separate folder and Localizable.strings
for English. Create others for each additional language you want to add.
根据文档(向下滚动到在代码中为面向用户的文本创建字符串文件),您不应添加Localizable.strings
到基本本地化。即使您的开发语言是英语,也要为英语创建一个单独的文件夹Localizable.strings
。为您要添加的每种其他语言创建其他语言。