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
filePathstringThe 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
DocumentType
Gets the runtime type of XlfDocument.
public static Type DocumentType { get; }
Property Value
FileName
Gets the file name of the loaded XLIFF document.
public string? FileName { get; }
Property Value
Files
Gets all file elements contained in this XLIFF document.
public IEnumerable<XlfFile> Files { get; }
Property Value
Version
Gets or sets the XLIFF version of this document.
public string Version { get; set; }
Property Value
Methods
AddFile(string, string, string)
Adds a new file element to this XLIFF document.
public XlfFile AddFile(string original, string dataType, string sourceLanguage)
Parameters
originalstringThe original file path reference.
dataTypestringThe data type of the file content (e.g., "xml", "html").
sourceLanguagestringThe source language code.
Returns
LoadXml(byte[])
Loads XLIFF content from the specified byte array.
public void LoadXml(byte[] xmlBytes)
Parameters
xmlBytesbyte[]The byte array containing the XML content.
LoadXml(string)
Loads XLIFF content from the specified XML string.
public void LoadXml(string xml)
Parameters
xmlstringThe XML string to load.
RemoveFile(string)
Removes a file element with the specified original attribute value.
public void RemoveFile(string original)
Parameters
originalstringThe 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
filePathstringThe 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
filePathstringThe output file path for the ResX file.
optionsXlfDocument.ResXSaveOptionOptions 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
sourceFilePathstringThe path to the source ResX file.
updatedResourceStateStringstringThe state string to assign to updated items.
addedResourceStateStringstringThe 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
updatedResourceStateStringstringThe state string to assign to updated items.
addedResourceStateStringstringThe state string to assign to added items.
Returns
- UpdateResult
An UpdateResult containing the identifiers of added, removed, and updated items.