Classe de moteur
LocalizationService
*Ce contenu est traduit en utilisant l'IA (Beta) et peut contenir des erreurs. Pour consulter cette page en anglais, clique ici.
Résumé
Propriétés
Méthodes
GetCorescriptLocalizations():Instances |
GetCountryRegionForPlayerAsync(player: Instance):string |
GetTableEntries(instance: Instance):{any} |
GetTranslatorForLocaleAsync(locale: string):Instance |
GetTranslatorForPlayer(player: Instance):Instance |
GetTranslatorForPlayerAsync(player: Instance):Instance |
Référence API
Propriétés
Méthodes
GetCorescriptLocalizations
LocalizationService:GetCorescriptLocalizations():Instances
Retours
Instances
GetCountryRegionForPlayerAsync
Paramètres
Retours
Échantillons de code
Obtenir le code Pays/Région pour un joueur
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("Bonjour, ami du Canada !")
else
print("GetCountryRegionForPlayerAsync a échoué : " .. code)
endGetTableEntries
GetTranslatorForLocaleAsync
Paramètres
Retours
Échantillons de code
Obtenir et utiliser un traducteur pour une 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("Bonjour en français: " .. result)
else
print("GetTranslatorForLocaleAsync failed: " .. translator)
endGetTranslatorForPlayer
GetTranslatorForPlayerAsync
Paramètres
Retours
Échantillons de code
Obtenir et utiliser un traducteur pour un joueur
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