This is a yielding function. When called, it will pause the Lua thread that called the function until a result is ready to be returned, without interrupting other scripts.
This function takes a player as an argument and yields until the cloud localization data for that player’s locale has been loaded, and then returns a
Translator object which can be used to perform translations for that locale if any are available.
This function can error and thus should be wrapped in a pcall.
LocalizationService/GetTranslatorForPlayer, same functionality as this function except that it does not yield and will only return data for embedded localization tables. It won’t include any data from web-based tables.
LocalizationService/GetTranslatorForLocaleAsync, returns a Translator to be used for translations using the locale data loaded
Getting and Using a Translator for a Player
This code sample attempts to retrieve a
Translator object for the local player.
LocalizationService/GetTranslatorForPlayerAsync is wrapped in a pcall because it may error. If it does not error and returns a Translator, it translates and prints “Hello World!” in the player’s language. If the function errors, it prints “GetTranslatorForLocaleAsync failed:“ followed by the error message.
LocalizationService/GetTranslatorForPlayer can also be used if you’d like to get the player’s translator without yielding until the function returns.