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

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

问题描述

我正在为欧洲的客户开发应用程序.我在美国说英语.我们的应用程序将支持多种语言,但不支持英语.我在翻译的 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>

没有成功.

任何想法都将不胜感激!

Any ideas would be appreciated!

推荐答案

默认使用特定语言不是您应该争取的.假设一位居住在法国并能说流利法语的日本用户将他的电话设置为日语.您的应用程序将默认为德语,尽管它有法语翻译;我想这不是你想要的,当然也不是用户想要的.

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.

既然你不想支持英文但是已经开发了英文的App,那么你可以做的最简单的事情就是在编译后立即去掉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 文件夹,该语言的所有本地化文件都消失了.您可以通过向目标添加一个运行脚本构建阶段来轻松做到这一点,其中包含这一行代码(它是一个 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 App 的非英语默认语言?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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