Classe de moteur
LocalizationTable
*Ce contenu est traduit en utilisant l'IA (Beta) et peut contenir des erreurs. Pour consulter cette page en anglais, clique ici.
Résumé
Propriétés
Méthodes
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):() |
Échantillons de code
TableDeLocalisation
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", -- La clé 'expressionKey' à utiliser avec GetString
Values = { -- Un dictionnaire de clés correspondant aux balises de langue IETF, et leurs traductions.
["ru"] = " !", -- Russe
["fr"] = "Bonjour le monde!", -- Français
["de"] = "Hallo Welt!", -- Allemand
["en-US"] = "Hello world!", -- Anglais
["it"] = "Ciao mondo!", -- Italien
["pt-BR"] = "Ol Mundo!", -- Portugais
["ja"] = "", -- Japonais
["es"] = "Hola Mundo!", -- Espagnol
},
},
}
local helloWorldTable = createLocalizationTable(entries)
local translatorEnglish = helloWorldTable:GetTranslator("en-US")
print(translatorEnglish:FormatByKey("Hello_World"))Référence API
Propriétés
DevelopmentLanguage
Root
Méthodes
GetContents
GetEntries
Retours
Échantillons de code
Utilisation d'une LocalizationTable
local LocalizationService = game:GetService("LocalizationService")
local localizationTable = LocalizationService:FindFirstChild("LocalizationTable")
local entries = {
{
["Key"] = "0001",
["Source"] = "en-us",
["Values"] = {
["0001"] = "Bonjour Muddah, bonjour Fadduh.",
["0002"] = "Me voilà au Camp Granada.",
["0003"] = "Le camp est très divertissant.",
["0004"] = "Et ils disent que nous allons nous amuser si la pluie s'arrête.",
},
},
}
localizationTable:SetEntries(entries)
local get_results = localizationTable:GetEntries()
for _index, dict in pairs(get_results) do
for _key, value in pairs(dict["Values"]) do -- Parcourir chaque paire clé, valeur dans le dictionnaire pour imprimer nos chaînes
print(value)
end
endGetString
GetTranslator
RemoveEntry
RemoveEntryValue
RemoveKey
RemoveTargetLocale
SetContents
SetEntries
LocalizationTable:SetEntries(entries:Variant):()
Paramètres
entries:Variant |
Retours
()
SetEntry
SetEntryContext
SetEntryExample
SetEntryKey
SetEntrySource