Scripting HelpersARCHIVE
A little piece of Roblox history. Preserved for everyone, one question at a time.Read about the archive →
✓ ANSWER ACCEPTED

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

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

✓ Accepted answer

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.

1 comment

0

Thanks for the information, and sorry for seeing this a bit later.

This discussion is preserved as it was. New answers, comments, and votes are closed.