xcode 如何使 iOS 应用程序名称可本地化?

声明:本页面是StackOverFlow热门问题的中英对照翻译,遵循CC BY-SA 4.0协议,如果您需要使用它,必须同样遵循CC BY-SA许可,注明原文地址和作者信息,同时你必须将它归于原作者(不是我):StackOverFlow 原文地址: http://stackoverflow.com/questions/10616650/
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

提示:将鼠标放在中文语句上可以显示对应的英文。显示中英文
时间:2020-09-15 00:21:07  来源:igfitidea点击:

How to make iOS app name localizable?

iphoneiosxcodelocalizationnslocalizedstring

提问by raistlin

I'm trying to find the easiest way to localize my app. I'm using sqlite, so I need basically only to switch my database name. Problem is the app name - can it be localized from code or I have to make x apps for x languages, so anyone will have app name in his/hers native language? The latter one seems like already rejected app to me... anyone?

我正在尝试找到本地化我的应用程序的最简单方法。我正在使用 sqlite,所以我基本上只需要切换我的数据库名称。问题是应用程序名称 - 是否可以从代码本地化,或者我必须为 x 种语言制作 x 个应用程序,所以任何人都会有他/她的母语的应用程序名称?后一个对我来说似乎已经被拒绝的应用程序......有人吗?

回答by Felix Lamouroux

I assume you mean the Bundle Display Name that appears on the device's home screen: You should create a localized file called InfoPlist.stringssimilar to the Localizable.stringsfile that you use for the usual text snippets.

我假设您指的是出现在设备主屏幕上的捆绑显示名称:您应该创建一个本地化文件,其名称InfoPlist.strings类似于Localizable.strings您用于常用文本片段的文件。

In the InfoPlist.stringsyou can localize the different keys from your Info.plist. To localize the app name add:

InfoPlist.stringsInfo.plist 中,您可以本地化不同的键。要本地化应用程序名称,请添加:

"CFBundleDisplayName" = "My localized app name";

To localize a file: Simply create a new strings file in Xcode. Then reveal the right Xcode pane and add localizations via the menu shown here:

本地化文件: 只需在 Xcode 中创建一个新的字符串文件。然后显示右侧的 Xcode 窗格并通过此处显示的菜单添加本地化:

XCode localizations

XCode 本地化

Using this technique you can localize any file you like. Simply add the correct version to your bundle. If you then use [[NSBundle mainBundle] pathFor...you will automatically get the path to the correct localization. We do this for sqlites, strings and sometime even images.

使用这种技术,您可以本地化您喜欢的任何文件。只需将正确的版本添加到您的捆绑包中即可。如果您随后使用,[[NSBundle mainBundle] pathFor...您将自动获得正确本地化的路径。我们为 sqlites、strings 和有时甚至图像执行此操作。