學習
引擎類別
LocalizationService
無法建立
服務
未複製

*此內容是使用 AI(Beta 測試版)翻譯,可能含有錯誤。若要以英文檢視此頁面,請按一下這裡



API 參考
屬性
RobloxLocaleId
唯讀
未複製
平行讀取
功能: Basic
LocalizationService.RobloxLocaleId:string

SystemLocaleId
唯讀
未複製
平行讀取
功能: Basic
LocalizationService.SystemLocaleId:string

方法
GetCorescriptLocalizations
功能: Basic
LocalizationService:GetCorescriptLocalizations():Instances
返回
Instances

GetCountryRegionForPlayerAsync
暫停
功能: Basic
LocalizationService:GetCountryRegionForPlayerAsync(player:Instance):string
參數
player:Instance
返回
範例程式碼
獲取玩家的國家/地區代碼
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)
end

GetTableEntries
功能: Basic
LocalizationService:GetTableEntries(instance:Instance):{any}
參數
instance:Instance
預設值:"nil"
返回

GetTranslatorForLocaleAsync
暫停
功能: Basic
LocalizationService:GetTranslatorForLocaleAsync(locale:string):Instance
參數
locale:string
返回
範例程式碼
獲取和使用地區的翻譯器
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, "Hello World!")
print("法語的問候: " .. result)
else
print("GetTranslatorForLocaleAsync 失敗: " .. translator)
end

GetTranslatorForPlayer
已棄用

GetTranslatorForPlayerAsync
暫停
功能: Basic
LocalizationService:GetTranslatorForPlayerAsync(player:Instance):Instance
參數
player:Instance
返回
範例程式碼
獲取和使用玩家的翻譯器
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, "Hello World!")
print(result)
else
print("GetTranslatorForPlayerAsync failed:" .. translator)
end

©2026 Roblox Corporation、Roblox、Roblox 標誌及 Powering Imagination 是我們在美國及其他國家地區的部分註冊與未註冊商標。