Clase de motor
LocalizationService
*Este contenido se traduce usando la IA (Beta) y puede contener errores. Para ver esta página en inglés, haz clic en aquí.
Resumen
Propiedades
Métodos
GetCorescriptLocalizations():Instances |
GetCountryRegionForPlayerAsync(player: Instance):string |
GetTableEntries(instance: Instance):{any} |
GetTranslatorForLocaleAsync(locale: string):Instance |
GetTranslatorForPlayer(player: Instance):Instance |
GetTranslatorForPlayerAsync(player: Instance):Instance |
Referencia API
Propiedades
Métodos
GetCorescriptLocalizations
LocalizationService:GetCorescriptLocalizations():Instances
Devuelve
Instances
GetCountryRegionForPlayerAsync
Parámetros
Devuelve
Muestras de código
Obtener el código de país/región para un jugador
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("¡Hola, amigo de Canadá!")
else
print("GetCountryRegionForPlayerAsync falló: " .. code)
endGetTableEntries
GetTranslatorForLocaleAsync
Parámetros
Devuelve
Muestras de código
Obtener y utilizar un traductor para una localidad
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("Hola en Francés: " .. result)
else
print("GetTranslatorForLocaleAsync falló: " .. translator)
endGetTranslatorForPlayer
GetTranslatorForPlayerAsync
Parámetros
Devuelve
Muestras de código
Obtener y Utilizar un Traductor para un Jugador
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, "¡Hola Mundo!")
print(result)
else
print("GetTranslatorForPlayerAsync falló: " .. translator)
end