Skip to main content

LocalizedTextUtils

Localized text utils which changes translationKey structures to shared locations

Types

TranslationArgs

type TranslationArgs = {[string]LocalizedTextData | number | string}

Valid translation args

LocalizedTextData

interface LocalizedTextData {
translationKeystring
translationArgsTranslationArgs
}

Valid localized text data

Functions

create

LocalizedTextUtils.create(
translationKeystring,
translationArgsTranslationArgs
) → LocalizedTextData

Creates a new localizedtextdata

isLocalizedText

LocalizedTextUtils.isLocalizedText(dataany) → boolean

Returns whether the given argument is localized text

formatByKeyRecursive

LocalizedTextUtils.formatByKeyRecursive(
translatorTranslator | JSONTranslator,
translationKeystring,
translationArgsTranslationArgs?,
extraArgstable?
) → string

Recursively formats the translated text.

observeFormatByKeyRecursive

LocalizedTextUtils.observeFormatByKeyRecursive(
translatorTranslator | JSONTranslator,
translationKeystring,
translationArgsTranslationArgs?,
extraArgstable?
) → Observable<string>

Observes the recursively formatted translated text.

observeLocalizedTextToString

LocalizedTextUtils.observeLocalizedTextToString(
translatorTranslator | JSONTranslator,
localizedTextLocalizedTextData,
extraArgstable?
) → Observable<string>

Observes the translations by string recursively

localizedTextToString

LocalizedTextUtils.localizedTextToString(
translatorTranslator | JSONTranslator,
localizedTextLocalizedTextData,
extraArgstable?
) → string

Recursively formats the translated text

tip

Use LocalizedTextUtils.observeLocalizedTextToString(translator, localizedText, extraArgs)

fromJSON

LocalizedTextUtils.fromJSON(textstring) → LocalizedTextData?

Converts from JSON

toJSON

LocalizedTextUtils.toJSON(localizedTextLocalizedTextData) → string?

Converts to JSON

setFromAttribute

LocalizedTextUtils.setFromAttribute(
objInstance,
attributeNamestring,
translationKeystring,
translationArgsTranslationArgs
) → LocalizedTextData

Sets the translation data as an attribute on an instance.

getFromAttribute

LocalizedTextUtils.getFromAttribute(
objInstance,
attributeNamestring
) → LocalizedTextData

Reads the data from the attribute

getTranslationFromAttribute

LocalizedTextUtils.getTranslationFromAttribute(
translatorTranslator | JSONTranslator,
objInstance,
attributeNamestring,
extraArgstable?
) → string?

Gets the translation from a given object's attribute

initializeAttribute

LocalizedTextUtils.initializeAttribute(
objInstance,
attributeNamestring,
defaultTranslationKeystring,
defaultTranslationArgstable?
) → ()

Ensures an attribute is defined if nothing is there

observeTranslation

LocalizedTextUtils.observeTranslation(
translatorTranslator | JSONTranslator,
objInstance,
attributeNamestring,
extraArgstable?
) → Observable<string?>

Returns the translated string from the given object

Show raw api
{
    "functions": [
        {
            "name": "create",
            "desc": "Creates a new localizedtextdata",
            "params": [
                {
                    "name": "translationKey",
                    "desc": "",
                    "lua_type": "string"
                },
                {
                    "name": "translationArgs",
                    "desc": "",
                    "lua_type": "TranslationArgs"
                }
            ],
            "returns": [
                {
                    "desc": "",
                    "lua_type": "LocalizedTextData"
                }
            ],
            "function_type": "static",
            "source": {
                "line": 35,
                "path": "src/localizedtextutils/src/Shared/LocalizedTextUtils.lua"
            }
        },
        {
            "name": "isLocalizedText",
            "desc": "Returns whether the given argument is localized text",
            "params": [
                {
                    "name": "data",
                    "desc": "",
                    "lua_type": "any"
                }
            ],
            "returns": [
                {
                    "desc": "",
                    "lua_type": "boolean"
                }
            ],
            "function_type": "static",
            "source": {
                "line": 50,
                "path": "src/localizedtextutils/src/Shared/LocalizedTextUtils.lua"
            }
        },
        {
            "name": "formatByKeyRecursive",
            "desc": "Recursively formats the translated text.",
            "params": [
                {
                    "name": "translator",
                    "desc": "",
                    "lua_type": "Translator | JSONTranslator"
                },
                {
                    "name": "translationKey",
                    "desc": "",
                    "lua_type": "string"
                },
                {
                    "name": "translationArgs",
                    "desc": "",
                    "lua_type": "TranslationArgs?"
                },
                {
                    "name": "extraArgs",
                    "desc": "",
                    "lua_type": "table?"
                }
            ],
            "returns": [
                {
                    "desc": "",
                    "lua_type": "string"
                }
            ],
            "function_type": "static",
            "source": {
                "line": 65,
                "path": "src/localizedtextutils/src/Shared/LocalizedTextUtils.lua"
            }
        },
        {
            "name": "observeFormatByKeyRecursive",
            "desc": "Observes the recursively formatted translated text.",
            "params": [
                {
                    "name": "translator",
                    "desc": "",
                    "lua_type": "Translator | JSONTranslator"
                },
                {
                    "name": "translationKey",
                    "desc": "",
                    "lua_type": "string"
                },
                {
                    "name": "translationArgs",
                    "desc": "",
                    "lua_type": "TranslationArgs?"
                },
                {
                    "name": "extraArgs",
                    "desc": "",
                    "lua_type": "table?"
                }
            ],
            "returns": [
                {
                    "desc": "",
                    "lua_type": "Observable<string>"
                }
            ],
            "function_type": "static",
            "source": {
                "line": 106,
                "path": "src/localizedtextutils/src/Shared/LocalizedTextUtils.lua"
            }
        },
        {
            "name": "observeLocalizedTextToString",
            "desc": "Observes the translations by string recursively",
            "params": [
                {
                    "name": "translator",
                    "desc": "",
                    "lua_type": "Translator | JSONTranslator"
                },
                {
                    "name": "localizedText",
                    "desc": "",
                    "lua_type": "LocalizedTextData"
                },
                {
                    "name": "extraArgs",
                    "desc": "",
                    "lua_type": "table?"
                }
            ],
            "returns": [
                {
                    "desc": "",
                    "lua_type": "Observable<string>"
                }
            ],
            "function_type": "static",
            "source": {
                "line": 146,
                "path": "src/localizedtextutils/src/Shared/LocalizedTextUtils.lua"
            }
        },
        {
            "name": "localizedTextToString",
            "desc": "Recursively formats the translated text\n\n:::tip\nUse LocalizedTextUtils.observeLocalizedTextToString(translator, localizedText, extraArgs)\n:::",
            "params": [
                {
                    "name": "translator",
                    "desc": "",
                    "lua_type": "Translator | JSONTranslator"
                },
                {
                    "name": "localizedText",
                    "desc": "",
                    "lua_type": "LocalizedTextData"
                },
                {
                    "name": "extraArgs",
                    "desc": "",
                    "lua_type": "table?"
                }
            ],
            "returns": [
                {
                    "desc": "",
                    "lua_type": "string"
                }
            ],
            "function_type": "static",
            "source": {
                "line": 169,
                "path": "src/localizedtextutils/src/Shared/LocalizedTextUtils.lua"
            }
        },
        {
            "name": "fromJSON",
            "desc": "Converts from JSON",
            "params": [
                {
                    "name": "text",
                    "desc": "",
                    "lua_type": "string"
                }
            ],
            "returns": [
                {
                    "desc": "",
                    "lua_type": "LocalizedTextData?"
                }
            ],
            "function_type": "static",
            "source": {
                "line": 185,
                "path": "src/localizedtextutils/src/Shared/LocalizedTextUtils.lua"
            }
        },
        {
            "name": "toJSON",
            "desc": "Converts to JSON",
            "params": [
                {
                    "name": "localizedText",
                    "desc": "",
                    "lua_type": "LocalizedTextData"
                }
            ],
            "returns": [
                {
                    "desc": "",
                    "lua_type": "string?"
                }
            ],
            "function_type": "static",
            "source": {
                "line": 204,
                "path": "src/localizedtextutils/src/Shared/LocalizedTextUtils.lua"
            }
        },
        {
            "name": "setFromAttribute",
            "desc": "Sets the translation data as an attribute on an instance.",
            "params": [
                {
                    "name": "obj",
                    "desc": "",
                    "lua_type": "Instance"
                },
                {
                    "name": "attributeName",
                    "desc": "",
                    "lua_type": "string"
                },
                {
                    "name": "translationKey",
                    "desc": "",
                    "lua_type": "string"
                },
                {
                    "name": "translationArgs",
                    "desc": "",
                    "lua_type": "TranslationArgs"
                }
            ],
            "returns": [
                {
                    "desc": "",
                    "lua_type": "LocalizedTextData"
                }
            ],
            "function_type": "static",
            "source": {
                "line": 219,
                "path": "src/localizedtextutils/src/Shared/LocalizedTextUtils.lua"
            }
        },
        {
            "name": "getFromAttribute",
            "desc": "Reads the data from the attribute",
            "params": [
                {
                    "name": "obj",
                    "desc": "",
                    "lua_type": "Instance"
                },
                {
                    "name": "attributeName",
                    "desc": "",
                    "lua_type": "string"
                }
            ],
            "returns": [
                {
                    "desc": "",
                    "lua_type": "LocalizedTextData"
                }
            ],
            "function_type": "static",
            "source": {
                "line": 233,
                "path": "src/localizedtextutils/src/Shared/LocalizedTextUtils.lua"
            }
        },
        {
            "name": "getTranslationFromAttribute",
            "desc": "Gets the translation from a given object's attribute",
            "params": [
                {
                    "name": "translator",
                    "desc": "",
                    "lua_type": "Translator | JSONTranslator"
                },
                {
                    "name": "obj",
                    "desc": "",
                    "lua_type": "Instance"
                },
                {
                    "name": "attributeName",
                    "desc": "",
                    "lua_type": "string"
                },
                {
                    "name": "extraArgs",
                    "desc": "",
                    "lua_type": "table?"
                }
            ],
            "returns": [
                {
                    "desc": "",
                    "lua_type": "string?"
                }
            ],
            "function_type": "static",
            "source": {
                "line": 253,
                "path": "src/localizedtextutils/src/Shared/LocalizedTextUtils.lua"
            }
        },
        {
            "name": "initializeAttribute",
            "desc": "Ensures an attribute is defined if nothing is there",
            "params": [
                {
                    "name": "obj",
                    "desc": "",
                    "lua_type": "Instance"
                },
                {
                    "name": "attributeName",
                    "desc": "",
                    "lua_type": "string"
                },
                {
                    "name": "defaultTranslationKey",
                    "desc": "",
                    "lua_type": "string"
                },
                {
                    "name": "defaultTranslationArgs",
                    "desc": "",
                    "lua_type": "table?"
                }
            ],
            "returns": [],
            "function_type": "static",
            "source": {
                "line": 273,
                "path": "src/localizedtextutils/src/Shared/LocalizedTextUtils.lua"
            }
        },
        {
            "name": "observeTranslation",
            "desc": "Returns the translated string from the given object",
            "params": [
                {
                    "name": "translator",
                    "desc": "",
                    "lua_type": "Translator | JSONTranslator"
                },
                {
                    "name": "obj",
                    "desc": "",
                    "lua_type": "Instance"
                },
                {
                    "name": "attributeName",
                    "desc": "",
                    "lua_type": "string"
                },
                {
                    "name": "extraArgs",
                    "desc": "",
                    "lua_type": "table?"
                }
            ],
            "returns": [
                {
                    "desc": "",
                    "lua_type": "Observable<string?>"
                }
            ],
            "function_type": "static",
            "source": {
                "line": 294,
                "path": "src/localizedtextutils/src/Shared/LocalizedTextUtils.lua"
            }
        }
    ],
    "properties": [],
    "types": [
        {
            "name": "TranslationArgs",
            "desc": "Valid translation args",
            "lua_type": "{ [string]: LocalizedTextData | number | string }",
            "source": {
                "line": 20,
                "path": "src/localizedtextutils/src/Shared/LocalizedTextUtils.lua"
            }
        },
        {
            "name": "LocalizedTextData",
            "desc": "Valid localized text data",
            "fields": [
                {
                    "name": "translationKey",
                    "lua_type": "string",
                    "desc": ""
                },
                {
                    "name": "translationArgs",
                    "lua_type": "TranslationArgs",
                    "desc": ""
                }
            ],
            "source": {
                "line": 28,
                "path": "src/localizedtextutils/src/Shared/LocalizedTextUtils.lua"
            }
        }
    ],
    "name": "LocalizedTextUtils",
    "desc": "Localized text utils which changes translationKey structures to shared locations",
    "source": {
        "line": 5,
        "path": "src/localizedtextutils/src/Shared/LocalizedTextUtils.lua"
    }
}