tl;dr: LocalizationService isn’t translating correctly?
This is a snippet of a function in a module.
function LocalizationModule:TranslateStringAsync(...) --/ (player), string, (pathway), (LocaleId) / if this is being called from the client the player agrument doesn't need to be supplied
local Args = {...}
local Player
local String
local Pathway
local LocaleId
if CheckEnvironment.IsServer == true then
Player = Args[1]
String = Args[2]
Pathway = Args[3]
LocaleId = Args[4]
elseif CheckEnvironment.IsClient == true then
Player = Players.LocalPlayer
String = Args[1]
Pathway = Args[2]
LocaleId = Args[3]
else
error('Script environment is not valid for translation!', math.huge)
end
if not Pathway then Pathway = game end
if LocaleId then
print(LocaleId)
local GetTranslator do
function GetTranslator()
local success, translator
for retries = 1, MaxRetriesForAsynchronousCall do
success, translator = pcall(function()
return LocalizationService:GetTranslatorForLocaleAsync(LocaleId)
end)
if success then
break
end
RunService.Stepped:Wait()
end
return {success, translator}
end
end
local TranslatorObject = assert(GetTranslator()) --/* TODO: remove assert (?)
local Success = TranslatorObject[1]
local Translator = TranslatorObject[2]
if Success then
return Translator:Translate(Pathway, String)
else
warn('After ' ..MaxRetriesForAsynchronousCall.. 'retries the translator still failed to fetch, not going to translate content.', debug.traceback()) return
end
end
I’m calling it from the client and everything is working as expected. I am supplying a manual locale Id for testing to see if it will properly translate. Here is the call from the client:
print(Localization:TranslateStringAsync('Hello, how are you?', nil, 'fr'))
It works as expected and returns, but the output isn’t translated at all. What’s wrong here? Is LocalizationService unfinished? It says French is currently supported.
Output:
fr
Hello, how are you?