据我在 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/