xcode Cocoa/iPhone:如何为我的应用程序创建简体中文本地化版本?

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

Cocoa/iPhone: How do I create a Simplified Chinese localization of my app?

iphonecocoaxcodelocalizationinternationalization

提问by Mike Akers

I'm in the middle of localizing my iPhone app, and I've gotten English, French, German and Japanese localizations working without any problems. Now I'm trying to get a simplified chinese localization working, and no matter what I try, the chinese .lproj bundle just won't be used when I have the phone set to simplified chinese.

我正在本地化我的 iPhone 应用程序,并且我已经获得了英语、法语、德语和日语本地化,没有任何问题。现在我正在尝试使用简体中文本地化,无论我尝试什么,当我将手机设置为简体中文时,都不会使用中文 .lproj 包。

One problem is that I'm not sure what the localization should be called. I've tried "Chinese", zh-Hans, zh-CN, zh_Hans, zh_CN and none of them work. I've even gone as far as digging around inside Remember The Milk's app bundle to see what they used. They're using zh_CN but that doesn't work for me.

一个问题是我不确定本地化应该叫什么。我试过 "Chinese", zh-Hans, zh-CN, zh_Hans, zh_CN 但都没有奏效。我什至深入了解了 Remember The Milk 的应用程序包,看看他们使用了什么。他们正在使用 zh_CN 但这对我不起作用。

Am I missing something obvious here? Do I need to update some plist somewhere? As far as I can see from reading the I18N documentation and looking at the relevant WWDC session video, all I should need to do is make sure I have the right .lproj bundle in my app bundle and I should be good to go... right?

我在这里遗漏了一些明显的东西吗?我需要在某处更新一些 plist 吗?就我阅读 I18N 文档和查看相关 WWDC 会话视频所见,我需要做的就是确保我的应用程序包中有正确的 .lproj 包,我应该很高兴……对?

If you think it would help, I can provide a test xcode project that demonstrates the problem...

如果你认为它会有所帮助,我可以提供一个测试 xcode 项目来演示这个问题......

Thanks

谢谢

回答by digdog

It's zh_CN for Simp. Chinese (简体中文), zh_TW for Trad. Chinese (繁體中文).

Simp 是 zh_CN。中文(简体中文),zh_TW 为繁体。中文(繁体中文)。

If you are testing zh_CN.lprojunder Trad. ChineseLanguage setting, it won't work. Just make sure you are testing your app with correct system language setting. Also, the Localizable.strings should be encoded with UTF-16 encoding.

如果您在Trad下测试zh_CN.lproj 。中文设置,不行。只要确保您正在使用正确的系统语言设置测试您的应用程序。此外,Localizable.strings 应使用 UTF-16 编码进行编码。

Update:
In latest Localization Programming Guide, these had been changed to zh-Hansand zh-Hant.

更新
在最新的本地化编程指南中,这些已更改为zh-Hanszh-Hant

Particularly in Chinese dialects, a region code is not always the best way to specify the proper dialect or script. For example, traditional Chinese (Han) is the default language spoken in Taiwan and is identified by the code zh_TW in Mac OS X v10.3.9 and earlier. However, traditional Chinese is also commonly spoken in Hong Kong and Macao, which means the zh_TW designator is not entirely accurate in those locations. The new standard defines new tags for the traditional Chinese (Hant) and simplified Chinese (Hans) scripts. Thus, traditional Chinese spoken in any country uses the code zh-Hant. Traditional Chinese, as it is spoken in Taiwan, now uses the locale code zh-Hant_TW.

尤其是在汉语方言中,区域代码并不总是指定正确方言或文字的最佳方式。例如,繁体中文 (Han) 是台湾的默认语言,在 Mac OS X v10.3.9 及更早版本中由代码 zh_TW 标识。但是,繁体中文在香港和澳门也很普遍,这意味着 zh_TW 指示符在这些地方并不完全准确。新标准为繁体中文(Hant)和简体中文(Hans)文字定义了新标签。因此,任何国家的繁体中文都使用代码zh-Hant。台湾使用的繁体中文现在使用区域设置代码 zh-Hant_TW。

回答by kslcam

Since iPhone likes to cache resources, you should clean up your app project and re-build it. Then everything will work fine with your localization.

由于 iPhone 喜欢缓存资源,你应该清理你的应用程序项目并重新构建它。然后一切都会与您的本地化正常工作。

回答by Arsalan

when u add localization for any language other than Chinese u named as Arabic,German,e.t.c but for the chinese u have to restrict when naming because there are 2 chinese (simple and tradition) so in iphone localization u must named zh_CN(for simplified chinese) if u placed other name it could not translate so b carefull name must be

当您为中文以外的任何语言添加本地化时,您将其命名为阿拉伯语,德语等,但对于中文,您必须在命名时加以限制,因为有 2 个中文(简单和传统),因此在 iphone 本地化中,您必须命名为 zh_CN(对于简体中文) 如果您放置了其他名称,则无法翻译,因此必须注意名称

zh_CN (for simplified chinese).

zh_CN(简体中文)。

it resolves ur problem
:)

它解决了你的问题
:)

回答by heMac

As digdog said above: "Also, the Localizable.strings should be encoded with UTF-16 encoding."

正如 digdog 上面所说:“此外,Localizable.strings 应该使用 UTF-16 编码。”

I found UTF-8 for Localizable.strings is alright too, I successfully made several language include zh_CN

我发现 Localizable.strings 的 UTF-8 也可以,我成功地制作了几种语言,包括 zh_CN

I was guided by following post: http://www.cocoabuilder.com/archive/cocoa/277415-localization-strings-in-utf16-vs-utf8.html

我受到以下帖子的指导:http: //www.cocoabuilder.com/archive/cocoa/277415-localization-strings-in-utf16-vs-utf8.html