Localization Table
*Konten ini diterjemahkan menggunakan AI (Beta) dan mungkin mengandung kesalahan. Untuk melihat halaman ini dalam bahasa Inggris, klik di sini.
Ringkasan
Metode
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):() |
Contoh Kode
TabelLokalisasi
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", -- 'expressionKey' yang akan digunakan dengan GetString
Values = { -- Sebuah kamus kunci yang sesuai dengan tag bahasa IETF, dan terjemahannya.
["ru"] = " !", -- Rusia
["fr"] = "Bonjour le monde!", -- Prancis
["de"] = "Hallo Welt!", -- Jerman
["en-US"] = "Hello world!", -- Inggris
["it"] = "Ciao mondo!", -- Italia
["pt-BR"] = "Ol Mundo!", -- Portugis
["ja"] = "", -- Jepang
["es"] = "Hola Mundo!", -- Spanyol
},
},
}
local helloWorldTable = createLocalizationTable(entries)
local translatorEnglish = helloWorldTable:GetTranslator("en-US")
print(translatorEnglish:FormatByKey("Hello_World"))Referensi API
Properti
Development Language
Root
Metode
Get Contents
Get Entries
Memberikan nilai
Contoh Kode
Menggunakan LocalizationTable
local LocalizationService = game:GetService("LocalizationService")
local localizationTable = LocalizationService:FindFirstChild("LocalizationTable")
local entries = {
{
["Key"] = "0001",
["Source"] = "en-us",
["Values"] = {
["0001"] = "Halo Muddah, halo Fadduh.",
["0002"] = "Ini aku di Camp Granada.",
["0003"] = "Camp sangat menghibur.",
["0004"] = "Dan mereka bilang kita akan bersenang-senang jika hujan berhenti.",
},
},
}
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 melalui setiap pasangan kunci, nilai dalam kamus untuk mencetak string kita
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):()
Parameter
entries:Variant |
Memberikan nilai
()
Set Entry
Set Entry Context
Set Entry Example
Set Entry Key
Set Entry Source