iOS开发总结(A0)- Localization

 Localization 可分为三类:

1)对 storyboard 及xib 进行 localization

2)对代码中的 NSString 进行 localization

3) app 名称的localizaiton

首先在xcode,project的info中增加localizations的语言

一、storyboard(及xib)的localization

1) 在storyboard 的file inspector 中,启用localizaiton的语言,系统将自动生成storyboard各语言的 strings文件

2)在strings文件对storyboard中的NSString 进行本地化(翻译)

二、代码中NSString的localization(以下仅是其中一种方法)

1)在m文件中 #define localizedstring,如下:

#define SomeLocalizedString  NSLocalizedStringFromTable(@"key", @"strings file name", @"comment")

2) 定义完所有localized strings 后,生成strings file,

- 在terminal中进入项目文件夹

- 输入 genstrings *.m,系统将生成所有本地化语言的strings file ,其中包含了之前定义的localized strings

- 将strings file 拖动到xcode 中,并编辑(翻译)

三、app名称的localization

1)新建strings文件,名称为InfoPlist.strings,并file inspector 中启用各localization语言,在每个localization strings file 中添加内容如下:

"CFBundleDisplayName" = "localized app name";

其他:

对launchscreen 进行localization无效, 因此launchscreen 内容应避免需要localization的NSString

原文地址:https://www.cnblogs.com/beddup/p/4612628.html