GoogleTranslateLib - A Google translation API/Library for Roblox

GoogleTranslateLib - A Google translation API for Roblox.

So while I was doing an assignment one of the key things was that the character would speak different languages. I’ve completed the assignment and I’ve decided to make it into a full library.
My use was very simple. It was to translate chat messages in real-time. The translation didn’t have to be accurate. I just wanted to make the player speak different languages so that it isnt the same text over and over.
But maybe you guys can find a good use for it?
Also this is my first library I’ve ever written. So feel free the leave tips so that I can improve it.

Installation.

To install the library get the module from GoogleTranslateLib - Roblox
And put it wherever you’d like.
To be able to do ANYTHING with the library in a script you have to call:

local API = require(LOCATION.TO.MODULE)
API.Init("YOUR API KEY HERE")

This will change the API key in the script and allow it to call the translation services.
If you do not set this you will get an error.

Documentation

API.Init("APIKEY")

Arguments: API key. (String)
Returns: None.
Description: Sets the API key in the script.

API.Translate("source", "target", "text")

Arguments: Source language of the translated text, language the text is translated to and the text being translated. SOURCE AND TARGET LANGUAGE NAMES HAVE TO FOLLOW THE ISO-639-1 CODES. List of ISO 639-1 codes - Wikipedia
Description: Translates the text.
Returns: Translated text. (String)

API.DetectLanguage("text")

Arguments: Text.
Description: Detects language of text and returns it’s ISO 639-1 code.
Returns: ISO 639-1 code. (String)

API.GetLanguages()

Arguments: None.
Description: Returns a table of all ISO 639-1 codes that google is able to translate.
Returns: Table.

14 Likes

I wouldn’t recommend going with google to translate your games. Google isn’t that accurate, and sometimes it might use inappropriate words to use in a translation, which breaks Roblox’s rules. With my experience as a translator and non-native English speaker, it’s best to hire someone to do your translations.

9 Likes

As I said before. It was only to translate messages in real-time. And in my implementation there was a filter in there that would tag innappropriate words before sending a request to the API.

Would I need to be getting an API key through Google? If so, how much money would I really be looking at spending if I am sending a very large amount of API requests?

Or just visit their website directly:

Personally speaking I think I am going to avoid it. My use case would’ve been for chat translation, and that would’ve entailed API calls for every message sent in the game by every single player. So the amount of API calls I could me making could vary so greatly.

1 Like

But what if google translate adds inappropriate words? You’re filtering the original text, not what google translate returns.

1 Like

I don’t think this is possible. I know that google translate is kinda funky sometimes but its not as broken to the point where it would translate filtered text (you have to filter it yourself btw) to swears. Its close to impossible. Plus even if it does that then probably no one would understand it. (unless youre translating to english)

1 Like

Still, google translate is unpredictable and you shouldn’t be taking any chances. (plus, correct me if i’m wrong but you’d be required to filter it anyways due to roblox’s rules on filtering)

There’s lots of people who don’t speak english/know multiple languages that play Roblox.

1 Like

Yes it is unpredictable. But it’s not unpredictable to the point where it would translate innocent / normal words into swears. That doesn’t really make much sense.

Is there a reason you believe this? You’ve said it’s impossible, but you haven’t stated why you think it’s impossible. Google Translate is a black box, unless you worked on it, you won’t know what the output will be, or what it can be.

However, regardless of that, you are required by Roblox’s ToS to filter the result of the API. Filtering the input doesn’t mean anything if it’s different from the output. Any text not approved by the developer (player input) should be filtered before being shown to other users.

4 Likes

To give credit where its due, its a pretty cool idea, and cool to see real-time translation

Although as many have already said, Google Translate is rather funky. But as an experiment, very cool

3 Likes

That is false. I worked on some games that used Google translate where normal phrases were sexualized by Google as well as have friends in the field who can attest to that. You shouldn’t be flaunting opinions around if you can’t back then with evidence.

5 Likes