8 个版本
0.3.0-alpha.4 | 2020 年 9 月 11 日 |
---|---|
0.3.0-alpha.3 | 2020 年 9 月 9 日 |
0.3.0-alpha.2 | 2020 年 7 月 25 日 |
0.2.0 | 2019 年 7 月 21 日 |
0.1.1 | 2019 年 7 月 21 日 |
在 国际化(i18n) 中排名 #143
37KB
612 行(不含注释)
XLIFF 解析器
这是一个用于读取和写入存储在 XLIFF 格式中的本地化文本的库。
⚠ 这项工作正在进行中 - 请查看以下实施状态的当前状态。
示例
读取 XLIFF 文件
let path: PathBuf = [env!("CARGO_MANIFEST_DIR"), "tests", "simplev1_2.xliff"]
.iter()
.collect();
let translations = T::load(&path);
let translation = translations.t(None, "Some text");
assert_eq!(
translation.source_text().unwrap(),
"Some text"
);
assert_eq!(
translation.target_text().unwrap(),
"je précise quelque chose de très..."
);
读取 XLIFF 字符串
let xliff_string = r#"<?xml version="1.0" encoding="UTF-8"?>
<xliff xmlns="urn:oasis:names:tc:xliff:document:1.2" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" version="1.2" xsi:schemaLocation="urn:oasis:names:tc:xliff:document:1.2 http://docs.oasis-open.org/xliff/v1.2/os/xliff-core-1.2-strict.xsd">
<file original="HelloWidgets/en.lproj/InfoPlist.strings" source-language="en" target-language="en" datatype="plaintext">
<header>
<tool tool-id="com.apple.dt.xcode" tool-name="Xcode" tool-version="12.0" build-num="12A6159"/>
</header>
<body>
<trans-unit id="CFBundleName" xml:space="preserve">
<source>HelloWidgets</source>
<target>HelloWidgets Translated</target>
<note>Bundle name</note>
</trans-unit>
</body>
</file>
</xliff>"#;
let translations = T::load_str(xliff_string);
let translation = translations.t(None, "CFBundleName");
变更日志
解析 XLIFF 1.2
实现状态
.
-
<xliff>
-
<文件>
-
<头>
-
<skl>
-
<内部-文件> | <外部-文件>
-
-
<阶段组>
-
<阶段>
-
备注
-
-
<术语表>
-
<内部-文件> | <外部-文件>
-
-
<参考>
-
<内部-文件> | <外部-文件>
-
-
<计数组>
-
<计数>
-
-
<工具>
-
<属性组>
-
<属性>
-
-
<备注>
-
-
<主体>
-
<组>
-
<上下文组>
-
<上下文>
-
-
<计数组>
-
<计数>
-
-
<属性组>
-
<属性>
-
-
<备注>
-
-
<翻译单元>
-
<源>
-
<目标>
-
<上下文组>
-
<上下文>
-
-
<计数组>
-
<计数>
-
-
<属性组>
-
<属性>
-
-
<段源>
-
<备注>
-
<备选翻译>
-
-
<二进制单元>
-
<二进制源>
-
<二进制目标>
-
<上下文组>
-
<上下文>
-
-
<计数组>
-
<计数>
-
-
<属性组>
-
<属性>
-
-
-
-
<备注>
-
<翻译单元>
-
-
致谢
依赖项
~1.5MB
~27K 行代码(估算额外代码行数)