如下: <resources xmlns:xliff="urn:oasis:names:tc:xliff:document:1.2"> <string name="buy_kindle">我想买%s台< xliff:g id="Kindle">Kindle</xliff:g></string> 注意使用该标签时,先在资源之前加上命名空间: xmlns:xliff=”urn:oasis:names:tc: xliff:document:1.2”。 :g id="Kindle">Kindle</xliff:g></item> <item quantity="other">我想买几台<xliff:g id="Kindle">Kindle :g id="Kindle">Kindle<$100></xliff:g></item> 其中“<”的ASCII是<,“>”的是>。
image.png 3、打开Localized Contents文件夹里的.xliff文件进行翻译 ? image.png 如果你是用MAC来翻译,有一些工具可以帮助你编辑xliff文件,如果你想用iPhone或者iPad来编辑这个文件,就可以用我开发的XliffTool了。 ? 选择翻译好的语言对应的xliff文件导入就好,现在国际化就完成了。 5、其他问题 1、 如果我后面加了很多字段怎么办? 如果storyboard增加了很多元素怎么办? 一样导入导出xliff,不会丢。 4、导出的其他文件干嘛的? 导出的storyboard文件是给对方翻译的时候可以对照界面翻译用的,当然需要mac下安装xcode。 理论上只用管xliff文件就好。 总结 以上的步骤可以总结为 添加语言类型 -> 导出xliff -> 翻译 -> 导入xliff 对,就这么简单,你的国际化就做好了。
:g id="LEVEL">%1$s</xliff:g>)"</string> 2.5.1.2 getUnderFifteenString 为充电时,当预估时间小于15分钟,则提示剩余电池续航时间不到15 :g id="THRESHOLD">%1$s</xliff:g>"</string> private static String getUnderFifteenString(Context :g id="TIME_REMAINING">%1$s</xliff:g>"</string> private static String getMoreThanTwoDaysString( :g id="TIME_REMAINING">%1$s</xliff:g>"</string> <string name="power_remaining_duration_only" msgid ="6123167166221295462">"大约还可使用 <xliff:g id="TIME_REMAINING">%1$s</xliff:g>"</string> private static
要标记不应翻译的文本,请使用 <xliff:g> 占位符标记。 以下是其他一些占位符标记的示例: <resources xmlns:xliff="urn:oasis:names:tc:xliff:document:1.2"> <! :g id="star">\u2605</xliff:g> </string> <! ">Game Group</xliff:g> </string> <! id="promotion_code">ABCDEFG</xliff:g>” to get a discount.
row.map(field => `"${field}"`).join(',')).join('\n'); } toXliffFormat(data, locale) { let xliff > <xliff version="1.2" xmlns="urn:oasis:names:tc:xliff:document:1.2"> <file original="" source-language this.walkTranslations(translations, (key, value) => { if (typeof value === 'string') { xliff <target>${this.escapeXml(value)}</target> </trans-unit>`; } }); } xliff += ` </body> </file> </xliff>`; return xliff; } escapeXml(unsafe) { return unsafe.replace
example":"5:00 am", "value":"%s" } ] } ] } 方式二:添加<xliff :g></xliff:g>标记对。 "string":[ { "name":"message_arrive", "value":"We will arrive at <xliff :g id='time' example='5:00 am'>%s</xliff:g>" } ] } boolean.json示例 { "boolean":[
sourceEntries, filePath): if (not path.exists(filePath)): return ET.register_namespace('xliff ',"urn:oasis:names:tc:xliff:document:1.2") tree = ET.ElementTree(file=filePath) root = tree.getroot
四. string.xml占位符 开发中经常遇到这样的情况 , 在string.xml中用到以下占位符 <string name="delete_success">删除<xliff:g id=" name">%1$s</xliff:g>成功</string> <string name="upload_success">%1$s上传到%2$s成功</string> 1.xliff:g标签 http
部署过程:https://www.jianshu.com/p/f3cd7dfd48d1 Weblate 支持多种翻译格式,我选择把 md 文件改换成 xliff 再上传。 之后又发现 Xliff 要把 md 文件里的 "<>&" 这些符号替换成占位符。好麻烦,还不如直接用 json 格式。
manifest> res/xml/nfc_tech_filter.xml: XML/HTML代码 <resourcesxmlns:xliffresourcesxmlns:xliff ="urn:oasis:names:tc:xliff:document:1.2"> <tech-list> <tech>android.nfc.tech.MifareClassic</tech>
-name "*.md" -print0 | xargs -0 -I M extract M M.zh_Hans.xliff M.zh_Hans.skl en-US zh_Hans 参考 ---- Quick
<resources xmlns:xliff="urn:oasis:names:tc:xliff:document:1.2"> <tech-list> <tech>android.nfc.tech.IsoDep 下面演示了一个标签匹配支持NfcA and Ndef 技术 或者 可被支持 NfcB and Ndef 技术: <resources xmlns:xliff="urn:oasis:names:tc:xliff android.nfc.tech.NfcA</tech> <tech>android.nfc.tech.Ndef</tech> </tech-list> </resources> <resources xmlns:xliff ="urn:oasis:names:tc:xliff:document:1.2"> <tech-list> <tech>android.nfc.tech.NfcB</tech>
<resources xmlns:xliff="urn:oasis:names:tc:xliff:document:1.2"> <tech-list> <tech>android.nfc.tech.IsoDep 下面演示了一个标签匹配支持NfcA and Ndef 技术 或者 可被支持 NfcB and Ndef 技术: <resources xmlns:xliff="urn:oasis:names:tc:xliff android.nfc.tech.NfcA</tech> <tech>android.nfc.tech.Ndef</tech> </tech-list> </resources> <resources xmlns:xliff ="urn:oasis:names:tc:xliff:document:1.2"> <tech-list> <tech>android.nfc.tech.NfcB</tech> <tech>android.nfc.tech.Ndef
application/vnd.ms-excel', 674 '.xld': 'application/vnd.ms-excel', 675 '.xlf': 'application/x-xliff ', 676 '.xliff': 'application/x-xliff', 677 '.xll': 'application/vnd.ms-excel', 678
application/vnd.ms-excel', 674 '.xld': 'application/vnd.ms-excel', 675 '.xlf': 'application/x-xliff ', 676 '.xliff': 'application/x-xliff', 677 '.xll': 'application/vnd.ms-excel', 678
> <xliff version="1.2" xmlns="urn:oasis:names:tc:xliff:document:1.2"> <file source-language="en" datatype context-type="linenumber">3</context> </context-group> </trans-unit> </body> </file> </xliff > <xliff xmlns="urn:oasis:names:tc:xliff:document:1.2" version="1.2"> <file original="ng2.template" /source> <target xml:lang="ru">Картотека</target> </trans-unit> </body> </file> </xliff
<resources xmlns:xliff="urn:oasis:names:tc:xliff:document:1.2"> + <!