Engine-Klasse
LocalizationTable
*Dieser Inhalt wurde mit KI (Beta) übersetzt und kann Fehler enthalten. Um diese Seite auf Englisch zu sehen, klicke hier.
Zusammenfassung
Eigenschaften
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):() |
Code-Beispiele
Lokalisierungstabelle
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", -- Der 'expressionKey', der mit GetString verwendet wird
Values = { -- Ein Wörterbuch mit Schlüsseln, die den IETF-Sprache-Tags und ihren Übersetzungen entsprechen.
["ru"] = " !", -- Russisch
["fr"] = "Bonjour le monde!", -- Französisch
["de"] = "Hallo Welt!", -- Deutsch
["en-US"] = "Hello world!", -- Englisch
["it"] = "Ciao mondo!", -- Italienisch
["pt-BR"] = "Ol Mundo!", -- Portugiesisch
["ja"] = "", -- Japanisch
["es"] = "Hola Mundo!", -- Spanisch
},
},
}
local helloWorldTable = createLocalizationTable(entries)
local translatorEnglish = helloWorldTable:GetTranslator("en-US")
print(translatorEnglish:FormatByKey("Hello_World"))API-Referenz
Eigenschaften
DevelopmentLanguage
Root
Methoden
GetContents
GetEntries
Rückgaben
Code-Beispiele
Verwendung einer LocalizationTable
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 bin ich im Camp Granada.",
["0003"] = "Das Camp ist sehr unterhaltsam.",
["0004"] = "Und sie sagen, wir werden Spaß haben, wenn es aufhört zu regnen.",
},
},
}
localizationTable:SetEntries(entries)
local get_results = localizationTable:GetEntries()
for _index, dict in pairs(get_results) do
for _key, value in pairs(dict["Values"]) do -- Durchlaufe jedes Schlüssel-Wert-Paar im Dictionary, um unsere Strings auszugeben
print(value)
end
endGetString
GetTranslator
RemoveEntry
RemoveEntryValue
RemoveKey
RemoveTargetLocale
SetContents
SetEntries
LocalizationTable:SetEntries(entries:Variant):()
Parameter
entries:Variant |
Rückgaben
()
SetEntry
SetEntryContext
SetEntryExample
SetEntryKey
SetEntrySource