iOS应用程序的非英语默认语言? [英] Non-English default language for iOS App?

查看:225
本文介绍了iOS应用程序的非英语默认语言?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我正在为欧洲的客户开发应用程式。我是美国的英语讲师。我们的应用程序将支持多种语言,但不支持英语。我有我们的应用程序中的所有字符串翻译的Localized.strings文件,正确设置为不同的语言,它们都工作正常,当设备设置为正确的语言(设备的语言是德语=应用程序正确本地化为德语)

I am developing an app for a client in Europe. I am an English-speaker in the US. Our app is going to support a number of languages, but not English. I have all the strings in our app in translated Localized.strings files, set up correctly for the different languages, and they all work fine when the device is set to the correct language (device's language is German = app is correctly localized for German).

当设备未设置为我们支持的语言之一时,例如在我的手机上设置为英语时,会出现问题。我们希望手机回到德国在这样的情况下,但这不是发生。我们看到的是,手机正在使用在Settings.app的国际部分的语言列表中最高的语言。对于我的手机,列表上最高的非英语语言是法语,因此当我运行应用程序时,它是本地化为法语。如果我将手机改为德语,然后回到英语(这将更改语言列表中的顺序),应用程序然后本地化为德语。

There is a problem when the device is not set to one of the languages we support, for example, on my phone which is set to English. We want the phone to fall back to German in cases like this, but that is not happening. What we are seeing is that the phone is using the language that appears highest on the Language list in the International section of Settings.app. For my phone, the highest non-English language on the list is French, so when I run the app, it is localized for French. If I change my phone to German and then back to English (which changes the order in the Languages list), the app then localizes to German.

如何确保应用程序默认为德语的非支持语言?我使用此教程来为项目设置区域设置。这包括删除在首次本地化文件时创建的默认英语区域设置。在项目文件中,我添加了:

How can I ensure the app defaults to German for non-supported languages? I used this tutorial to set up the locales for the project. This includes removing the default "English" locale that is created when you first localize a file. In the project file, I've added:

developmentRegion = de;

此外,在Info.plist中,我有

Also, in the Info.plist, I have

<key>CFBundleDevelopmentRegion</key>
<string>de</string>

没有成功。

推荐答案

默认为特定的语言不是你应该努力的。假设居住在法国并流利地说法语的日本用户的手机设置为日语。你的应用程序将默认为德语,尽管它有一个法语翻译;我想这不是你想要的,它当然不是用户想要的。

Defaulting to a particular language is not what you should strive for. Suppose a japanese user living in France and fluently speaking French has his phone set to Japanese. Your App would default to German, despite it having a French translation; I guess that's not what you want and it's certainly not what the user wants.

因此,我建议尊重用户设置的语言优先级。

For this reason I suggest to respect the language prioritization as set by the user.

由于你不想支持英语,而是用英语开发了应用程序,你最容易做的就是摆脱 en.lproj 编译后。这将使应用程序只有您计划支持的语言,并且iPhone将选择最适合用户的语言,如iPhone的默认语言设置。

Since you don't want to support English but have developed the App in English, the easiest thing you can do is to just get rid of en.lproj right after compiling. This will leave the app with only the languages you plan to support, and the iPhone will chose the language best suited for the user, as set in iPhone's defaults.

有一个非常简单的解决方案删除特定的本地化

There is a pretty straightforward solution to deleting a specific localization:

让Xcode使用所有目前的本地化和代码签署之前删除 en.lproj 文件夹和所有本地化的文件的语言都消失了。你可以很容易地通过向目标添加一个Run Script Build阶段,包含这一行代码(它是一个Bash脚本):

Let Xcode build the App with all the present localizations and just before code-signing kicks in delete the en.lproj folder and all localized files for that language are gone. You can easily do this by adding a Run Script build phase to the target, containing this one line of code (it's a Bash Script):

rm -r "${TARGET_BUILD_DIR}/${PRODUCT_NAME}.app/en.lproj"

代码签名在所有构建阶段完成后总是启动,因此只需在当前阶段结束时进行构建阶段。

Code Signing always kicks in after all build phases have completed, so just put that build phase at the end of your current phases.

注意这会增加构建的时间,因为Xcode会重新创建所有的英语文件,因此您可能想在测试期间禁用此步骤。

Note that this increases the time to build because Xcode recreates all English files, so you might want to disable this step during testing.

我希望这是一个可行的解决方案。

I hope that's a viable solution for you.

关于在不存在适当的本地化的情况下,应用程序必须回到德语

问题是是否是适当的本地化?如果用户的第三个选择是法语(在2种不受支持的语言之后),则此解决方案将使应用返回法语,这是 适当的本地化。

Question is what is an appropriate localization? If the user's third choice is French (after 2 unsupported languages), this solution will make the app fall back to French, which is an appropriate localization. More appropriate than setting the user's fifth choice, German, by hand.

当应用程序启动时会发生什么事情:操作系统会降低用户语言列表,如首选项中设置的那样,直到找到匹配的本地化,并使用这种语言。许多应用程序默认为英语而不是德语的原因很简单,因为英语出现在德语以上的大多数用户语言列表中。系统没有固有的语言偏好。如果您删除英语翻译,只有您想要支持的语言,并且在这些语言中,用户列表中较高的语言。

What happens when an app launches is simple: The OS descends the users language list, as set in Preferences, until it finds a matching localization, and uses this language. The reason many apps default to English and not German is simply because English appears on most user language lists above German. There is no inherent language preference to the system. If you delete the English translation, only the languages you want to support are there, and of these languages the one higher on a user's list is taken.

这篇关于iOS应用程序的非英语默认语言?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆