Translating using :GetTranslatorForLocaleAsync() doesn't seem to be working?

Hey, I need help from somebody on this. There are no errors in the output or anything but it still prints “Hello how are you?” instead of printing it in German. Basically, even if tried doing it it another language or translated it to the other way round, such as setting German to English it still probably wouldn’t work.

I’ve added the German language to Localization, selected "Use Translate Content" and all forms of "Automatic Text Capture" have been enabled:

local LocalizationService = game:GetService("LocalizationService")

-- Load Translator for "de". Wrap the function within a pcall() to protect against failures.
local res, translator = pcall(function()
	return LocalizationService:GetTranslatorForLocaleAsync("de")
end)

if res then
	-- Use Translate function, providing object context and string
	local sourceTranslation = translator:Translate(game, "Hello how are you?")
	print(sourceTranslation)
else
	print('GetTranslatorForPlayerAsync failed: ' .. translator)
end

For now this script is just a test to see if the translations work and I would eventually use it on a bigger problem, such as lots of people giving text entries through StringValues and displaying them in TextLabels through GUIs, but not all of this content by users is in the same language for me to read, that’s why I want to be able to translate it. I’ve looked all around on the Devforum about it but none of it has been really that helpful. I even tried testing the script in the main game to see if it was a problem with testing in studio not translating languages, but I still had the same issue.

Similarly, I have used Roblox’s method of translating by using a TextLabel object, instead of assigning game to avoid an “Argument 2 missing or nil” error. Still, this method just prints “Hello World!”, instead of “Hello World!” in German:

local LocalizationService = game:GetService("LocalizationService")

local textLabel = script.Parent

local success, translator = pcall(function()
	return LocalizationService:GetTranslatorForLocaleAsync("de")
end)
if success then
	local result = translator:Translate(textLabel, "Hello World!")
	print(result)
else
	print("GetTranslatorForLocaleAsync failed: " .. translator)
end

As said before, none of this has produced any errors so I have no clue where the problem may be coming from. I am not familiar with using code to translate languages, so please let me know if I need to change anything. Am I missing something here? If anybody could help me on this particular problem, it would be greatly appreciated! Thank you.

Any assistance big or small shall be appreciated. So far I’ve done everything that I think is possible to try and fix the problem but so far no luck.


Edit: Has anybody else had these kind of problems? Just curious, because I haven’t seen many recent posts about this issue.

Having read over my previous codes, I was left wondering why I needed to add a first assignment inside :Translate() to avoid “Argument 2 missing or nil ”. What is the purpose of the first assignment in the first place?:

local sourceTranslation = translator:Translate(game, "Hello how are you?")

Or

local result = translator:Translate(textLabel, "Hello World!")

After some searching, Translate does not automatically translate the given string, but retrieves the translation from the LocalizationTable.

LocalizationService:GetTranslatorForLocaleAsync()

The entries used for localization are the entries provided by the LocalizationTable hierarchy under LocalizationService as well as the cloud table (if available). This will be the same set of entries returned by LocalizationService.GetTableEntries(nil)."


The automatic translation article essentially captures/collects text in-game during testing/playing and adds it to your cloud LocalizationTable, which you can then keep or modify to your liking.

Automatic translation works by first collecting strings encountered within the experience, either through testing or playing. Once these strings are captured, Roblox automatically translates the strings on your experience’s localization table.

After collecting these strings, you can enable translations for your experience to automatically display the captured strings for users who have their default language settings set to the translated language.


Finally the context: it is essentially an override translator best explained in this article section: Localizing with Scripting | Documentation - Roblox Creator Hub

So there isn’t really an option to translate anything in a Roblox game unless it’s been predetermined in Localization?

Technically you can using a 3rd party API and filter it using TextChatService:FilterStringAsync()

If I was using a textLabel for example instead of printing in the Output, I could just use AutoLocalize but the only problem with that is that you can’t have text too long?


Edit:

Also, can you show me how I could do that?

This topic was automatically closed 14 days after the last reply. New replies are no longer allowed.