Automatic Chat Translator [UPDATED V1.1]

AUTOUPDATER ADDED: SEE MODEL FOR SOURCE CODE https://create.roblox.com/marketplace/asset/12520251098/ChatTranslatorAutoUpdate (Incase you want to make sure it isn’t a virus or whatever, or just don’t want it to automatically update)

INSERT THIS INTO YOUR GAME, NOT THE SOURCE CODE ABOVE: Chat Translator - Roblox

[DEPRECIATED. TO USE, YOU MUST GO TO TEXTCHATSERVICE > PROPERTIES > CHATVERSION AND SET IT TO LEGACYCHATSERVICE.]

I got annoyed at the localization service and decided to make an automatic chat translator. It uses HTTP Requests and googles API to automatically translate chat and bubble chat messages. While its not as accurate as a native speaker, it still does amazingly compared to no translation at all (The language barrier is super annoying in some communities). It also automatically changes the message depending on what language the player has their ROBLOX Language set to.

English To Spanish:

Spanish to English:

(No, it does not translate the message for the user who sent it, these gifs are just to show it working.)

Please report any bugs and issues to me so I can deal with them.

Credits to sloss2003 for the translator module itself, while yes I made specific modifications, I probably wouldn’t have been able to figure out how to do this without the help of it.

PLEASE NOTE: WHILE THIS SCRIPT DOES DO A DECENT JOB AT BYPASSING THE LANGUAGE BARRIER (which is better than nothing), THIS IS STILL NOT AS ACCURATE AS A NATIVE SPEAKER. SPECIFIC TRANSLATIONS MAY BE INACCURATE, PLEASE CONSIDER ITS USE WISELY.

For a more comprehensive list of drawbacks please refer to the following below:

– Chat colors can only be white (unless you want to change it to a solid color or be smarter than me and figure out a way)

– Normal chat messages cannot be used as this sytem utilizes system messages. It was made this way to stop the original chat message from being broadcasted, and because speakers (players) cannot be mimicked through localscripts, which is required as it translates uniquely for all clients.

– might be laggy if roblox is running slowly

(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, i’ll also add a system to stop it from translating to the language the player sent it in whenever I can figure out an effective way to grab the language data from the client and send it to server through a remote event or something.)

Update 1.1: Settings added to autoloader script.
Translation Type (true or false): if set to true, it will stop translations of languages to languages. Example: it will not translate english to english nor spanish to spanish.-
Log Mode: (true or false): prints what its doing.

Further Modifications to hopefully add more information for the user added.

17 Likes

Wait so this uses http service I’m assuming?

Yes, it uses HTTP service to send data to googles translate API.

If there are too much people in the server, will the system get overloaded to try and translate every message?

(V1, DOES NOT USE A MAGNITUDE SYSTEM ANYMORE) Good question, it uses a magnitude system so if a player is 15 studs away it won’t translate. It could possibly overload depending on the amount of users chatting near it or if Roblox is running slowly, but I haven’t tested that yet.

Wow, this is really cool!
Rather than saying /addlanguage Japanese though, I think you should make a UI to change the language to translate to. Otherwise, I feel this is a really cool idea.

1 Like

That’s very possible, however, I’m not good at UI design so I just decided to do that. It could be easy to add though.

Inside the tool is an instruction manual on all of the languages it can translate to as well as their alpha-2 codes. You could put those in a scrolling UI or something, and have a player click on it to add it to the table, or even just ditch the table and click system entirely and make a search bar with all the languages. Regardless, appreciate it!

Will it cause server crashing if someone is spamming?

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?