Classe motore
LocalizationService
*Questo contenuto è tradotto usando AI (Beta) e potrebbe contenere errori. Per visualizzare questa pagina in inglese, clicca qui.
Sommario
Proprietà
Metodi
GetCorescriptLocalizations():Instances |
GetCountryRegionForPlayerAsync(player: Instance):string |
GetTableEntries(instance: Instance):{any} |
GetTranslatorForLocaleAsync(locale: string):Instance |
GetTranslatorForPlayer(player: Instance):Instance |
GetTranslatorForPlayerAsync(player: Instance):Instance |
Riferimento API
Proprietà
Metodi
GetCorescriptLocalizations
LocalizationService:GetCorescriptLocalizations():Instances
Restituzioni
Instances
GetCountryRegionForPlayerAsync
Parametri
Restituzioni
Campioni di codice
Ottenere il codice paese/regione per un giocatore
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("Ciao, amico dal Canada!")
else
print("GetCountryRegionForPlayerAsync non riuscito: " .. code)
endGetTableEntries
GetTranslatorForLocaleAsync
Parametri
Restituzioni
Campioni di codice
Ottenere e utilizzare un traduttore per una locale
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("Ciao in francese: " .. result)
else
print("GetTranslatorForLocaleAsync fallito: " .. translator)
endGetTranslatorForPlayer
GetTranslatorForPlayerAsync
Parametri
Restituzioni
Campioni di codice
Ottenere e utilizzare un traduttore per un giocatore
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