Klasa silnika
LocalizationService
*Ta zawartość została przetłumaczona przy użyciu narzędzi AI (w wersji beta) i może zawierać błędy. Aby wyświetlić tę stronę w języku angielskim, kliknij tutaj.
Podsumowanie
Właściwości
Metody
GetCorescriptLocalizations():Instances |
GetCountryRegionForPlayerAsync(player: Instance):string |
GetTableEntries(instance: Instance):{any} |
GetTranslatorForLocaleAsync(locale: string):Instance |
GetTranslatorForPlayer(player: Instance):Instance |
GetTranslatorForPlayerAsync(player: Instance):Instance |
Materiały referencyjne dotyczące interfejsów API
Właściwości
Metody
GetCorescriptLocalizations
LocalizationService:GetCorescriptLocalizations():Instances
Zwroty
Instances
GetCountryRegionForPlayerAsync
Parametry
Zwroty
Przykłady kodu
Uzyskiwanie kodu kraju/regionu dla gracza
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("Cześć, przyjacielu z Kanady!")
else
print("GetCountryRegionForPlayerAsync nie powiodło się: " .. code)
endGetTableEntries
GetTranslatorForLocaleAsync
Parametry
Zwroty
Przykłady kodu
Uzyskiwanie i używanie tłumacza dla lokalizacji
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("Witaj po francusku: " .. result)
else
print("GetTranslatorForLocaleAsync nie powiodło się: " .. translator)
endGetTranslatorForPlayer
GetTranslatorForPlayerAsync
Parametry
Zwroty
Przykłady kodu
Uzyskiwanie i korzystanie z tłumacza dla gracza
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, "Witaj Świecie!")
print(result)
else
print("GetTranslatorForPlayerAsync nie powiodło się: " .. translator)
end