Table of Contents

Class XlfFile

Namespace
SunamoXliffParser
Assembly
SunamoXliffParser.dll

Represents a file element within an XLIFF document.

public class XlfFile
Inheritance
XlfFile
Inherited Members
Extension Methods

Constructors

XlfFile(XElement, XNamespace)

Initializes a new instance of the XlfFile class from an existing XML element.

public XlfFile(XElement node, XNamespace xmlNamespace)

Parameters

node XElement

The XML element representing the file.

xmlNamespace XNamespace

The XML namespace of the XLIFF document.

XlfFile(XElement, XNamespace, string, string, string)

Initializes a new instance of the XlfFile class with specified attribute values.

public XlfFile(XElement node, XNamespace xmlNamespace, string original, string dataType, string sourceLanguage)

Parameters

node XElement

The XML element representing the file.

xmlNamespace XNamespace

The XML namespace of the XLIFF document.

original string

The original file path reference.

dataType string

The data type of the file content.

sourceLanguage string

The source language code.

Properties

DataType

Gets or sets the data type of the file content (e.g., xml, html).

public string DataType { get; }

Property Value

string

Header

Gets the header element of this file, if present.

public XlfHeader? Header { get; }

Property Value

XlfHeader

Optional

Gets the optional attributes of this file element.

public XlfFile.Optionals Optional { get; }

Property Value

XlfFile.Optionals

Original

Gets or sets the original file path reference.

public string Original { get; }

Property Value

string

SourceLang

Gets or sets the source language code.

public string SourceLang { get; }

Property Value

string

TransUnits

Gets all translation units contained in this file element.

public IEnumerable<XlfTransUnit> TransUnits { get; }

Property Value

IEnumerable<XlfTransUnit>

Methods

AddOrUpdateTransUnit(string, string, string, XlfDialect)

Adds a new translation unit or updates an existing one.

public XlfTransUnit AddOrUpdateTransUnit(string id, string source, string target, XlfDialect dialect)

Parameters

id string

The identifier of the translation unit.

source string

The source text.

target string

The target text.

dialect XlfDialect

The XLIFF dialect to use for identifier resolution.

Returns

XlfTransUnit

The added or updated XlfTransUnit.

AddTransUnit(string, string, string, AddMode, XlfDialect)

Adds a translation unit with the specified behavior for existing units.

public XlfTransUnit AddTransUnit(string id, string source, string target, XlfFile.AddMode addMode, XlfDialect dialect)

Parameters

id string

The identifier of the translation unit.

source string

The source text.

target string

The target text.

addMode XlfFile.AddMode

The behavior when a unit with the same identifier already exists.

dialect XlfDialect

The XLIFF dialect to use for identifier resolution.

Returns

XlfTransUnit

The added or existing XlfTransUnit.

Export(string, IXlfExporter, List<string>, List<string>, XlfDialect)

Exports filtered translation units using the specified exporter.

public void Export(string outputFilePath, IXlfExporter exporter, List<string> stateFilter, List<string> resTypeFilter, XlfDialect dialect)

Parameters

outputFilePath string

The path for the exported output file.

exporter IXlfExporter

The exporter implementation to use.

stateFilter List<string>

A list of target states to include, or null/empty to include all.

resTypeFilter List<string>

A list of resource types to include, or null/empty to include all.

dialect XlfDialect

The XLIFF dialect to use during export.

GetTransUnit(string, XlfDialect)

Gets a translation unit by its identifier and dialect.

public XlfTransUnit GetTransUnit(string id, XlfDialect dialect)

Parameters

id string

The identifier of the translation unit.

dialect XlfDialect

The XLIFF dialect to use for identifier resolution.

Returns

XlfTransUnit

The matching XlfTransUnit.

RemoveTransUnit(string, XlfDialect)

Removes a translation unit by its identifier and dialect.

public void RemoveTransUnit(string id, XlfDialect dialect)

Parameters

id string

The identifier of the translation unit to remove.

dialect XlfDialect

The XLIFF dialect to use for identifier resolution.

RemoveTransUnit(string, string)

Removes translation units matching the specified attribute name and value.

public void RemoveTransUnit(string attributeName, string attributeValue)

Parameters

attributeName string

The name of the attribute to match.

attributeValue string

The value of the attribute to match.

TryGetTransUnit(string, XlfDialect, out XlfTransUnit?)

Attempts to get a translation unit by its identifier and dialect.

public bool TryGetTransUnit(string id, XlfDialect dialect, out XlfTransUnit? unit)

Parameters

id string

The identifier of the translation unit.

dialect XlfDialect

The XLIFF dialect to use for identifier resolution.

unit XlfTransUnit

When this method returns, contains the matching translation unit, or null if not found.

Returns

bool

True if the translation unit was found; otherwise, false.