我的Base Internationalization故事板是否必须与所有非本地化语言和字符串的后备语言相对应?

时间:2023-01-23 18:49:46

I've looked through some internationalization documentation and videos on apple developer, but I never found an explicit answer to that question. In Apple's tutorials I see the Base.lproj folder alongside en.lproj and zh.lproj -- the example translation (localization) is from English to Chinese. But they tell me that there's a file en.lproj/myStoryboard.strings, and that is confusing. I can't see the point in creating an English localization for the storyboard (that is already in English).

我查看了苹果开发人员的一些国际化文档和视频,但我从未找到过该问题的明确答案。在Apple的教程中,我看到了Base.lproj文件夹以及en.lproj和zh.lproj - 示例翻译(本地化)是从英文到中文。但他们告诉我,有一个文件en.lproj / myStoryboard.strings,这很令人困惑。我无法看到为故事板创建英语本地化的重点(已经是英文版)。

  1. So my questions are if the user will ever see the strings in the Base.lproj/myStoryboard.storyboard?
  2. 所以我的问题是用户是否会在Base.lproj / myStoryboard.storyboard中看到字符串?
  3. Do the strings in that file have to be the default strings that are shown to the user if the system cannot find the user's preferred language folder in my bundle?
  4. 如果系统在我的捆绑包中找不到用户的首选语言文件夹,那么该文件中的字符串是否必须是向用户显示的默认字符串?
  5. Can I explicitly say "never use Base.lproj/myStoryboard.storyboard, always fall back on en.lproj/myStoryboard.strings"?
  6. 我可以明确地说“永远不要使用Base.lproj / myStoryboard.storyboard,总是回到en.lproj / myStoryboard.strings”吗?

In other words:
Let's say I want my app to display in English whenever the user's language isn't available, but that my Base.lproj/myStoryboard.storyboard is in Swedish. Do I then have to localize the Base Storyboard to sv.lproj/myStoryboard.strings and translate all strings in the Base storyboard to English to accomplish this?

换句话说:假设用户的语言不可用,我希望我的应用程序以英语显示,但我的Base.lproj / myStoryboard.storyboard是瑞典语。那么我是否必须将基本故事板本地化为sv.lproj / myStoryboard.strings并将Base故事板中的所有字符串翻译为英语才能完成此操作?

2 个解决方案

#1


3  

In my case, XCode 5 didn't create a en.lproj/myStoryboard.strings, there's only the original storyboard in the Base.lproj folder. Maybe it's an old XCode issue?

在我的例子中,XCode 5没有创建en.lproj / myStoryboard.strings,只有Base.lproj文件夹中的原始故事板。也许这是一个旧的XCode问题?

Try to remove that file and see if your app gets along with Base.lproj for default, English strings.

尝试删除该文件,看看你的应用程序是否与Base.lproj一起使用默认的英文字符串。

Your Info.plist file should have an entry Localization native development region, which points to the lproj folder to be used in case the required string doesn't exist in the preferred language.

您的Info.plist文件应具有一个条目本地化本机开发区域,该区域指向要在首选语言中不存在所需字符串的情况下使用的lproj文件夹。

I'm not sure about this, but I think you have to use en and UI with a Base.lproj would automatically fallback to Base.lproj.

我不确定这一点,但我认为你必须使用en和UI与Base.lproj会自动回退到Base.lproj。

Does that help you in any way?

这对你有什么帮助吗?

#2


3  

  1. So my questions are if the user will ever see the strings in the Base.lproj/myStoryboard.storyboard?
  2. 所以我的问题是用户是否会在Base.lproj / myStoryboard.storyboard中看到字符串?

It is the default to use those strings for the development region localization, which is typically English. If there was a matching strings file for english, it would supersede the strings in the storyboard. This is typically redundant, so it isn't normally used. If you really want all of your languages to be handled identically, you can do this.

默认情况下,这些字符串用于开发区域本地化,通常是英语。如果有一个匹配的英文字符串文件,它将取代故事板中的字符串。这通常是多余的,因此通常不会使用。如果您确实希望以相同的方式处理所有语言,则可以执行此操作。

Do the strings in that file have to be the default strings that are shown to the user if the system cannot find the user's preferred language folder in my bundle?

如果系统在我的捆绑包中找不到用户的首选语言文件夹,那么该文件中的字符串是否必须是向用户显示的默认字符串?

These are unrelated concepts. The strings embedded in the storyboard are equivalent to having ones in en.lproj. After that, language fallback works the same as without Base.lproj.

这些是不相关的概念。嵌入在故事板中的字符串等同于en.lproj中的字符串。之后,语言回退与没有Base.lproj的情况相同。

Can I explicitly say "never use Base.lproj/myStoryboard.storyboard, always fall back on en.lproj/myStoryboard.strings"?

我可以明确地说“永远不要使用Base.lproj / myStoryboard.storyboard,总是回到en.lproj / myStoryboard.strings”吗?

If you have en.lproj/myStoryboard.strings, and english is the development language, they will always superseded the strings embedded in Base.lproj/myStoryboard.storyboard for English. Including when English isn't the preferred language, but ends up being chosen as the fallback language.

如果你有en.lproj / myStoryboard.strings,而english是开发语言,他们将总是取代嵌入在Base.lproj / myStoryboard.storyboard中的英文字符串。包括英语不是首选语言,但最终被选为后备语言。

#1


3  

In my case, XCode 5 didn't create a en.lproj/myStoryboard.strings, there's only the original storyboard in the Base.lproj folder. Maybe it's an old XCode issue?

在我的例子中,XCode 5没有创建en.lproj / myStoryboard.strings,只有Base.lproj文件夹中的原始故事板。也许这是一个旧的XCode问题?

Try to remove that file and see if your app gets along with Base.lproj for default, English strings.

尝试删除该文件,看看你的应用程序是否与Base.lproj一起使用默认的英文字符串。

Your Info.plist file should have an entry Localization native development region, which points to the lproj folder to be used in case the required string doesn't exist in the preferred language.

您的Info.plist文件应具有一个条目本地化本机开发区域,该区域指向要在首选语言中不存在所需字符串的情况下使用的lproj文件夹。

I'm not sure about this, but I think you have to use en and UI with a Base.lproj would automatically fallback to Base.lproj.

我不确定这一点,但我认为你必须使用en和UI与Base.lproj会自动回退到Base.lproj。

Does that help you in any way?

这对你有什么帮助吗?

#2


3  

  1. So my questions are if the user will ever see the strings in the Base.lproj/myStoryboard.storyboard?
  2. 所以我的问题是用户是否会在Base.lproj / myStoryboard.storyboard中看到字符串?

It is the default to use those strings for the development region localization, which is typically English. If there was a matching strings file for english, it would supersede the strings in the storyboard. This is typically redundant, so it isn't normally used. If you really want all of your languages to be handled identically, you can do this.

默认情况下,这些字符串用于开发区域本地化,通常是英语。如果有一个匹配的英文字符串文件,它将取代故事板中的字符串。这通常是多余的,因此通常不会使用。如果您确实希望以相同的方式处理所有语言,则可以执行此操作。

Do the strings in that file have to be the default strings that are shown to the user if the system cannot find the user's preferred language folder in my bundle?

如果系统在我的捆绑包中找不到用户的首选语言文件夹,那么该文件中的字符串是否必须是向用户显示的默认字符串?

These are unrelated concepts. The strings embedded in the storyboard are equivalent to having ones in en.lproj. After that, language fallback works the same as without Base.lproj.

这些是不相关的概念。嵌入在故事板中的字符串等同于en.lproj中的字符串。之后,语言回退与没有Base.lproj的情况相同。

Can I explicitly say "never use Base.lproj/myStoryboard.storyboard, always fall back on en.lproj/myStoryboard.strings"?

我可以明确地说“永远不要使用Base.lproj / myStoryboard.storyboard,总是回到en.lproj / myStoryboard.strings”吗?

If you have en.lproj/myStoryboard.strings, and english is the development language, they will always superseded the strings embedded in Base.lproj/myStoryboard.storyboard for English. Including when English isn't the preferred language, but ends up being chosen as the fallback language.

如果你有en.lproj / myStoryboard.strings,而english是开发语言,他们将总是取代嵌入在Base.lproj / myStoryboard.storyboard中的英文字符串。包括英语不是首选语言,但最终被选为后备语言。