Table of Contents

Class XlfDocument

Namespace
SunamoXliffParser
Assembly
SunamoXliffParser.dll

Represents an XLIFF document and provides methods for reading, modifying, and exporting translation data.

public class XlfDocument
Inheritance
XlfDocument
Inherited Members
Extension Methods

Constructors

XlfDocument()

Initializes a new instance of the XlfDocument class without loading any file. Call LoadXml(string) to load XML content.

public XlfDocument()

XlfDocument(string)

Initializes a new instance of the XlfDocument class from the specified file. If the file name is null, LoadXml(string) must be called before using the document.

public XlfDocument(string filePath)

Parameters

filePath string

The path to the XLIFF file to load, or null to create an unloaded document.

Properties

Dialect

Gets or sets the XLIFF dialect used by this document.

public XlfDialect Dialect { get; set; }

Property Value

XlfDialect

DocumentType

Gets the runtime type of XlfDocument.

public static Type DocumentType { get; }

Property Value

Type

FileName

Gets the file name of the loaded XLIFF document.

public string? FileName { get; }

Property Value

string

Files

Gets all file elements contained in this XLIFF document.

public IEnumerable<XlfFile> Files { get; }

Property Value

IEnumerable<XlfFile>

Version

Gets or sets the XLIFF version of this document.

public string Version { get; set; }

Property Value

string

Methods

AddFile(string, string, string)

Adds a new file element to this XLIFF document.

public XlfFile AddFile(string original, string dataType, string sourceLanguage)

Parameters

original string

The original file path reference.

dataType string

The data type of the file content (e.g., "xml", "html").

sourceLanguage string

The source language code.

Returns

XlfFile

The newly created XlfFile instance.

LoadXml(byte[])

Loads XLIFF content from the specified byte array.

public void LoadXml(byte[] xmlBytes)

Parameters

xmlBytes byte[]

The byte array containing the XML content.

LoadXml(string)

Loads XLIFF content from the specified XML string.

public void LoadXml(string xml)

Parameters

xml string

The XML string to load.

RemoveFile(string)

Removes a file element with the specified original attribute value.

public void RemoveFile(string original)

Parameters

original string

The original attribute value identifying the file to remove.

Save()

Saves the document to the file specified by FileName.

public void Save()

SaveAsResX(string)

Saves this XLIFF document as a ResX file without any special options.

public void SaveAsResX(string filePath)

Parameters

filePath string

The output file path for the ResX file.

SaveAsResX(string, ResXSaveOption)

Saves this XLIFF document as a ResX file with the specified options.

public void SaveAsResX(string filePath, XlfDocument.ResXSaveOption options)

Parameters

filePath string

The output file path for the ResX file.

options XlfDocument.ResXSaveOption

Options controlling the save behavior.

Update(string, string, string)

Updates the XLIFF data from the provided ResX source file.

public UpdateResult Update(string sourceFilePath, string updatedResourceStateString, string addedResourceStateString)

Parameters

sourceFilePath string

The path to the source ResX file.

updatedResourceStateString string

The state string to assign to updated items.

addedResourceStateString string

The state string to assign to added items.

Returns

UpdateResult

An UpdateResult containing the identifiers of added, removed, and updated items.

UpdateFromSource()

Updates translation data from the associated source file using default state strings based on the XLIFF version.

public UpdateResult UpdateFromSource()

Returns

UpdateResult

An UpdateResult containing the identifiers of added, removed, and updated items.

UpdateFromSource(string, string)

Updates translation data from the associated source file using the specified state strings.

public UpdateResult UpdateFromSource(string updatedResourceStateString, string addedResourceStateString)

Parameters

updatedResourceStateString string

The state string to assign to updated items.

addedResourceStateString string

The state string to assign to added items.

Returns

UpdateResult

An UpdateResult containing the identifiers of added, removed, and updated items.