docs.unity3d.com
Search Results for

    Show / Hide Table of Contents

    Class XliffDocument

    Provides the ability to interact with XLIFF files.

    Inheritance
    object
    XliffDocument
    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(XliffVersion)

    Creates a new XLIFF file with the requested version.

    Parse(Stream)

    Converts and XLIFF stream into a parsed document.

    In This Article
    Back to top
    Copyright © 2025 Unity Technologies — Trademarks and terms of use
    • Legal
    • Privacy Policy
    • Cookie Policy
    • Do Not Sell or Share My Personal Information
    • Your Privacy Choices (Cookie Settings)