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

HIDDEN
NOT REPLICATED

When set to a non-empty string, this property overrides value of the LocalizationService.RobloxLocaleId when running in play solo mode.

HIDDEN
NOT REPLICATED

The locale id used for localizing core and internal features such as core scripts and GUI.

READ ONLY
NOT REPLICATED

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

READ ONLY
NOT REPLICATED

Events

Methods


Returns a list of LocalizationTable objects used for localizing CoreScripts.


Gets all entries used for autotranslation.


Returns a Translator to be used for translations using the locale data loaded.

SetRobloxLocaleId(locale: string): void  


StartTextScraper(): void  


StopTextScraper(): void  



Returns country/region code string according to player's client IP geolocation.


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.


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.

PromptDownloadGameTableToCSV(table: Instance): void  YIELDS


PromptExportToCSVs(): void  YIELDS


PromptImportFromCSVs(): void  YIELDS


Properties

ForcePlayModeGameLocaleId

Hidden
Not Replicated

ForcePlayModeRobloxLocaleId

Hidden
Not Replicated

When set to a non-empty string, this property overrides value of the LocalizationService.RobloxLocaleId when running in play solo mode.

IsTextScraperRunning

RobloxForcePlayModeGameLocaleId

Hidden
Not Replicated

RobloxForcePlayModeRobloxLocaleId

Hidden
Not Replicated

RobloxLocaleId

Read Only
Not Replicated

This property shows the locale id used for the localization of core and internal features such as CoreGui and CoreScripts.

This will return a string with the two letter code (for example, "en-us") for the locale.

SystemLocaleId

Read Only
Not Replicated

This property shows the locale id that the local player has set for their operating system.

This will return a string with the two letter code (for example, "en-us") for the locale.

Events

AutoTranslateWillRun

Roblox Script Security

Methods

GetCorescriptLocalizations

Returns a list of LocalizationTable objects used for localizing CoreScripts.


Returns

GetTableEntries

Returns an Array, where each element of the returned Array is itself an Array of entries in the same format as described in LocalizationTable:GetEntries(). The order of the elements in the returned Array is the same order that the LocalizationTables will be searched through to attempt autotranslation for the provided Instance. The entry elements within a particular LocalizationTable are returned in an unspecified order.

This function returns entries regardless of whether the object is a GuiBase2d with GuiBase2d.AutoLocalize enabled. An object that is a GuiBase2d will not actually be autotranslated unless GuiBase2d.AutoLocalize is enabled.

The ordering of the tables is as follows:

This function does not yield. It will not wait until the cloud LocalizationTable has loaded.

Parameters

instance: Instance
Default Value: "nil"

Returns

An array of arrays, where each array is in the same format as described in LocalizationTable:GetEntries().

GetTranslatorForPlayer

This function takes a player as an argument and returns a Translator instance which can be used to perform translations for that locale if any are available. The entries used for localization are the entries provided by the LocalizationTable hierarchy under LocalizationService as well as the cloud LocalizationTable, if it is available and already loaded. This will be the same set of entries returned by LocalizationService.GetTableEntries().

This function does not yield. It will not wait until the cloud LocalizationTable has loaded.

See also:

Parameters

player: Instance

The Player that you are getting the Translator for.


Returns

The Translator instance for the specified locale.

Code Samples

Getting and Using a Translator for a Player

1local LocalizationService = game:GetService("LocalizationService")
2local Players = game:GetService("Players")
3
4local textLabel = script.Parent
5
6local success, translator = pcall(function()
7 return LocalizationService:GetTranslatorForPlayerAsync(Players.LocalPlayer)
8end)
9
10if success then
11 local result = translator:Translate(textLabel, "Hello World!")
12 print(result)
13else
14 print("GetTranslatorForPlayerAsync failed: " .. translator)
15end

SetExperienceSettingsLocaleId

void
Roblox Script Security

Parameters

locale: string

Returns

void

SetRobloxLocaleId

void
Roblox Script Security

Parameters

locale: string

Returns

void

StartTextScraper

void
Roblox Script Security

Returns

void

StopTextScraper

void
Roblox Script Security

Returns

void

GetCountryRegionForPlayerAsync

Yields

Returns a country/region code string according to player's client IP geolocation. The supported country/region codes are as follows:

CodeCountry/Region
USUnited States
GBUnited Kingdom
CACanada
AFAfghanistan
AXAland Islands
ALAlbania
DZAlgeria
ASAmerican Samoa
ADAndorra
AOAngola
AIAnguilla
AQAntarctica
AGAntigua and Barbuda
ARArgentina
AMArmenia
AWAruba
AUAustralia
ATAustria
AZAzerbaijan
BSBahamas
BHBahrain
BDBangladesh
BBBarbados
BYBelarus
BEBelgium
BZBelize
BJBenin
BMBermuda
BTBhutan
BOBolivia
BQBonaire, Saint Eustatius and Saba
BABosnia and Herzegovina
BWBotswana
BVBouvet Island
BRBrazil
IOBritish Indian Ocean Territory
BNBrunei Darussalam
BGBulgaria
BFBurkina Faso
BIBurundi
KHCambodia
CMCameroon
CVCape Verde
KYCayman Islands
CFCentral African Republic
TDChad
CLChile
CNChina
CXChristmas Island
CCCocos Islands
COColombia
KMComoros
CGCongo
CDCongo (DRC)
CKCook Islands
CRCosta Rica
CIIvory Coast
HRCroatia
CWCuraçao
CYCyprus
CZCzech Republic
DKDenmark
DJDjibouti
DMDominica
DODominican Republic
ECEcuador
EGEgypt
SVEl Salvador
GQEquatorial Guinea
EREritrea
EEEstonia
ETEthiopia
FKFalkland Islands (Malvinas)
FOFaroe Islands
FJFiji
FIFinland
FRFrance
GFFrench Guiana
PFFrench Polynesia
TFFrench Southern Territories
GAGabon
GMGambia
GEGeorgia
DEGermany
CodeCountry/Region
GHGhana
GIGibraltar
GRGreece
GLGreenland
GDGrenada
GPGuadeloupe
GUGuam
GTGuatemala
GGGuernsey
GNGuinea
GWGuinea-Bissau
GYGuyana
HTHaiti
HMHeard Island and the McDonald Islands
VAHoly See
HNHonduras
HKHong Kong
HUHungary
ISIceland
INIndia
IDIndonesia
IQIraq
IEIreland
IMIsle of Man
ILIsrael
ITItaly
JMJamaica
JPJapan
JEJersey
JOJordan
KZKazakhstan
KEKenya
KIKiribati
KRKorea
KWKuwait
KGKyrgyzstan
LALaos
LVLatvia
LBLebanon
LSLesotho
LRLiberia
LYLibya
LILiechtenstein
LTLithuania
LULuxembourg
MOMacao
MKMacedonia
MGMadagascar
MWMalawi
MYMalaysia
MVMaldives
MLMali
MTMalta
MHMarshall Islands
MQMartinique
MRMauritania
MUMauritius
YTMayotte
MXMexico
FMMicronesia
MDMoldova
MCMonaco
MNMongolia
MEMontenegro
MSMontserrat
MAMorocco
MZMozambique
MMMyanmar
NANamibia
NRNauru
NPNepal
NLNetherlands
ANNetherlands Antilles
NCNew Caledonia
NZNew Zealand
NINicaragua
NENiger
NGNigeria
NUNiue
NFNorfolk Island
MPNorthern Mariana Islands
NONorway
OMOman
CodeCountry/Region
PKPakistan
PWPalau
PSPalestine
PAPanama
PGPapua New Guinea
PYParaguay
PEPeru
PHPhilippines
PNPitcairn Islands
PLPoland
PTPortugal
PRPuerto Rico
QAQatar
REReunion
RORomania
RURussian Federation
RWRwanda
BLSaint Barthelemy
SHSaint Helena, Ascension and Tristan da Cunha
KNSaint Kitts and Nevis
LCSaint Lucia
MFSaint Martin
PMSaint Pierre and Miquelon
VCSaint Vincent and the Grenadines
WSSamoa
SMSan Marino
STSao Tome and Principe
SASaudi Arabia
SNSenegal
RSSerbia
SCSeychelles
SLSierra Leone
SGSingapore
SXSint Maarten
SKSlovakia
SISlovenia
SBSolomon Islands
SOSomalia
ZASouth Africa
GSSouth Georgia and the South Sandwich Islands
SSSouth Sudan
ESSpain
LKSri Lanka
SRSuriname
SJSvalbard and Jan Mayen
SZSwaziland
SESweden
CHSwitzerland
TWTaiwan
TJTajikistan
TZTanzania
THThailand
TLTimor-leste
TGTogo
TKTokelau
TOTonga
TTTrinidad and Tobago
TNTunisia
TRTurkey
TMTurkmenistan
TCTurks and Caicos Islands
TVTuvalu
UGUganda
UAUkraine
AEUnited Arab Emirates
UMUnited States Minor Outlying Islands
UYUruguay
UZUzbekistan
VUVanuatu
VEVenezuela
VNVietnam
VGVirgin Islands (British)
VIVirgin Islands (US)
WFWallis and Futuna
EHWestern Sahara
YEYemen
ZMZambia
ZWZimbabwe
CUCuba
IRIran
SYSyria
KPNorth Korea

See also:

Parameters

player: Instance

The player that you are getting country/region information for.


Returns

A string indicating the country/region code of a player.

Code Samples

Getting Country/Region Code for a Player

1local LocalizationService = game:GetService("LocalizationService")
2local Players = game:GetService("Players")
3
4local player = Players.LocalPlayer
5
6local result, code = pcall(LocalizationService.GetCountryRegionForPlayerAsync, LocalizationService, player)
7
8if result and code == "CA" then
9 print("Hello, friend from Canada!")
10else
11 print("GetCountryRegionForPlayerAsync failed: " .. code)
12end

GetTranslatorForLocaleAsync

Yields

This function takes a locale code as an argument and yields until the cloud LocalizationTable for that locale has been loaded, if available. It then returns a Translator object which can be used to perform translations for that locale if any are available. The entries used for localization are the entries provided by the LocalizationTable hierarchy under LocalizationService as well as the cloud table (if available). This will be the same set of entries returned by LocalizationService.GetTableEntries().

This function can error and thus should be wrapped in a pcall().

See also:

Parameters

locale: string

A Roblox supported language or locale code.


Returns

The Translator instance for the specified locale.

Code Samples

Getting and Using a Translator for a Locale

1local LocalizationService = game:GetService("LocalizationService")
2
3local textLabel = script.Parent
4
5local success, translator = pcall(function()
6 return LocalizationService:GetTranslatorForLocaleAsync("fr")
7end)
8
9if success then
10 local result = translator:Translate(textLabel, "Hello World!")
11 print("Hello in French: " .. result)
12else
13 print("GetTranslatorForLocaleAsync failed: " .. translator)
14end

GetTranslatorForPlayerAsync

Yields

This function takes a player as an argument and yields until the cloud LocalizationTable for that player's locale has been loaded, if available. It then returns a Translator object which can be used to perform translations for that locale if any are available. The entries used for localization are the entries provided by the LocalizationTable hierarchy under LocalizationService as well as the cloud table (if available). This will be the same set of entries returned by GetTableEntries(nil).

This function can error and thus should be wrapped in a pcall().

See also:

Parameters

player: Instance

The Player that you are getting the Translator for.


Returns

The Translator instance for the specified locale.

Code Samples

Getting and Using a Translator for a Player

1local LocalizationService = game:GetService("LocalizationService")
2local Players = game:GetService("Players")
3
4local textLabel = script.Parent
5
6local success, translator = pcall(function()
7 return LocalizationService:GetTranslatorForPlayerAsync(Players.LocalPlayer)
8end)
9
10if success then
11 local result = translator:Translate(textLabel, "Hello World!")
12 print(result)
13else
14 print("GetTranslatorForPlayerAsync failed: " .. translator)
15end

PromptDownloadGameTableToCSV

void
Yields
Roblox Script Security

Parameters

table: Instance

Returns

void

PromptExportToCSVs

void
Yields
Roblox Script Security

Returns

void

PromptImportFromCSVs

void
Yields
Roblox Script Security

Returns

void

PromptUploadCSVToGameTable

Yields
Roblox Script Security

Returns