docs.unity3d.com
    Show / Hide Table of Contents

    Class XliffDocument

    Provides the ability to interact with XLIFF files.

    Inheritance
    Object
    XliffDocument
    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.

    In This Article
    • Methods
      • Create(XliffVersion)
      • Parse(Stream)
    Back to top
    Terms of use
    Copyright © 2023 Unity Technologies — Terms of use
    • Legal
    • Privacy Policy
    • Cookies
    • Do Not Sell or Share My Personal Information
    • Your Privacy Choices (Cookie Settings)
    "Unity", Unity logos, and other Unity trademarks are trademarks or registered trademarks of Unity Technologies or its affiliates in the U.S. and elsewhere (more info here). Other names or brands are trademarks of their respective owners.
    Generated by DocFX on 18 October 2023