Class XliffDocument
Provides the ability to interact with XLIFF files.
Namespace: UnityEditor.Localization.Plugins.XLIFF
Syntax
public static class XliffDocument : object
Examples
This shows how to create an XLIFF document, populate it with values to translate, and then write it to file.
var document = XliffDocument.Create(XliffVersion.V20);
// The lnaguage to translate from.
document.SourceLanguage = "en";
// The language to translate into.
document.TargetLanguage = "fr";
var file = document.AddNewFile();
file.Id = "file id";
var group = file.AddNewGroup();
var start = group.AddNewTranslationUnit();
start.Id = "12345";
start.Name = "START";
start.Source = "Start Game";
var quit = group.AddNewTranslationUnit();
quit.Id = "12346";
quit.Name = "QUIT";
quit.Source = "Quit Game";
using (var stream = new FileStream("Exported XLIFF.xliff", FileMode.Create, FileAccess.Write))
{
document.Serialize(stream);
}
Methods
Create(XliffVersion)
Creates a new XLIFF file with the requested version.
Declaration
public static IXliffDocument Create(XliffVersion version)
Parameters
Type | Name | Description |
---|---|---|
XliffVersion | version | The XLIFF version to target. |
Returns
Type | Description |
---|---|
IXliffDocument | The new XLIFF file. |
Parse(Stream)
Converts and XLIFF stream into a parsed document.
Declaration
public static IXliffDocument Parse(Stream stream)
Parameters
Type | Name | Description |
---|---|---|
Stream | stream | The XLIFF stream. |
Returns
Type | Description |
---|---|
IXliffDocument | The parsed XLIFF document. |