Engine Class
LocalizationService
*เนื้อหานี้แปลโดยใช้ AI (เวอร์ชัน Beta) และอาจมีข้อผิดพลาด หากต้องการดูหน้านี้เป็นภาษาอังกฤษ ให้คลิกที่นี่
สรุป
คุณสมบัติ
วิธีการ
GetCorescriptLocalizations():Instances |
GetCountryRegionForPlayerAsync(player: Instance):string |
GetTableEntries(instance: Instance):{any} |
GetTranslatorForLocaleAsync(locale: string):Instance |
GetTranslatorForPlayer(player: Instance):Instance |
GetTranslatorForPlayerAsync(player: Instance):Instance |
เอกสารอ้างอิงเกี่ยวกับ API
คุณสมบัติ
วิธีการ
GetCorescriptLocalizations
LocalizationService:GetCorescriptLocalizations():Instances
ส่งค่ากลับ
Instances
GetCountryRegionForPlayerAsync
พารามิเตอร์
ส่งค่ากลับ
ตัวอย่างโค้ด
การรับรหัสประเทศ/ภูมิภาคสำหรับผู้เล่น
local LocalizationService = game:GetService("LocalizationService")
local Players = game:GetService("Players")
local player = Players.LocalPlayer
local result, code = pcall(LocalizationService.GetCountryRegionForPlayerAsync, LocalizationService, player)
if result and code == "CA" then
print("สวัสดีเพื่อนจากแคนาดา!")
else
print("GetCountryRegionForPlayerAsync ล้มเหลว: " .. code)
endGetTableEntries
GetTranslatorForLocaleAsync
พารามิเตอร์
ส่งค่ากลับ
ตัวอย่างโค้ด
การรับและการใช้ตัวแปลภาษาในพื้นที่
local LocalizationService = game:GetService("LocalizationService")
local textLabel = script.Parent
local success, translator = pcall(function()
return LocalizationService:GetTranslatorForLocaleAsync("fr")
end)
if success then
local result = translator:Translate(textLabel, "สวัสดี โลก!")
print("สวัสดีเป็นภาษาฝรั่งเศส: " .. result)
else
print("GetTranslatorForLocaleAsync ล้มเหลว: " .. translator)
endGetTranslatorForPlayer
GetTranslatorForPlayerAsync
พารามิเตอร์
ส่งค่ากลับ
ตัวอย่างโค้ด
การรับและใช้งานตัวแปลภาษาสำหรับผู้เล่น
local LocalizationService = game:GetService("LocalizationService")
local Players = game:GetService("Players")
local textLabel = script.Parent
local success, translator = pcall(function()
return LocalizationService:GetTranslatorForPlayerAsync(Players.LocalPlayer)
end)
if success then
local result = translator:Translate(textLabel, "สวัสดีชาวโลก!")
print(result)
else
print("GetTranslatorForPlayerAsync ล้มเหลว: " .. translator)
end