We are excited to announce that we’ll be rolling out an update in the next few weeks which enables users to change their language settings while they are in an experience. Players will be able to toggle between supported languages using the in-experience menu.
Any GUI object that has the
AutoLocalize property set to
True will automatically be translated when a player switches languages in an experience. However, any localization performed by scripting (using Localization APIs) will need to be updated to react properly when a user changes their language.
You will need to detect a change in the
LocaleID of the
Translator instance returned by
GetTranslatorForPlayerAsync. This is done using the
GetPropertyChangedSignal event, which can call listeners to update translations as necessary.
local LocalizationService = game:GetService("LocalizationService") local Players = game:GetService("Players") local player = Players.LocalPlayer -- If GetTranslatorForPlayerAsync does not error, it will return a Translator for player's current locale local res, translator = pcall(function() return LocalizationService:GetTranslatorForPlayerAsync(player) end) -- Function that gets called when change in player's locale ID is detected local function OnLocaleIdChanged() print("Translator has changed to: " .. translator.LocaleId) -- You should re-translate any assets translated with Localization APIs to the player's new language here end -- Check if GetTranslatorForPlayerAsync succeeded if res then -- If succeeded, translate assets here using translator -- Listen for a change in player's locale ID translator:GetPropertyChangedSignal("LocaleId"):Connect(OnLocaleIdChanged) else print('GetTranslatorForPlayerAsync failed: ' .. translator) end
See Reacting to Users Switching Languages in our documentation for additional implementation details.
Making these code changes will not interrupt any existing functionality, but you will not be able to test the listener function until language switcher emulation becomes available in Studio. We plan to roll emulation out alongside the feature in a few weeks.
Please leave any feedback or questions below!