ios - Swift 中的 NSLocalizedString 注释参数

标签 ios xcode swift3 localization

据我在 Apple Developer 网站上阅读 NSLocalizedString 了解:https://developer.apple.com/reference/foundation/nslocalizedstring

NSLocalizedString 初始值设定项中的注释参数应执行以下操作,如 Apple 开发文档“放置在字符串文件中键值对上方的注释”中所述。

所以我假设使用以下代码:

label.text = NSLocalizedString("HELLO_WORLD", comment: "Text for greeting label.")

将更新我的 Localizable.strings 文件中的相应字符串,但所有文件都不会更改,其中的所有内容是:

"HELLO_WORLD"= "你好,世界!";

不确定我是否走上了正确的道路,或者我是否误解了评论论点的目的。

最佳答案

根据 Localizing Your App documentation ,您可以为本地化团队导出本地化。您在 NSLocalizedString 中添加的注释包含在导出的文件中。

导出本地化会创建带有 xliff 扩展名的文件,其中包含类似于以下代码的 XML。

<trans-unit id="Settings">
    <source>Settings</source>
    <target>설정</target>
    <note>Label of the button to Settings screen</note>
</trans-unit>
<trans-unit id="Take Photo">
    <source>Take Photo</source>
    <target>사진 찍기</target>
    <note>No comment provided by engineer.</note>
</trans-unit>
XLIFF 文件可以使用 XLIFFTool 等应用本地化工具进行编辑。

关于ios - Swift 中的 NSLocalizedString 注释参数,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/43998830/

相关文章:

sprite-kit - watchOS 3.0 在 SpriteKit 中检测表冠旋转

android - Appcelerator Titanium 性能

ios - 每当将新 child 添加到我的 firebase 数据库中的节点时,我想向用户发送通知

IOS CallKit 调用识别被拒绝

ios - CGFloat 返回 +Inf

c++ - cmake + xcode : error 'Build setting PRODUCT_NAME undefined'

xcode - 当 .app 在桌面上运行时,NSFileManager 的 currentDirectoryPath 返回根目录

c# - 在 Unity 中创建 iOS 插件

ios - UIButton.isSelected 不能 Observable

ios - CLLocationManager() Location 在模拟器中为 nil