Scripting Helpers is winding down operations and is now read-only. More info→
Ad
Log in to vote
1

How would i load a LocalizationTable when someone clicked on a TextButton?

Asked by
mauro21 22
5 years ago

So how would i load a LocalizationTable when someone clicked on a textbutton? For example: You have a GUI with a textbutton and when someone clicks it the localization table loads in for that player in the selected language.

1 answer

Log in to vote
0
Answered by 5 years ago

1: Retrieve the user's language preferences, you can get it by using the property of LocalizationService.RobloxLocaleID or LocalizationService.SystemLocaleID, these returns a string.

2: Get a Translator Instance for the specified player using the LocalizationService:GetTranslatorForPlayer() constructor, this will return the Translator Instance which provides the translations.

Note: LocalizationService only provides to get the locale IDs and get a translator, and that translator will lookup to a LocalizationTable object

3: After retrieving a Translator Instance, you can use Translate:FormatByKey() in a LocalizationTable or use Translate:Translate(), this will need context which is the source of the GUI text, then the text you need to translate.

After doing these steps, this will: call the LocalizationService to return a Translator Instance, invoke functions from the Translator to provide translations which in turn will lookup to the keys, context, and string to provide the translation.

0
Thanks for the information, and sorry for seeing this a bit later. mauro21 22 — 5y
Ad

Answer this question