Skip to main content

InstanceLocaleLoader

Owns the lazy per-locale loading state for an instance-decoded JSONTranslator (a folder of per-locale JSON StringValues / ModuleScripts): which locales are available, which have already been loaded, and the accumulated entry lookup.

Decodes and writes a locale's entries to the TranslatorService only the first time that locale is needed. The service is resolved from the ServiceBag passed to the constructor, so callers never have to thread a writer through each load call.

Functions

new

InstanceLocaleLoader.new(
serviceBagServiceBag,--

provides the TranslatorService writes land on

translatorNamestring,
sourceLocaleIdstring,--

always loaded, the fallback for every key

folderInstance--

holds the per-locale StringValue/ModuleScript children

) → InstanceLocaleLoader

LoadSourceLocale

InstanceLocaleLoader.LoadSourceLocale(selfInstanceLocaleLoader) → ()

Loads the source locale. Always call this first -- it establishes the Source/Context that other locales' values merge onto, and it is the ultimate fallback for every key.

LoadAllLocales

InstanceLocaleLoader.LoadAllLocales(selfInstanceLocaleLoader) → ()

Loads every available locale file. Used off the client, where there is no single target locale to narrow to.

LoadLocale

InstanceLocaleLoader.LoadLocale(
localeIdstring--

the target locale

) → ()

Loads every available locale file that shares the target's language (e.g. for "es-mx": both es and es-mx; for "fr-fr": every fr-* file), so a regional player gets the universal-language strings and same-language siblings as fallbacks before dropping to the source. The source locale is ensured first. Idempotent -- a file already loaded is never decoded or written again -- and returns nothing, since the caller does not (and should not) care which files it touched.

Show raw api
{
    "functions": [
        {
            "name": "new",
            "desc": "",
            "params": [
                {
                    "name": "serviceBag",
                    "desc": "provides the [TranslatorService] writes land on",
                    "lua_type": "ServiceBag"
                },
                {
                    "name": "translatorName",
                    "desc": "",
                    "lua_type": "string"
                },
                {
                    "name": "sourceLocaleId",
                    "desc": "always loaded, the fallback for every key",
                    "lua_type": "string"
                },
                {
                    "name": "folder",
                    "desc": "holds the per-locale StringValue/ModuleScript children",
                    "lua_type": "Instance"
                }
            ],
            "returns": [
                {
                    "desc": "",
                    "lua_type": "InstanceLocaleLoader"
                }
            ],
            "function_type": "static",
            "source": {
                "line": 45,
                "path": "src/clienttranslator/src/Shared/Loaders/InstanceLocaleLoader.lua"
            }
        },
        {
            "name": "LoadSourceLocale",
            "desc": "Loads the source locale. Always call this first -- it establishes the Source/Context\nthat other locales' values merge onto, and it is the ultimate fallback for every key.",
            "params": [
                {
                    "name": "self",
                    "desc": "",
                    "lua_type": "InstanceLocaleLoader"
                }
            ],
            "returns": [],
            "function_type": "static",
            "source": {
                "line": 73,
                "path": "src/clienttranslator/src/Shared/Loaders/InstanceLocaleLoader.lua"
            }
        },
        {
            "name": "LoadAllLocales",
            "desc": "Loads every available locale file. Used off the client, where there is no single\ntarget locale to narrow to.",
            "params": [
                {
                    "name": "self",
                    "desc": "",
                    "lua_type": "InstanceLocaleLoader"
                }
            ],
            "returns": [],
            "function_type": "static",
            "source": {
                "line": 81,
                "path": "src/clienttranslator/src/Shared/Loaders/InstanceLocaleLoader.lua"
            }
        },
        {
            "name": "LoadLocale",
            "desc": "Loads every available locale file that shares the target's language (e.g. for \"es-mx\":\nboth `es` and `es-mx`; for \"fr-fr\": every `fr-*` file), so a regional player gets the\nuniversal-language strings and same-language siblings as fallbacks before dropping to\nthe source. The source locale is ensured first. Idempotent -- a file already loaded is\nnever decoded or written again -- and returns nothing, since the caller does not (and\nshould not) care which files it touched.",
            "params": [
                {
                    "name": "self",
                    "desc": "",
                    "lua_type": "InstanceLocaleLoader"
                },
                {
                    "name": "localeId",
                    "desc": "the target locale",
                    "lua_type": "string"
                }
            ],
            "returns": [],
            "function_type": "static",
            "source": {
                "line": 98,
                "path": "src/clienttranslator/src/Shared/Loaders/InstanceLocaleLoader.lua"
            }
        }
    ],
    "properties": [],
    "types": [],
    "name": "InstanceLocaleLoader",
    "desc": "Owns the lazy per-locale loading state for an instance-decoded [JSONTranslator]\n(a folder of per-locale JSON StringValues / ModuleScripts): which locales are\navailable, which have already been loaded, and the accumulated entry lookup.\n\nDecodes and writes a locale's entries to the [TranslatorService] only the first time\nthat locale is needed. The service is resolved from the [ServiceBag] passed to the\nconstructor, so callers never have to thread a writer through each load call.",
    "source": {
        "line": 13,
        "path": "src/clienttranslator/src/Shared/Loaders/InstanceLocaleLoader.lua"
    }
}