Translator:Translate() not working

hi, so the following code is taken directly from here, but changed the context (which does not matter in this case):

local LS = game:GetService('LocalizationService')
 
local res,trans = pcall(function()
	return LS:GetTranslatorForLocaleAsync("fr")
end)
	
if res then
	local ctx = game
	local res = trans:Translate(ctx, "Hello World!")
	print('Hello in French: ' .. res)
else
	print('GetTranslatorForLocaleAsync failed: ' .. trans)
end

it is not working at all. in studio AND in game, all “translations” are just whatever the input was. No translation is done. Any idea why?

ps: by “whatever the input was”, i mean the output is:

Hello in French: Hello World!

You’re doing it wrong. The Translator:Translate() function isn’t machine translation; it retrieves translations from a big index of translations called a LocalizationTable. To add translations, you visit the Localization Portal for your game. (Find out how to visit it at this very nice tutorial on the DevHub.)

If you’re looking for a free machine translation system, I recommend you take a look at the free LibreTranslate API. However, I strongly suggest hiring a human translator to fill in translations on the Localization Portal for all serious projects.

2 Likes

roblox has a free machine translation system, right? how do I use it?

You enable the automatic machine translation with this nice tutorial:

It might not be available for your game right now though.

ill mark this as solved but i am still having a problem; i cant get libretranslate running. my game does not have automatic machine translation so i made a list of all of the games (exhaustingly extensive) dialogue and im trying to process it but libretranslate just… refuses to install. can it run on windows? every tutorial ive found gives me errors

If you’re going to install a local translator application, I’d advise not going with LibreTranslate. There are many better local alternatives if you’re going with Windows, like the far superior DeepL Translator.

i was installing it so i could avoid the ratelimit, but i figured it out and just translated everything into 5 languages

1 Like