XliffTranslation

loreline.translation.XliffTranslation (Class)

Converts XLIFF (1.2 or 2.x) file content into a Loreline translation file body.

XLIFF 1.2 layout:

<xliff version="1.2">
  <file source-language="en" target-language="fr">
    <body>
      <trans-unit id="intro">
        <source>Welcome to the cafe.</source>
        <target>Bienvenue dans le café.</target>
      </trans-unit>
    </body>
  </file>
</xliff>

XLIFF 2.x layout:

<xliff version="2.0" srcLang="en" trgLang="fr">
  <file id="...">
    <unit id="intro">
      <segment>
        <source>Welcome to the cafe.</source>
        <target>Bienvenue dans le café.</target>
      </segment>
    </unit>
  </file>
</xliff>

Locale filter:

  • 1.2: only <file target-language="<locale>"> is converted
  • 2.x: the root <xliff trgLang="<locale>"> must match
  • If no target-language attribute is present anywhere, we take everything (the file is assumed to be in the requested locale).

Empty/missing <target> -> entry skipped.

<target> must be valid Loreline body content. Its text is written verbatim into the synthesised .lor and re-parsed by Loreline. See the full rules in loreline.translation.TranslationFormats.

Static Members

toLoreline(content: String, locale: String): String
Name Type
content String
locale String
Returns
String

fromScript(script: loreline.AstNode, existing: Null<Map>, locale: String): String

Generates an XLIFF 1.2 file body for the given source script and locale. If existing is provided, entries already present there are preserved as the <target> value; otherwise the <target> defaults to the source text (placeholder).

Name Type
script loreline.AstNode
existing Null<Map>
locale String
Returns
String

Private Members

localeMatches(fileLocale: String, requested: String): Bool

Matches the file's target-language against the requested locale. Accepts an exact match OR a primary-language match (e.g. file "fr-FR" matches request "fr", and vice versa).

Name Type
fileLocale String
requested String
Returns
Bool

primarySubtag(s: String): String
Name Type
s String
Returns
String

firstChildElement(parent: Xml, name: String): Xml
Name Type
parent Xml
name String
Returns
Xml

innerText(node: Xml): String
Name Type
node Xml
Returns
String

escapeForXmlText(s: String): String
Name Type
s String
Returns
String

escapeForXmlAttr(s: String): String
Name Type
s String
Returns
String

writeEntry(buf: loreline.Utf8Buf, id: String, src: String, tgt: String): Void
Name Type
buf loreline.Utf8Buf
id String
src String
tgt String

escapeLineForComment(s: String): String
Name Type
s String
Returns
String