Machine Translation Module

Introduction:

Back in 2016, I made a module by the name of “TranslationService” that allows you to translate text to different languages with the Yandex.Translate API. While the source behind it is extremely simple and small, it’s free to use for anyone that wants to try it and is just here for the sake of simplicity. With Roblox starting to roll out with multi-lingual support, games are also starting to support multiple languages too. While I would highly recommend you find a native speaker for most cases due to a lack of accuracy in machine translation, this module might be necessary in some cases such as translating chat messages.

Update: This module now supports Google Translate and Microsoft Translator with temporary public keys available for use.


Usage:

TranslationService.Translate(
    string OriginalPhrase,
    string LanguageToTranslateTo,
    string LanguageToTranslateFrom, (optional, default = "en")
    string Key, (optional, default = nil)
    string Service (optional, default = "Yandex", accepts "Yandex", "Google" or "Microsoft")
) -- Returns the translated phrase

TranslationService.Languages.Google -- Returns a table of available languages with Google Translate
TranslationService.Languages.Yandex -- Returns a table of available languages with Yandex.Translate
TranslationService.Languages.Microsoft -- Returns a table of available languages with Microsoft Translator

The module accepts two letter abbreviations of a language or its full name. If I remember correctly, the Yandex.Translate public key used for the module has a limit of 10 million words to be translated per month. Although unlikely to reach this limit, you may find it necessary to get your own key from Yandex.Translate, Microsoft Translator or Google Translate, which you can then pass as the Key argument.


Examples:

local TranslationService = require(733018661)

print(TranslationService.Translate("Hello, world!", "fr"))

> Bonjour tout le monde!

print(TranslationService.Translate("This is an example.", "Spanish", "English", nil, "Google"))

> Esto es un ejemplo.


Model:

54 Likes

Amazing module, thank you so much!

This will be really handy :slight_smile:

2 Likes

Any chance of something like this for Google Translate API?

1 Like

Google Translate API costs money to use, which is why @JoshRBX used Yandex.Translate instead, which has a free plan.

2 Likes

I’ll look into the Google Translate API when I get home, but as @WhereAreTheLights has mentioned, it does not have a free plan, so using your own API key would probably have to be mandatory if you choose to use it instead of the default free Yandex.Translate option.

3 Likes

I looked on google cloud and I think its like 76 bucks an hour. I’ve went ahead and enabled it but I am unsure on how to use the json file or the key.

1 Like

The module now supports Google Translate and has a temporary public key already available for testing, I have updated the original post in favour of the changes.

3 Likes

This is great! Thanks for implementing that. I don’t even have an API key, but I’ve wanted to use Google Translate from Roblox before. I’m sure people will use it.

2 Likes

It would be cool if you also added support for Microsoft Translator Text API.
Nonetheless, this is a really nice module! :grinning:

2 Likes

I just knew that someone would suggest that, I’ve now added Microsoft Translator support to the module!

6 Likes

Amazing!

2 Likes

Pretty cool that you’re sharing this but I’m fairly 100% sure that devs can just enable auto localisation & auto machine translation on their game (and I’m pretty sure roblox use google translate api)

1 Like

This thread was posted over 2 years before automatic translations were even released, so it was a lot more useful at the time.

But I suppose it does still have a place for translating into English, translating into a much larger amount of languages, and supporting alternatives to Google Translate.

Either way, it’s just a basic API wrapper I posted here three years ago that is free-for-use if anyone finds a use for it.

1 Like

My bad, didn’t see at all thread date, kinda not used to the way it shows on this platform xD

for apostrophes, im getting &#39, which apparently means ’ in html
image

How accurate is this module? Like if you put a hundred lines in a language will the translation be next to perfect?

Do you plan on adding DeepL’s Translate? I heard it’s really good.

I doubt it. This resource was posted 3 years ago, and Roblox has since included built in translation. Not sure why this is being bumped after all these years.

1 Like