Skip to main content

LocalizationEntryParserUtils

Utility to build a localization table from json, intended to be used with rojo. Can also handle Rojo json objects turned into tables!

Functions

getAvailableLocales

LocalizationEntryParserUtils.getAvailableLocales(folderInstance) → {[string]true}

Returns the set of locales available in a folder, inferred from the names of its StringValue/ModuleScript descendants (e.g. an en.json StringValue -> "en").

decodeLocaleFromInstance

LocalizationEntryParserUtils.decodeLocaleFromInstance(
tableNamestring,
sourceLocaleIdstring,
localeIdstring,--

the locale to decode

folderInstance,
lookupTable{[string]LocalizationEntry}--

accumulated across locales

) → {LocalizationEntry}--

entries that now have a value for localeId

Decodes only the descendants matching a single locale into the given lookup table, so a locale's JSON is not decoded until it is actually needed. The lookup table is shared across calls, so decoding a non-source locale after the source locale merges its values onto the existing entries (preserving their Source/Context).

Show raw api
{
    "functions": [
        {
            "name": "getAvailableLocales",
            "desc": "Returns the set of locales available in a folder, inferred from the names of its\nStringValue/ModuleScript descendants (e.g. an `en.json` StringValue -> \"en\").",
            "params": [
                {
                    "name": "folder",
                    "desc": "",
                    "lua_type": "Instance"
                }
            ],
            "returns": [
                {
                    "desc": "",
                    "lua_type": "{ [string]: true }"
                }
            ],
            "function_type": "static",
            "source": {
                "line": 79,
                "path": "src/clienttranslator/src/Shared/Conversion/LocalizationEntryParserUtils.lua"
            }
        },
        {
            "name": "decodeLocaleFromInstance",
            "desc": "Decodes only the descendants matching a single locale into the given lookup table,\nso a locale's JSON is not decoded until it is actually needed. The lookup table is\nshared across calls, so decoding a non-source locale after the source locale merges\nits values onto the existing entries (preserving their Source/Context).",
            "params": [
                {
                    "name": "tableName",
                    "desc": "",
                    "lua_type": "string"
                },
                {
                    "name": "sourceLocaleId",
                    "desc": "",
                    "lua_type": "string"
                },
                {
                    "name": "localeId",
                    "desc": "the locale to decode",
                    "lua_type": "string"
                },
                {
                    "name": "folder",
                    "desc": "",
                    "lua_type": "Instance"
                },
                {
                    "name": "lookupTable",
                    "desc": "accumulated across locales",
                    "lua_type": "{ [string]: LocalizationEntry }"
                }
            ],
            "returns": [
                {
                    "desc": "entries that now have a value for localeId",
                    "lua_type": "{ LocalizationEntry }"
                }
            ],
            "function_type": "static",
            "source": {
                "line": 104,
                "path": "src/clienttranslator/src/Shared/Conversion/LocalizationEntryParserUtils.lua"
            }
        }
    ],
    "properties": [],
    "types": [],
    "name": "LocalizationEntryParserUtils",
    "desc": "Utility to build a localization table from json, intended to be used with rojo. Can also handle Rojo json\nobjects turned into tables!",
    "source": {
        "line": 8,
        "path": "src/clienttranslator/src/Shared/Conversion/LocalizationEntryParserUtils.lua"
    }
}