Class Xliff
XML Localisation Interchange File Format. The purpose of XLIFF is to store localizable data and carry it from one step of the localization process to the other, while allowing interoperability between and among tools.
Namespace: UnityEditor.Localization.Plugins.XLIFF
Syntax
public static class Xliff
Methods
AddTableToDocument(IXliffDocument, StringTable, StringTable)
Populate the document with the entries from target
using source
as the source reference.
Note: The source and target tables must be part of the same collection, they must both use the same SharedTableData.
Declaration
public static void AddTableToDocument(IXliffDocument document, StringTable source, StringTable target)
Parameters
Type | Name | Description |
---|---|---|
IXliffDocument | document | The XLIFF document to add the entries to. |
StringTable | source | |
StringTable | target |
CreateDocument(LocaleIdentifier, LocaleIdentifier, XliffVersion)
Creates an empty XLIFF document ready for populating.
Declaration
public static IXliffDocument CreateDocument(LocaleIdentifier source, LocaleIdentifier target, XliffVersion version)
Parameters
Type | Name | Description |
---|---|---|
LocaleIdentifier | source | The source language. The language used when populating Source. |
LocaleIdentifier | target | The target language. The language used when populating Target. |
XliffVersion | version | The XLIFF file version. |
Returns
Type | Description |
---|---|
IXliffDocument |
Export(LocaleIdentifier, String, String, XliffVersion, ICollection<StringTableCollection>, ITaskReporter)
Exports all StringTable in collections
as 1 or more XLIFF files where each file represents a single language.
Declaration
public static void Export(LocaleIdentifier source, string directory, string name, XliffVersion version, ICollection<StringTableCollection> collections, ITaskReporter reporter = null)
Parameters
Type | Name | Description |
---|---|---|
LocaleIdentifier | source | This is the language that will be used as the source language for all generated XLIFF files. |
String | directory | The directory to output the generated XLIFF files. |
String | name | The default name for all generated XLIFF files. Files will be saved with the full name "[name]_[Language Code].xlf" |
XliffVersion | version | The XLIFF version to generate the files in. |
ICollection<StringTableCollection> | collections | 1 or more StringTableCollection. The collections will be combines into language groups where each file represents a single |
ITaskReporter | reporter | Optional reporter which can report the current progress. |
Export(StringTable, String, XliffVersion, ICollection<StringTable>, ITaskReporter)
Export the values in tables
using sourceLanguage
as the source language to one or more XLIFF files.
Declaration
public static void Export(StringTable sourceLanguage, string directory, XliffVersion version, ICollection<StringTable> tables, ITaskReporter reporter = null)
Parameters
Type | Name | Description |
---|---|---|
StringTable | sourceLanguage | This is the table that will be used as the source language for all generated XLIFF files. |
String | directory | The directory where all generated XLIFF files will be saved to. |
XliffVersion | version | The XLIFF version to generate the files in. |
ICollection<StringTable> | tables | 1 or more StringTable that will be used as the target language for each XLIFF file. 1 XLIFF file will be generated for each table. |
ITaskReporter | reporter | Optional reporter which can report the current progress. |
ImportDirectory(String, Xliff.ImportOptions, ITaskReporter)
Imports all XLIFF files with the extensions xlf or xliff into existing StringTableCollection or new ones if a matching one could not be found.
Declaration
public static void ImportDirectory(string directory, Xliff.ImportOptions importOptions = null, ITaskReporter reporter = null)
Parameters
Type | Name | Description |
---|---|---|
String | directory | The directory to search. Searches sub directories as well. |
Xliff.ImportOptions | importOptions | Optional import options which can be used to configure the importing behavior. |
ITaskReporter | reporter | Optional reporter which can report the current progress. |
ImportDocument(IXliffDocument, Xliff.ImportOptions, ITaskReporter)
Imports a single XLIFF document into the project. Attempts to find matching StringTableCollection's, if one could not be found then a new one is created.
Declaration
public static void ImportDocument(IXliffDocument document, Xliff.ImportOptions importOptions = null, ITaskReporter reporter = null)
Parameters
Type | Name | Description |
---|---|---|
IXliffDocument | document | The root XLIFF document. |
Xliff.ImportOptions | importOptions | Optional import options which can be used to configure the importing behavior. |
ITaskReporter | reporter | Optional reporter which can report the current progress. |
ImportDocumentIntoTable(IXliffDocument, StringTable, Xliff.ImportNotesBehavior, ITaskReporter)
Import an XLIFF document into the target table, ignoring TargetLanguage.
Declaration
public static void ImportDocumentIntoTable(IXliffDocument document, StringTable target, Xliff.ImportNotesBehavior importNotesBehavior = Xliff.ImportNotesBehavior.Replace, ITaskReporter reporter = null)
Parameters
Type | Name | Description |
---|---|---|
IXliffDocument | document | The XLIFF document to import. |
StringTable | target | The target table that will be populated with the translated values. |
Xliff.ImportNotesBehavior | importNotesBehavior | How should the notes be imported? |
ITaskReporter | reporter | Optional reporter which can report the current progress. |
ImportFile(String, Xliff.ImportOptions, ITaskReporter)
Imports a single XLIFF file into the project. Attempts to find matching StringTableCollection's, if one could not be found then a new one is created.
Declaration
public static void ImportFile(string file, Xliff.ImportOptions importOptions = null, ITaskReporter reporter = null)
Parameters
Type | Name | Description |
---|---|---|
String | file | The XLIFF file. |
Xliff.ImportOptions | importOptions | Optional import options which can be used to configure the importing behavior. |
ITaskReporter | reporter | Optional reporter which can report the current progress. |
ImportFileIntoCollection(StringTableCollection, String, Xliff.ImportOptions, ITaskReporter)
Import the XLIFF file into the collection.
Declaration
public static void ImportFileIntoCollection(StringTableCollection collection, string file, Xliff.ImportOptions importOptions = null, ITaskReporter reporter = null)
Parameters
Type | Name | Description |
---|---|---|
StringTableCollection | collection | The collection to import all the XLIFF data into. |
String | file | The XLIFF file path. |
Xliff.ImportOptions | importOptions | Optional import options which can be used to configure the importing behavior. |
ITaskReporter | reporter | Optional reporter which can report the current progress. |
ImportFileIntoTable(String, StringTable, Xliff.ImportNotesBehavior, ITaskReporter)
Import an XLIFF file into the target table, ignoring TargetLanguage.
Declaration
public static void ImportFileIntoTable(string file, StringTable target, Xliff.ImportNotesBehavior importNotesBehavior = Xliff.ImportNotesBehavior.Replace, ITaskReporter reporter = null)
Parameters
Type | Name | Description |
---|---|---|
String | file | The XLIFF file path. |
StringTable | target | The target table that will be populated with the translated values. |
Xliff.ImportNotesBehavior | importNotesBehavior | How should the notes be imported? |
ITaskReporter | reporter | Optional reporter which can report the current progress. |