Automatic Chat Translator [UPDATED V1.1]

Due to the size of the text file, it shouldn’t have any impact on the server whatsoever. Of course, as I have said above it hasn’t been tested on a large scale, however, each translation has a size of usually about 132 bytes total, which shouldn’t cause any problems or delays.

So in the future, will we have translators all over Roblox?

Well, it depends on if Roblox adopts this scripting technique. You may have to post this in the DevForum category for Roblox Feature Requests in order to see this across Roblox. Though, Roblox could also just use localization services…

It will be cool if they do ngl.

1 Like

I’ll try to see if I can make an automatic translator for chat and automatically translate it VIA the localization settings of the user’s PC. The reason I didn’t attempt this initially was its annoying because you have to find a way to disable bubble chats without disabling them (so two bubble chats don’t appear, one being the translated message, the other being the original message), and stop a player’s chat message from reaching the chat box while also mimicking them and posting the new translated message to the users chat. You also have to do this for every client, and every chat message, which is quite a few HTTP requests. I’ll see what I can do tomorrow, wish me luck.

It’s funny because I’m making a game that is focused on localization (as it teaches English and/or Spanish / the user’s preferred language). What API do you use for translating? Roblox Localization or something entirely different?

My version uses Google’s Translate API and grabs the response., I’m patching out the kinks right now, give me about 30 minutes and I’ll post the new version which translates chat. It has downsides, but I think it works well. I also added comments about how each part works should you desire to use it.

How much does Google Translate API cost? I’ve thought about using it in the past, but I wasn’t sure if it would cost a lot to use.

It doesn’t cost anything, its an open source API, if you’re referring to game costs its minimal at best, Roblox automatically stops HTTP requests if 500 are sent per minute, so it shouldn’t lag at all. Heres

the usage if you want to use it:

In a module script:

local languages = game.HttpService:JSONDecode(game.HttpService:GetAsync(“https://pkgstore.datahub.io/core/language-codes:language-codes-full_json/data/language-codes-full_json.json”))

translator = {}
function translator.getLanguageAbreviation(name) – Goes through the languages local and finds the Alpha2 abbreviation

print("Attempting Language")

name = string.lower(name)

for i,v in pairs (languages) do

	if string.lower(v["English"]) == name or string.lower(string.split(v["English"]," ")[1]) == name..";" or v["alpha2"] == name then
		return(v["alpha2"])
	end
end

end

function translator.translate(targetlanguage,Query)

local Language = targetlanguage

local http = game.HttpService:JSONDecode(game.HttpService:GetAsync("https://translate.googleapis.com/translate_a/single?client=gtx&sl=auto&tl="..Language.."&dt=t&q="..Query))
return(http[1][1][1]) -- Returns the request, hopefully returning a result

end

return translator

In a server script:

local Translator = require(script.Translator)

print(Translator.Translate(“es”,“Hello World”)) – Will translate “Hello World” to spanish and print it

(Sorry for poor formatting, super new to the dev forum)

1 Like

Thank you! For some reason, I always thought Google Translate and Google API weren’t free.

1 Like

UPDATE PUBLISHED: Instead of it being a tool, its now capable of translating Chat Messages and Bubble Chat Messages for all clients. Please report any issues. You can get it simply by getting the “Chat translator” model and putting the autoupdater into workspace/serverscriptservice/anywhere

I’m going to try to stop it from translating english to english and so on to prevent a massive amount of HTTP requests, however please expect possible issues with extremely large servers as the method it uses is still a work in progress, aswell see if I can make a module of translated messages that goes away after a bit (to hopefully reduce the http count from the amount of players in the server to one per language).

(I also made an autoupdater to simplify everything and make it so you don’t have to constantly readd the script)

(Added a system that remembers the translations, so it doesn’t have to send 50 http requests per player, and instead is only about two, language detection system will be added soon hopefully)

Does it support text to speech?

Yes, it should speak properly if your computer has TTS enabled, as its the same as a regular chat message in most ways. If you’re referring to text to speech in a game such as outpost 84 where people can hear you - the most it would probably do is say the message in the language it was from. It would need to be modified to work.

I’m saying as in Outpost 84 tts, but much more advanced and modified so that it can pronounce words in different languages. Also, you can get what language preference they have and the tts will adapt for them.

1 Like

…Yeahhhh, while yes it would be possible, it would be very nightmarish to achieve due to what you need to do. All the vowels need to be uploaded to ROBLOX, they need to be able to be used by anyone (which is a process not even I am sure how exactly how achieve), and you have to get all of the unique vowels of every language and stick them together including the unique ways specific words are said, that’s not even going into possible safe chat bypasses with it. And then finally, you have to figure out a way to somehow make it say the words coherently.

Honestly, I would love the challenge of making a system that can achieve that, however, I don’t intend to add that kind of system to the translator. My best recommendation would be to get a premade TTS, grab the main module of the Translator (https://create.roblox.com/marketplace/asset/12520251098/ChatTranslatorAutoUpdate), and make the TTS fire on the translation event. Perhaps a project for a rainy day, though.

(That, or i’m just overthinking it)

1 Like

Maybe tts won’t be such a good idea.

I think Roblox’s new chat system may of broken this. I’ll do some more testing but I think because of the way it now works i’ll have to recode it. (No clue if I even can, i’ll see what I can do)

Script broken for the new Chat System. While its possible to fix i’d have to find different methods as specific parts like Plr.chatted are unable to be called from localscripts anymore (I don’t know why, but theres probably a better method).

To continue using this script, please change your Chatversion to LegacyChatService from TextChatService > Chatversion in your explorer.

This is a really useful script.

Is there a way to get the translated message text? Something similar to how the Player.Chatted event returns the message string? Also is there a way to disable the translations one one client but still have it on for other clients?

I was able to figure this out using the source code model. Thank you!

1 Like