Allow to know when Translator:Translate() doesn't find a translation

As a Roblox developer, it is currently impossible to know when Translator:Translate() doesn’t find a translation, because currently it returns the original untranslated string in case the translation is not found.

 -- can't know if the translated text was found
local TranslatedText = Translator:Translate(Context, Text)

If Roblox is able to address this issue, it would improve my development experience because this will let me know when a translation has not been found and I will be able to insert it.

3 Likes

Alternatively you can just

local wasTranslated = TranslatedText == Text

No, because if there is a translation registered where both words are the same (Taxi = Taxi), it won’t work.

Currently, I have a workaround:

function Translate(Player, Text, Context)
	local Translator = Module.GetTranslator(Player)
	local TranslatedText = Translator:Translate(Context, Text) -- will return the original Text if no translation found
	if TranslatedText == Text then -- if the resulting text is different, it already indicates that translation exists, otherwise it manually searches for all entries
		local Found = false
		local Table = LocalizationService:GetTableEntries() -- list all translation entries
		for Id, Item in ipairs(Table[1]) do -- search entry by entry to know if the translation exists or not
			if Item.Source == Text then -- if there is the source text, check if there is a translation
				for LocaleId in pairs(Item.Values) do -- search for translations in all languages
					if LocaleId == Translator.LocaleId then -- if the translation found matches the player's localization
						Found = true
						break
					end
				end
				if Found then
					break
				end
			end
		end
		if not Found then
			warn(Player, 'Translation not found for\n"' .. Text .. '"\nPlayer: ' .. Player.Name)
		end
	end
end

Why would you need this behavior for this specific scenario in the first place? If it stays the same there’s no reason to know whether it was registered or not because it’s still the same exact string. Doesn’t seem very useful specifically for that case.

As in the script I put above, I need a warn to know when there is no translation registered. This makes it easy to enter translations in advance.
Before, I already made the comparison that you had suggested, if the results are the same, but as I said, if a word like Taxi has the same translation in another language, the simple comparison of the resulting values will not indicate if there is a registered translation or not.

Hey @rogeriodec_games can you share some more details on your use case? If there is no translation what do you display to the user? This API is meant to return best effort for translation so creators have less edge cases to handle explicitly.

Are you using this script to verify translations exist while working in studio?

Let me explain a little more for you to understand:
For example, an experience with the source language English might show 2 Text Labels like this:
image

Let’s say the developer made a translation to Portuguese but forgot to translate the word RED. So the experience will look like this for a pt language player:
image

In the above case, the player will get a “mixed” translation.
To make it clear to the player (and especially to the developer), it would be important to know that the translation of a certain word was not found.
This may appear in a warn for the developer’s internal use (like a Log system), or it may even appear for the player, to let them know that that word has not been automatically translated, where they can even alert the developer about it.
For example, if the script didn’t find the pt translation of the word RED, I could change the appearance of the font and background, as below:
image

In this way, it will allow proactive action by the developer to prevent missing translations from being forgotten.

2 Likes

@rogeriodec_games Do you use the creator dashboard’s localization features? You can quickly check what is not translated.

https://create.roblox.com/creations/experiences/<YOUR_UNIVERSE_ID>/localization/translation?activeTab=strings

You didn’t understand.
I’m asking Translator:Translate to return some indicator to know if the translation requested in this instruction was not found.

I understand what you are asking for but trying to see if there is a reasonable workaround for what you are trying to achieve. We are working on more translator and feedback improvements.

Thanks, I already created a workaround as describe above:

However, it is a long-winded solution, when only an additional return variable in Translator:Translate() could solve all this in a simpler way.

Another real issue for this topic, including one I’ll have to adopt right away for my game:
My game was initially developed entirely in Portuguese, and I did a complete translation into English.
But with the current limitation, a player, for example, from Holland, will receive the default interface (Portuguese), as the Dutch language is not present in the translations.
In this case, I would like English to be the official language for ALL players in languages other than Portuguese.
But with the current limitation of Translator:Translate, this will not be possible.