Engine Class
LocalizationTable
*เนื้อหานี้แปลโดยใช้ AI (เวอร์ชัน Beta) และอาจมีข้อผิดพลาด หากต้องการดูหน้านี้เป็นภาษาอังกฤษ ให้คลิกที่นี่
สรุป
วิธีการ
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):() |
ตัวอย่างโค้ด
ตารางการปรับท้องถิ่น
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' ที่จะใช้กับ GetString
Values = { -- พจนานุกรมของคีย์ที่ตรงกับ IETF language tags และการแปลของพวกเขา
["ru"] = " !", -- รัสเซีย
["fr"] = "Bonjour le monde!", -- ฝรั่งเศส
["de"] = "Hallo Welt!", -- เยอรมัน
["en-US"] = "Hello world!", -- อังกฤษ
["it"] = "Ciao mondo!", -- อิตาลี
["pt-BR"] = "Ol Mundo!", -- โปรตุเกส
["ja"] = "", -- ญี่ปุ่น
["es"] = "Hola Mundo!", -- สเปน
},
},
}
local helloWorldTable = createLocalizationTable(entries)
local translatorEnglish = helloWorldTable:GetTranslator("en-US")
print(translatorEnglish:FormatByKey("Hello_World"))เอกสารอ้างอิงเกี่ยวกับ API
คุณสมบัติ
DevelopmentLanguage
Root
วิธีการ
GetContents
GetEntries
ส่งค่ากลับ
ตัวอย่างโค้ด
การใช้ LocalizationTable
local LocalizationService = game:GetService("LocalizationService")
local localizationTable = LocalizationService:FindFirstChild("LocalizationTable")
local entries = {
{
["Key"] = "0001",
["Source"] = "en-us",
["Values"] = {
["0001"] = "สวัสดีคุณแม่ สวัสดีคุณพ่อ.",
["0002"] = "นี่ฉันอยู่ที่แคมป์กรานาดา.",
["0003"] = "แคมป์สนุกมาก.",
["0004"] = "และพวกเขาบอกว่าเราจะสนุกถ้ามันหยุดฝน.",
},
},
}
localizationTable:SetEntries(entries)
local get_results = localizationTable:GetEntries()
for _index, dict in pairs(get_results) do
for _key, value in pairs(dict["Values"]) do -- วนผ่านทุกคู่คีย์และค่าในพจนานุกรมเพื่อตีพิมพ์สายอักขระของเรา
print(value)
end
endGetString
GetTranslator
RemoveEntry
RemoveEntryValue
RemoveKey
RemoveTargetLocale
SetContents
SetEntries
LocalizationTable:SetEntries(entries:Variant):()
พารามิเตอร์
entries:Variant |
ส่งค่ากลับ
()
SetEntry
SetEntryContext
SetEntryExample
SetEntryKey
SetEntrySource