docs.unity3d.com
Search Results for

    Show / Hide Table of Contents

    Method CreateStringTableCollection

    CreateStringTableCollection(string, string)

    Creates a StringTableCollection using the project Locales.

    Declaration
    public static StringTableCollection CreateStringTableCollection(string tableName, string assetDirectory)
    Parameters
    Type Name Description
    string tableName

    The name of the new collection. Cannot be blank or whitespace, cannot contain invalid filename characters, and cannot contain "[]".

    string assetDirectory

    The directory to save the generated assets, must be in the project Assets directory.

    Returns
    Type Description
    StringTableCollection

    The created StringTableCollection collection.

    Examples

    This example shows how to create a new StringTableCollection and add some English values.

    var newCollection = LocalizationEditorSettings.CreateStringTableCollection("My Strings", "Assets/String Tables");
    
    var table = newCollection.GetTable("en") as StringTable;
    table.AddEntry("START_MENU", "Start Game");
    table.AddEntry("OPTIONS_MENU", "Options");
    table.AddEntry("EXIT_MENU", "Quit");
    
    // Mark modified assets dirty so changes are saved.
    EditorUtility.SetDirty(table);
    EditorUtility.SetDirty(table.SharedData);

    CreateStringTableCollection(string, string, IList<Locale>)

    Creates a StringTableCollection using the provided Locales.

    Declaration
    public static StringTableCollection CreateStringTableCollection(string tableName, string assetDirectory, IList<Locale> selectedLocales)
    Parameters
    Type Name Description
    string tableName

    The name of the new collection. Cannot be blank or whitespace, cannot contain invalid filename characters, and cannot contain "[]".

    string assetDirectory

    The directory to save the generated assets, must be in the project Assets directory.

    IList<Locale> selectedLocales

    The locales to generate the collection with. A StringTable will be created for each Locale.

    Returns
    Type Description
    StringTableCollection

    The created StringTableCollection collection.

    Examples

    This example shows how to create a new StringTableCollection which contains an English and Japanese StringTable.

    var english = LocalizationEditorSettings.GetLocale("en-GB");
    var japanese = LocalizationEditorSettings.GetLocale(SystemLanguage.Japanese);
    
    // Create a collection with a English (UK) and Japanese table
    var newCollection = LocalizationEditorSettings.CreateStringTableCollection("My Strings", "Assets/String Tables", new List<Locale> { english, japanese });
    
    var table = newCollection.GetTable("en") as StringTable;
    table.AddEntry("START_MENU", "Start Game");
    table.AddEntry("OPTIONS_MENU", "Options");
    table.AddEntry("EXIT_MENU", "Quit");
    In This Article
    Back to top
    Copyright © 2024 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)