Engine-klasse
LocalizationTable
*Deze inhoud is vertaald met behulp van AI (bèta) en kan fouten bevatten. Klik hier om deze pagina in het Engels te bekijken.
Samenvatting
Eigenschappen
Methoden
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):() |
Codevoorbeelden
LocalisatieTabel
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", -- De 'expressionKey' die gebruikt moet worden met GetString
Values = { -- Een woordenboek van sleutels die overeenkomen met IETF-taal-tags, en hun vertalingen.
["ru"] = " !", -- Russisch
["fr"] = "Bonjour le monde!", -- Frans
["de"] = "Hallo Welt!", -- Duits
["en-US"] = "Hello world!", -- Engels
["it"] = "Ciao mondo!", -- Italiaans
["pt-BR"] = "Ol Mundo!", -- Portugees
["ja"] = "", -- Japans
["es"] = "Hola Mundo!", -- Spaans
},
},
}
local helloWorldTable = createLocalizationTable(entries)
local translatorEnglish = helloWorldTable:GetTranslator("en-US")
print(translatorEnglish:FormatByKey("Hello_World"))API-referentie
Eigenschappen
DevelopmentLanguage
Root
Methoden
GetContents
GetEntries
Teruggaves
Codevoorbeelden
Een LocalizationTable gebruiken
local LocalizationService = game:GetService("LocalizationService")
local localizationTable = LocalizationService:FindFirstChild("LocalizationTable")
local entries = {
{
["Key"] = "0001",
["Source"] = "en-us",
["Values"] = {
["0001"] = "Hallo Muddah, hallo Fadduh.",
["0002"] = "Hier ben ik in Camp Granada.",
["0003"] = "Camp is zeer vermakelijk.",
["0004"] = "En ze zeggen dat we plezier zullen hebben als het stopt met regenen.",
},
},
}
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 door elk sleutel-waarde paar in het woordenboek om onze strings af te drukken
print(value)
end
endGetString
GetTranslator
RemoveEntry
RemoveEntryValue
RemoveKey
RemoveTargetLocale
SetContents
SetEntries
LocalizationTable:SetEntries(entries:Variant):()
Parameters
entries:Variant |
Teruggaves
()
SetEntry
SetEntryContext
SetEntryExample
SetEntryKey
SetEntrySource