LocalizationService
LocalizationService is the service responsible for handling automated translation.
It is used as a storage for LocalizationTable objects used by automatic text replacement.
LocalizationService will only use its child LocalizationTables for automatic text replacement unless GuiBase2d.RootLocalizationTable is specified on a GUI object or its ancestors.
Summary
Properties
The locale ID used for localizing core and internal features.
The locale ID that the local player has set for their operating system.
Methods
Returns a list of LocalizationTable objects used for localizing core scripts.
Returns country/region code string according to player's client IP geolocation.
Gets all entries used for automated localization.
Yields until the cloud LocalizationTable for the argument locale has been loaded - if available. Returns a Translator instance to be used for translations for the provided locale.
Returns a Translator to be used for translations using the locale data loaded.
Yields until the cloud LocalizationTable for the player's locale has been loaded - if available. Returns a Translator instance to be used for translations for the provided locale.
Properties
Methods
GetCorescriptLocalizations
Returns
GetCountryRegionForPlayerAsync
Parameters
Returns
Code Samples
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("Hello, friend from Canada!")
else
print("GetCountryRegionForPlayerAsync failed: " .. code)
end
GetTranslatorForLocaleAsync
Parameters
Returns
Code Samples
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("Hello in French: " .. result)
else
print("GetTranslatorForLocaleAsync failed: " .. translator)
end
GetTranslatorForPlayer
Parameters
Returns
Code Samples
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
GetTranslatorForPlayerAsync
Parameters
Returns
Code Samples
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