#i18n #localization #translation #xliff #multi-language

xliff

Library for reading and writing localized text stored in XLIFF format

8 releases

new 0.3.0-alpha.4 Sep 11, 2020
0.3.0-alpha.3 Sep 9, 2020
0.3.0-alpha.2 Jul 25, 2020
0.2.0 Jul 21, 2019
0.1.1 Jul 21, 2019

#29 in Internationalization (i18n)

Download history 21/week @ 2020-05-27 9/week @ 2020-06-03 3/week @ 2020-06-10 3/week @ 2020-06-17 3/week @ 2020-06-24 37/week @ 2020-07-01 7/week @ 2020-07-08 11/week @ 2020-07-15 23/week @ 2020-07-22 8/week @ 2020-07-29 6/week @ 2020-08-05 19/week @ 2020-08-12 9/week @ 2020-08-19 6/week @ 2020-08-26 18/week @ 2020-09-02 32/week @ 2020-09-09

53 downloads per month

Apache-2.0

36KB
612 lines

XLIFF Parser

Build Status

This is a library for reading and writing localized text stored in XLIFF format.

Docs

⚠ This is work in progress - check below for the current status of the implementation.

Examples

Reading XLIFF file


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..."
);

Reading XLIFF string


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");

Changelog

Version history

Parse XLIFF 1.2

Spec

Implementation status

.

  • <xliff>
    • <file>
      • <header>
        • <skl>
          • <internal-file> | <external-file>
        • <phase-group>
          • <phase>
          • note
        • <glossary>
          • <internal-file> | <external-file>
        • <reference>
          • <internal-file> | <external-file>
        • <count-group>
          • <count>
        • <tool>
        • <prop-group>
          • <prop>
        • <note>
      • <body>
        • <group>
          • <context-group>
            • <context>
          • <count-group>
            • <count>
          • <prop-group>
            • <prop>
          • <note>
        • <trans-unit>
          • <source>
          • <target>
          • <context-group>
            • <context>
          • <count-group>
            • <count>
          • <prop-group>
            • <prop>
          • <seg-srouce>
          • <note>
          • <alt-trans>
        • <bin-unit>
          • <bin-source>
          • <bin-target>
          • <context-group>
            • <context>
          • <count-group>
            • <count>
          • <prop-group>
            • <prop>
      • <note>
      • <trans-unit>

Acknowledgements

  • Depends on quick-xml

  • The names "OASIS" and "XLIFF" are trademarks of OASIS, the owner and developer of the XLIFF specification.

Dependencies

~5.5MB
~171K SLoC