Klasa silnika
LocalizationTable
*Ta zawartość została przetłumaczona przy użyciu narzędzi AI (w wersji beta) i może zawierać błędy. Aby wyświetlić tę stronę w języku angielskim, kliknij tutaj.
Podsumowanie
Właściwości
Metody
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):() |
Przykłady kodu
TabelaLokalizacyjna
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", -- Klucz 'expressionKey' do użycia z GetString
Values = { -- Słownik kluczy odpowiadających tagom językowym IETF oraz ich tłumaczeniom.
["ru"] = " !", -- Rosyjski
["fr"] = "Bonjour le monde!", -- Francuski
["de"] = "Hallo Welt!", -- Niemiecki
["en-US"] = "Hello world!", -- Angielski
["it"] = "Ciao mondo!", -- Włoski
["pt-BR"] = "Ol Mundo!", -- Portugalski
["ja"] = "", -- Japoński
["es"] = "Hola Mundo!", -- Hiszpański
},
},
}
local helloWorldTable = createLocalizationTable(entries)
local translatorEnglish = helloWorldTable:GetTranslator("en-US")
print(translatorEnglish:FormatByKey("Hello_World"))Materiały referencyjne dotyczące interfejsów API
Właściwości
DevelopmentLanguage
Root
Metody
GetContents
GetEntries
Zwroty
Przykłady kodu
Używanie LocalizationTable
local LocalizationService = game:GetService("LocalizationService")
local localizationTable = LocalizationService:FindFirstChild("LocalizationTable")
local entries = {
{
["Key"] = "0001",
["Source"] = "en-us",
["Values"] = {
["0001"] = "Witaj Muddah, witaj Fadduh.",
["0002"] = "Oto jestem w Camp Granada.",
["0003"] = "Oboz jest bardzo rozrywkowy.",
["0004"] = "I mówią, że będziemy się dobrze bawić, jeśli przestanie padać.",
},
},
}
localizationTable:SetEntries(entries)
local get_results = localizationTable:GetEntries()
for _index, dict in pairs(get_results) do
for _key, value in pairs(dict["Values"]) do -- Przechodzimy przez każde pary klucz, wartość w słowniku, aby wydrukować nasze ciągi znaków
print(value)
end
endGetString
GetTranslator
RemoveEntry
RemoveEntryValue
RemoveKey
RemoveTargetLocale
SetContents
SetEntries
LocalizationTable:SetEntries(entries:Variant):()
Parametry
entries:Variant |
Zwroty
()
SetEntry
SetEntryContext
SetEntryExample
SetEntryKey
SetEntrySource