Show raw api
{
"functions": [
{
"name": "new",
"desc": "Constructs a new JSONTranslator from the given args.\n\n```\nlocal translator = JSONTranslator.new(\"MyTranslator\", en\", {\n\tactions = {\n\t\trespawn = \"Respawn {playerName}\";\n\t};\n})\n\nprint(translator:FormatByKey(\"actions.respawn\"), { playerName = \"Quenty\"}) --> Respawn Quenty\n\n-- Observing is preferred\nmaid:GiveTask(translator:ObserveFormatByKey(\"actions.respawn\", {\n\tplayerName = RxInstanceUtils.observeProperty(player, \"DisplayName\");\n}):Subscribe(function(text)\n\tprint(text) --> \"Respawn Quenty\"\nend)\n```\n\n```lua\nlocal translator = JSONTranslator.new(script)\n-- assume there is an `en.json` underneath the script with valid JSON.\n```",
"params": [
{
"name": "translatorName",
"desc": "Name of the translator. Used for source.",
"lua_type": "string"
},
{
"name": "localeId",
"desc": "",
"lua_type": "string"
},
{
"name": "dataTable",
"desc": "",
"lua_type": "table"
}
],
"returns": [
{
"desc": "",
"lua_type": "JSONTranslator"
}
],
"function_type": "static",
"source": {
"line": 84,
"path": "src/clienttranslator/src/Shared/JSONTranslator.lua"
}
},
{
"name": "ObserveFormatByKey",
"desc": "Observes the translated value",
"params": [
{
"name": "self",
"desc": "",
"lua_type": "JSONTranslator"
},
{
"name": "translationKey",
"desc": "",
"lua_type": "string"
},
{
"name": "translationArgs",
"desc": "May have observables (or convertable to observables) in it.",
"lua_type": "table?"
}
],
"returns": [
{
"desc": "",
"lua_type": "Observable<string>"
}
],
"function_type": "static",
"source": {
"line": 173,
"path": "src/clienttranslator/src/Shared/JSONTranslator.lua"
}
},
{
"name": "PromiseFormatByKey",
"desc": "Formats the resulting entry by args.\n\n:::tip\nYou should use [JSONTranslator.ObserveFormatByKey] instead of this to respond\nto locale changing.\n:::",
"params": [
{
"name": "self",
"desc": "",
"lua_type": "JSONTranslator"
},
{
"name": "translationKey",
"desc": "",
"lua_type": "string"
},
{
"name": "args",
"desc": "",
"lua_type": "table?"
}
],
"returns": [
{
"desc": "",
"lua_type": "Promise<string>"
}
],
"function_type": "static",
"source": {
"line": 241,
"path": "src/clienttranslator/src/Shared/JSONTranslator.lua"
}
},
{
"name": "PromiseTranslator",
"desc": "Returns a promise that will resolve once the Roblox translator is loaded from the cloud.",
"params": [
{
"name": "self",
"desc": "",
"lua_type": "JSONTranslator"
}
],
"returns": [
{
"desc": "",
"lua_type": "Promise<Translator>"
}
],
"function_type": "static",
"source": {
"line": 255,
"path": "src/clienttranslator/src/Shared/JSONTranslator.lua"
}
},
{
"name": "ObserveTranslator",
"desc": "Observes the current Roblox translator for this translator.",
"params": [
{
"name": "self",
"desc": "",
"lua_type": "JSONTranslator"
}
],
"returns": [
{
"desc": "",
"lua_type": "Observable<Translator>"
}
],
"function_type": "static",
"source": {
"line": 264,
"path": "src/clienttranslator/src/Shared/JSONTranslator.lua"
}
},
{
"name": "ObserveLocaleId",
"desc": "Observes the current locale id for this translator.",
"params": [
{
"name": "self",
"desc": "",
"lua_type": "JSONTranslator"
}
],
"returns": [
{
"desc": "",
"lua_type": "Observable<string>"
}
],
"function_type": "static",
"source": {
"line": 273,
"path": "src/clienttranslator/src/Shared/JSONTranslator.lua"
}
},
{
"name": "SetEntryValue",
"desc": "Adds an entry value to the localization table itself. This can be useful\nfor ensuring pseudo localization and/or generating localization values\nfrom the game data itself.",
"params": [
{
"name": "self",
"desc": "",
"lua_type": "JSONTranslator"
},
{
"name": "translationKey",
"desc": "",
"lua_type": "string"
},
{
"name": "source",
"desc": "",
"lua_type": "string"
},
{
"name": "context",
"desc": "",
"lua_type": "string"
},
{
"name": "localeId",
"desc": "",
"lua_type": "string"
},
{
"name": "text",
"desc": "",
"lua_type": "string"
}
],
"returns": [],
"function_type": "static",
"source": {
"line": 288,
"path": "src/clienttranslator/src/Shared/JSONTranslator.lua"
}
},
{
"name": "ObserveTranslation",
"desc": "Observes a translation key and formats it with the given args.",
"params": [
{
"name": "self",
"desc": "",
"lua_type": "JSONTranslator"
},
{
"name": "prefix",
"desc": "",
"lua_type": "string"
},
{
"name": "text",
"desc": "",
"lua_type": "string"
},
{
"name": "translationArgs",
"desc": "",
"lua_type": "table?"
}
],
"returns": [
{
"desc": "",
"lua_type": "Observable<string>"
}
],
"function_type": "static",
"source": {
"line": 323,
"path": "src/clienttranslator/src/Shared/JSONTranslator.lua"
}
},
{
"name": "ToTranslationKey",
"desc": "Converts the given prefix and text into a translation key.",
"params": [
{
"name": "self",
"desc": "",
"lua_type": "JSONTranslator"
},
{
"name": "prefix",
"desc": "",
"lua_type": "string"
},
{
"name": "text",
"desc": "",
"lua_type": "string"
}
],
"returns": [
{
"desc": "",
"lua_type": "string"
}
],
"function_type": "static",
"source": {
"line": 342,
"path": "src/clienttranslator/src/Shared/JSONTranslator.lua"
}
},
{
"name": "GetLocaleId",
"desc": "Gets the current localeId of the translator if it's initialized, or a default if it is not.",
"params": [
{
"name": "self",
"desc": "",
"lua_type": "JSONTranslator"
}
],
"returns": [
{
"desc": "",
"lua_type": "string"
}
],
"function_type": "static",
"source": {
"line": 360,
"path": "src/clienttranslator/src/Shared/JSONTranslator.lua"
}
},
{
"name": "GetLocalizationTable",
"desc": "Gets the localization table the translation is using.",
"params": [
{
"name": "self",
"desc": "",
"lua_type": "JSONTranslator"
}
],
"returns": [
{
"desc": "",
"lua_type": "LocalizationTable"
}
],
"function_type": "static",
"source": {
"line": 369,
"path": "src/clienttranslator/src/Shared/JSONTranslator.lua"
}
},
{
"name": "PromiseLoaded",
"desc": "Returns a promise that will resolve once the translator is loaded from the cloud.",
"params": [
{
"name": "self",
"desc": "",
"lua_type": "JSONTranslator"
}
],
"returns": [
{
"desc": "",
"lua_type": "Promise"
}
],
"function_type": "static",
"source": {
"line": 377,
"path": "src/clienttranslator/src/Shared/JSONTranslator.lua"
}
},
{
"name": "FormatByKey",
"desc": "Formats or errors if the cloud translations are not loaded.\n\n:::tip\nYou should use [JSONTranslator.ObserveFormatByKey] instead of this to respond\nto locale changing.\n:::",
"params": [
{
"name": "self",
"desc": "",
"lua_type": "JSONTranslator"
},
{
"name": "translationKey",
"desc": "",
"lua_type": "string"
},
{
"name": "args",
"desc": "",
"lua_type": "table?"
}
],
"returns": [
{
"desc": "",
"lua_type": "string"
}
],
"function_type": "static",
"source": {
"line": 393,
"path": "src/clienttranslator/src/Shared/JSONTranslator.lua"
}
},
{
"name": "Destroy",
"desc": "Cleans up the translator and deletes the localization table if it exists.\nShould be called by [ServiceBag]",
"params": [
{
"name": "self",
"desc": "",
"lua_type": "JSONTranslator"
}
],
"returns": [],
"function_type": "static",
"source": {
"line": 473,
"path": "src/clienttranslator/src/Shared/JSONTranslator.lua"
}
}
],
"properties": [],
"types": [],
"name": "JSONTranslator",
"desc": "Utility function that loads a translator from a folder or a table.\n\nTo get translations uploaded.\n\n1. Run the game\n2. On the client, check LocalizationService.GeneratedJSONTable\n3. Right click > Save as CSV\n4. Stop the game\n5. In Studio, go to plugins > \"Localization Tools\"\n6. Upload the CSV (update)",
"source": {
"line": 16,
"path": "src/clienttranslator/src/Shared/JSONTranslator.lua"
}
}