ios - localizable.string 不存在时如何设置默认语言?

标签 ios objective-c localizable.strings

我知道这篇文章似乎重复了....但我已经研究过但没有找到答案...请帮助我。

我有一个应用程序翻译成两种语言(葡萄牙语和英语),我的字符串和 Storyboard是葡萄牙语,例如:

[[self labelTest] setText:NSLocalizedString(@"Essa é uma label", nil)];

我的资源中有文件:en.lproj/Localizable.stringspt.lproj/Localizable.strings

本地化本地开发区域设置为“en”。

我在这里的理解是,如果用户语言是英语,则加载 en.lproj,何时加载葡萄牙语 pt.lproj,何时加载法语或任何其他语言。应该加载 en.lproj,但事实并非如此。如果我在我的设备中设置为西类牙语、法语或任何其他语言,我会看到葡萄牙语,我想显示英语。

这是我看过的帖子,但仍然失败:

iOS App default Language "en" is not applied

AppStore language description and "Localization native development region"

What is the meaning of "Localization native development region" entry in info.plist?

http://useyourloaf.com/blog/2010/05/10/fixing-xcode-default-development-region.html

How can I load a default language plist if the localized version does not exist for the current language?

当找不到用户设备语言的 Localizable.strings 时,我必须做什么才能始终以英语加载语言?

最佳答案

我已经检查了您的链接,其中一个链接中已经报告了这一点,但请确保我想提及这一点。

根据苹果 Property List Key Reference您可以通过 CFBundleDevelopmentRegion 设置默认语言:

CFBundleDevelopmentRegion (String - iOS, OS X)

specifies the native region for the bundle. This key contains a string value that usually corresponds to the native language of the person who wrote the bundle. The language specified by this value is used as the default language if a resource cannot be located for the user’s preferred region or language.

这当然只有在您的语言项目设置正确的情况下才有效。因此,请检查信息 选项卡 中的项目设置 中是否列出了这两种语言,并且您的资源是否已正确复制(Copy Bundle Resources)

关于ios - localizable.string 不存在时如何设置默认语言?,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/24377002/

相关文章:

ios - Realm 迁移 : Why in documentation it is recommended to call the migration block each time without checking the schema version before?

objective-c - 预加载的核心数据数据库不起作用

ios - 我们想在我们自己的服务器上使用 Rocket.chat 而不是 open.rocket.chat 一些我们无法继续的事情

objective-c - 根据 Objective-C 中的属性从数组中删除重复项

ios - Xcode 5 中的本地化

ios - 同一部 iPhone 中的多个 MDM 配置文件

ios - 如何使用 Mac Catalyst 将 iPad 应用程序移植到 Mac 上设置 "Help"菜单选项?

ios - Xcode 删除特定于语言的 Storyboard iOS

ios - iPhone 中设置的其他语言无法读取 Localizable.strings (Base) 文件字符串?

ios - 始终将 slider 归因于零而导致100%失败的算法