LocalizationService

Show Deprecated
Not Creatable
Service
Not Replicated

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

  • Read Only
    Not Replicated
    Read Parallel

    The locale ID used for localizing core and internal features.

  • Read Only
    Not Replicated
    Read Parallel

    The locale ID that the local player has set for their operating system.

Methods

Properties

RobloxLocaleId

Read Only
Not Replicated
Read Parallel

SystemLocaleId

Read Only
Not Replicated
Read Parallel

Methods

GetCorescriptLocalizations

Instances

Returns

Instances

GetCountryRegionForPlayerAsync

Yields

Parameters

player: Instance

Returns

Code Samples

Getting Country/Region Code for a Player

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

GetTableEntries

Parameters

instance: Instance
Default Value: "nil"

Returns

GetTranslatorForLocaleAsync

Yields

Parameters

locale: string

Returns

Code Samples

Getting and Using a Translator for a 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("Hello in French: " .. result)
else
print("GetTranslatorForLocaleAsync failed: " .. translator)
end

GetTranslatorForPlayer

Parameters

player: Instance

Returns

Code Samples

Getting and Using a Translator for a Player

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

Yields

Parameters

player: Instance

Returns

Code Samples

Getting and Using a Translator for a Player

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

Events