Show / Hide Table of Contents

Class XliffFormatter

Serializes XLIFF documents using byte conventions that match translate-toolkit's (Weblate's) output: pretty-printed with 2-space indent, LF line endings, no BOM, and the XML declaration's encoding written as "UTF-8" (uppercase). Without this, every Weblate roundtrip would produce a noisy diff against our generated files even when no content changed.

Inheritance
System.Object
XliffFormatter
Namespace: Eco.Shared.Localization
Assembly: Eco.Shared.dll
Syntax
public static class XliffFormatter : Object

Fields

XliffEncoding

Declaration
public static readonly Encoding XliffEncoding
Field Value
Type Description
System.Text.Encoding

Methods

CreateWriterSettings()

Default settings for our XLIFF output. Returns a fresh instance each call so callers may tweak it.

Declaration
public static XmlWriterSettings CreateWriterSettings()
Returns
Type Description
System.Xml.XmlWriterSettings

Save(XDocument, Stream)

Saves the document to stream using the standard XLIFF byte conventions.

Declaration
public static void Save(XDocument doc, Stream stream)
Parameters
Type Name Description
System.Xml.Linq.XDocument doc
System.IO.Stream stream

Save(XDocument, String)

Saves the document to path using the standard XLIFF byte conventions.

Declaration
public static void Save(XDocument doc, string path)
Parameters
Type Name Description
System.Xml.Linq.XDocument doc
System.String path

ToBytes(XDocument)

Serializes the document to a byte array using the standard XLIFF byte conventions. Useful for idempotent-write callers that want to diff against an existing file's bytes before deciding whether to write.

Declaration
public static byte[] ToBytes(XDocument doc)
Parameters
Type Name Description
System.Xml.Linq.XDocument doc
Returns
Type Description
System.Byte[]
☀
☾
In This Article
Back to top
Copyright (c) Strange Loop Games 2021
☀
☾