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 language code as an argument and yields until the cloud localization data for that 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
articles/Built-in Functions & Variables — Lua|pcall.
LocalizationService/GetTranslatorForPlayer, same functionality as this function except that it does not yield
LocalizationService/GetTranslatorForPlayerAsync, same functionality as this function except that it yields until the translator has been loaded
A Roblox supported language code. The currently supported language codes are “en” (English), “fr” (French), “de” (German), “ko” (Korean), “pt” (Portuguese), “es” (Spanish)
Getting and Using a Translator for a Locale
This code sample attempts to retrieve a
Translator object for the locale “fr” - French.
LocalizationService/GetTranslatorForLocaleAsync is wrapped in a pcall because it may error. If it does not error and returns a Translator, prints “Hello in French:“ followed by the French translation of “Hello World!”. If the function errors, it prints “GetTranslatorForLocaleAsync failed:“ followed by the error message.