FilterAndTranslateStringAsync() is a function of TextService. It is used to filter text and translate it between two languages. You’re correct in your assumption that this is an obscure function; there’s no documentation on it in the Developer API.
However, we can see that it exists by viewing it in the Object Browser inside Roblox Studio:
The Roblox API github tells us that this function was added 2023-05-17 11:55
so it is very very new:
It is so new that Roblox hasn’t even made a DevForum post about the new features!
(The update that adds this new feature is 576)
Anyways, I set up a script
to check it out and noticed that it returns a TextFilterTranslatedResult
instance:
local PLR = game:GetService("Players")
local TXT = game:GetService("TextService")
PLR.PlayerAdded:Connect(function(plr)
plr.Chatted:Connect(function(msg, recipient)
local filteredTranslate = TXT:FilterAndTranslateStringAsync(
msg,
plr.UserId,
{"en-es"},
Enum.TextFilterContext.PublicChat
)
print(filteredTranslate)
end)
end)
From there we can see that TextFilterTranslateResult:GetTranslations()
is not an array, but a dictionary!
So before trying to decode the dictionary, I checked out TextFilterTranslatedResult.SourceText:
print(filteredTranslate.SourceText)
As you can see from the output, the source text is not a string, it is a TextFilterResult. So I looked at the Object Brower reference for that and found GetChatForUserAsync(userId):
print(filteredTranslate.SourceText:GetChatForUserAsync(plr.UserId))
But this only gives us a string in our source language, English. We probably want to get the string in our target language; in this case, Spanish.
Going back to TextFilterTranslatedResult again:
It verifies that the returned data is a dictionary. However, there is no more information about it. You could have stumbled on a function that has little to no functionality yet due to its brand-new nature.
I hope this steers you in the right direction! Check the #updates:release-notes page later on, to see if they add documentation for it in version 576.