# 401-Localizing with Xcode 9
主要讲两大点
- Internationalization
- Xcode Localization Workflow
# Internationalization
# Strings Management
- Prepare your strings for translation
- Use NSLocalizedString to load strings in codde
- Use localizedStringWithFormat to get a localized formatted string
for example
let format = NSLocalizedString("%d popular languages", comment: "Number of popular languages")
label.text = String.localizedStringWithFormat(format, count)
1
2
2
Static analyzer, 静态分析代码中是否存在没有本地化的字符串
在 Build Setting 中设置
Miss Localizability = YES
Miss Localization Context Comment = YES
# Formatting
for example
let formatter = DateFormatter()
formatter.dateStyle = .full
let str = formatter.string(from: date)
1
2
3
2
3
# User Interfase
!
# Xcode Localization Workflow
# XLIFF
XML格式的文件,可以导入/导出,XliffReader
# Stringsdict
Xcode 9 新增特性,支持
- Plurals
- Adaptive Strings