Class XliffDocument
Provides the ability to interact with XLIFF files.
Namespace: UnityEditor .Localization.Plugins.XLIFF
Assembly: Unity.Localization.Editor.dll
Syntax
public static class XliffDocument
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
Name | Description |
---|---|
Create(Xliff |
Creates a new XLIFF file with the requested version. |
Parse(Stream) | Converts and XLIFF stream into a parsed document. |