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
nodeXElementThe XML element representing the file.
xmlNamespaceXNamespaceThe 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
nodeXElementThe XML element representing the file.
xmlNamespaceXNamespaceThe XML namespace of the XLIFF document.
originalstringThe original file path reference.
dataTypestringThe data type of the file content.
sourceLanguagestringThe 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
Header
Gets the header element of this file, if present.
public XlfHeader? Header { get; }
Property Value
Optional
Gets the optional attributes of this file element.
public XlfFile.Optionals Optional { get; }
Property Value
Original
Gets or sets the original file path reference.
public string Original { get; }
Property Value
SourceLang
Gets or sets the source language code.
public string SourceLang { get; }
Property Value
TransUnits
Gets all translation units contained in this file element.
public IEnumerable<XlfTransUnit> TransUnits { get; }
Property Value
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
idstringThe identifier of the translation unit.
sourcestringThe source text.
targetstringThe target text.
dialectXlfDialectThe 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
idstringThe identifier of the translation unit.
sourcestringThe source text.
targetstringThe target text.
addModeXlfFile.AddModeThe behavior when a unit with the same identifier already exists.
dialectXlfDialectThe 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
outputFilePathstringThe path for the exported output file.
exporterIXlfExporterThe exporter implementation to use.
stateFilterList<string>A list of target states to include, or null/empty to include all.
resTypeFilterList<string>A list of resource types to include, or null/empty to include all.
dialectXlfDialectThe 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
idstringThe identifier of the translation unit.
dialectXlfDialectThe 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
idstringThe identifier of the translation unit to remove.
dialectXlfDialectThe 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
attributeNamestringThe name of the attribute to match.
attributeValuestringThe 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
idstringThe identifier of the translation unit.
dialectXlfDialectThe XLIFF dialect to use for identifier resolution.
unitXlfTransUnitWhen this method returns, contains the matching translation unit, or null if not found.
Returns
- bool
True if the translation unit was found; otherwise, false.