Localization Table
*Este conteúdo é traduzido por IA (Beta) e pode conter erros. Para ver a página em inglês, clique aqui.
Resumo
Propriedades
Métodos
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):() |
Amostras de código
Tabela de Localização
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", -- A 'expressionKey' a ser usado com GetString
Values = { -- Um dicionário de chaves correspondentes a tags de idioma IETF e suas traduções.
["ru"] = " !", -- Russo
["fr"] = "Bonjour le monde!", -- Francês
["de"] = "Hallo Welt!", -- Alemão
["en-US"] = "Hello world!", -- Inglês
["it"] = "Ciao mondo!", -- Italiano
["pt-BR"] = "Ol Mundo!", -- Português
["ja"] = "", -- Japonês
["es"] = "Hola Mundo!", -- Espanhol
},
},
}
local helloWorldTable = createLocalizationTable(entries)
local translatorEnglish = helloWorldTable:GetTranslator("en-US")
print(translatorEnglish:FormatByKey("Hello_World"))Referência API
Propriedades
Development Language
Root
Métodos
Get Contents
Get Entries
Devolução
Amostras de código
Usando uma Tabela de Localização
local LocalizationService = game:GetService("LocalizationService")
local localizationTable = LocalizationService:FindFirstChild("LocalizationTable")
local entries = {
{
["Key"] = "0001",
["Source"] = "en-us",
["Values"] = {
["0001"] = "Olá Muddah, olá Fadduh.",
["0002"] = "Aqui estou no Acampamento Granada.",
["0003"] = "O acampamento é muito divertido.",
["0004"] = "E eles dizem que teremos diversão se parar de chover.",
},
},
}
localizationTable:SetEntries(entries)
local get_results = localizationTable:GetEntries()
for _index, dict in pairs(get_results) do
for _key, value in pairs(dict["Values"]) do -- Percorre cada par chave, valor no dicionário para imprimir nossas strings
print(value)
end
endGet String
Get Translator
Remove Entry
Remove Entry Value
Remove Key
Remove Target Locale
Set Contents
Set Entries
Localization Table: Set Entries(entries:Variant):()
Parâmetros
entries:Variant |
Devolução
()
Set Entry
Set Entry Context
Set Entry Example
Set Entry Key
Set Entry Source