我曾经使用NSLocalizedString
自定义功能。
例如,要访问Profile.strings
,我定义了这个函数:
func LocalizedProfile(key: String, comment: String?) {
NSLocalizedString(key, tableName: "Profile", comment: comment ?? "")
}
并且,这样调用:
let localized = LocalizedProfile("Submit", comment: "For registration")
除了导出 XLIFF 之外,此方法工作正常。
在 Xcode 6.3.2 上,执行Export for localization
会抛出错误:
为了获取错误信息,我通过命令行执行:
xcodebuild -exportLocalizations -localizationPath ./xliff -project MyApp.xcodeproj -exportLanguage ja
而且,我收到了这个错误:
Bad entry in file /Users/mono/Documents/Git/MyApp/Localization.swift (line = 29): Argument is not a literal string.
定义自定义本地化方法对我非常有用,但我也想使用导出 XLIFF 功能。
有什么方法可以解决这个需求吗?