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
Assembly: Eco.Shared.dll
public static class XliffFormatter : Object
Fields
Declaration
public static readonly Encoding XliffEncoding
Field Value
| Type |
Description |
| System.Text.Encoding |
|
Methods
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 |
|
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 |
|
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 |
|
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[] |
|