xcode 在 iPhone 应用程序中使用 Localizable.strings

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

Using Localizable.strings in iPhone application

iphonexcodelocalizationthree20

提问by bobo

I downloaded the three20 library:

我下载了three20库:

http://three20.info/

http://three20.info/

And I opened the TTCatalog sample project that comes with this library:

我打开了这个库附带的 TTCatalog 示例项目:

http://img16.imageshack.us/img16/3183/screenshot20100302at752.png

http://img16.imageshack.us/img16/3183/screenshot20100302at752.png

As you can see, there are lots of Localizable.strings files.

如您所见,有很多 Localizable.strings 文件。

When I opened the iPhone simulator and changed its language to for example French in the settings, the text on the button still remains in English:

当我打开 iPhone 模拟器并在设置中将其语言更改为法语时,按钮上的文本仍然是英语:

http://img69.imageshack.us/img69/9775/screenshot20100302at812.png

http://img69.imageshack.us/img69/9775/screenshot20100302at812.png

I already checked that there is definitely a corresponding entry for the text "See All" in the Localization.strings of French.

我已经检查过,在法语的 Localization.strings 中肯定有一个对应的文本“查看全部”的条目。

Why and what are the steps to make it use the Localizable.strings files?

为什么以及使用 Localizable.strings 文件的步骤是什么?

(This sample project does not come with any nib/xib file)

(此示例项目不附带任何 nib/xib 文件)

EDIT:

编辑:

After adding the following XML in Info.plist:

在 Info.plist 中添加以下 XML 后:

...
<dict>
...
    <key>CFBundleLocalizations</key>
    <array>
    <string>de</string>
    <string>en</string>
    <string>es</string>
    <string>fr</string>
    <string>it</string>
    <string>ja</string>
    <string>zh_cn</string>
    <string>zh_tw</string>  
    </array>
</dict>
...

It works now!

它现在有效!

回答by Guillaume

Does this thread help http://groups.google.com/group/three20/browse_thread/thread/bee3d5525a32d476?

此线程对http://groups.google.com/group/three20/browse_thread/thread/bee3d5525a32d476有帮助吗?

Quoted text, in case the link becomes unavailable:

引用文本,以防链接不可用:

For localizations inside bundles to work, your app has to have some localized resources itself, because the available localizations are determined by looking at the once available in the main bundle. Alternatively, you can add the available localizations as a setting in your Info.plist, with the key 'CFBundleLocalizations'. Note that the value of this key has to be an array, something the Info.plist editor of XCode does not support, you edit the file 'by hand' to get the localizations in there. If you only need one localization, you can simple set the key 'CFBundleDevelopmentRegion' to the value of your choice.

要使包内的本地化工作,您的应用程序本身必须有一些本地化资源,因为可用的本地化是通过查看主包中曾经可用的资源来确定的。或者,您可以使用“CFBundleLocalizations”键将可用的本地化添加为 Info.plist 中的设置。请注意,此键的值必须是一个数组,XCode 的 Info.plist 编辑器不支持该值,您可以“手动”编辑文件以获取其中的本地化信息。如果您只需要一种本地化,您可以简单地将键 'CFBundleDevelopmentRegion' 设置为您选择的值。