Engine Class
LocalizationTable
Summary
Properties
Methods
GetTranslator(localeId: string):Instance |
RemoveEntry(key: string,source: string,context: string):() |
RemoveEntryValue(key: string,source: string,context: string,localeId: string):() |
RemoveTargetLocale(localeId: string):() |
SetContents(contents: string):() |
SetEntries(entries: Variant):() |
SetEntryContext(key: string,source: string,context: string,newContext: string):() |
SetEntryExample(key: string,source: string,context: string,example: string):() |
SetEntryKey(key: string,source: string,context: string,newKey: string):() |
SetEntrySource(key: string,source: string,context: string,newSource: string):() |
Code Samples
LocalizationTable
local LocalizationService = game:GetService("LocalizationService")
local function createLocalizationTable(entries): LocalizationTable
local localTable = Instance.new("LocalizationTable")
localTable.SourceLocaleId = LocalizationService.SystemLocaleId
localTable:SetEntries(entries)
return localTable
end
local entries = {
{
Key = "Hello_World", -- The 'expressionKey' to be used with GetString
Values = { -- A dictionary of keys corresponding to IETF language tags, and their translations.
["ru"] = " !", -- Russian
["fr"] = "Bonjour le monde!", -- French
["de"] = "Hallo Welt!", -- German
["en-US"] = "Hello world!", -- English
["it"] = "Ciao mondo!", -- Italian
["pt-BR"] = "Ol Mundo!", -- Portuguese
["ja"] = "", -- Japanese
["es"] = "Hola Mundo!", -- Spanish
},
},
}
local helloWorldTable = createLocalizationTable(entries)
local translatorEnglish = helloWorldTable:GetTranslator("en-US")
print(translatorEnglish:FormatByKey("Hello_World"))API Reference
Properties
DevelopmentLanguage
Root
Methods
GetContents
GetEntries
Returns
Code Samples
Using a LocalizationTable
local LocalizationService = game:GetService("LocalizationService")
local localizationTable = LocalizationService:FindFirstChild("LocalizationTable")
local entries = {
{
["Key"] = "0001",
["Source"] = "en-us",
["Values"] = {
["0001"] = "Hello Muddah, hello Fadduh.",
["0002"] = "Here I am at Camp Granada.",
["0003"] = "Camp is very entertaining.",
["0004"] = "And they say we'll have some fun if it stops raining.",
},
},
}
localizationTable:SetEntries(entries)
local get_results = localizationTable:GetEntries()
for _index, dict in pairs(get_results) do
for _key, value in pairs(dict["Values"]) do -- Loop through every key, value pair in the dictionary to print our strings
print(value)
end
endGetString
GetTranslator
RemoveEntry
RemoveEntryValue
RemoveKey
RemoveTargetLocale
SetContents
SetEntries
LocalizationTable:SetEntries(entries:Variant):()
Parameters
entries:Variant |
Returns
()
SetEntry
SetEntryContext
SetEntryExample
SetEntryKey
SetEntrySource