Introducing the Real-Time Translation API

Hey Creators!

We’re excited to announce the launch of our real-time translation API! This will enable you to generate automatic translations for text in your experience without using the standard translation workflow.

The standard translation workflow detects strings in your experience based on how frequently they’re viewed by players and adds them to your localization table to be translated. This means it may miss uncommon strings and/or strings generated during gameplay, such as dynamically-generated text or text created by players. This new real-time translation API can generate translations for these strings in real-time, ensuring that your experience is fully localized.

How to Use the Translation API

You can view the Translation API reference documentation here (link may be temporarily broken as we are working to get the page up - all relevant info should be in the post below!).

Translating Content Into the Player’s Language

You can translate text into a player’s language by passing their Player.LocaleId in as the target language code. Below is an example of how you can get the player’s locale ID in a LocalScript, and then pass it to a Script in ServerScriptService to make the translation request.

  • Note that the translation API is an Open Cloud API, meaning you’ll need a path when making a request. The only path parameter you’ll need here is your experience’s Universe ID, which can be found in the overflow menu of the experience tile on the Creator Hub Creations page. Also make sure that you have included the Open Cloud client package (the linked page is for another API, but the instructions are the exact same).
  • Additionally, all input text will be passed through the text filter before translation. If it does not pass, the text will not be translated and the API will return a content moderated error.

LocalScript:


local ReplicatedStorage = game:GetService("ReplicatedStorage")
local httpRequestFunction = ReplicatedStorage:WaitForChild("TranslateTextFunction")

-- Text to translate
local textToTranslate = "This is the example text"

-- Get the player's locale
local Players = game:GetService("Players")
local player = Players.LocalPlayer

-- get the locale ID for the local player's locale or set to any supported locale string
local locale = player.LocaleId

local translatedText = httpRequestFunction:InvokeServer(textToTranslate, locale)

print("Translated text: ", translatedText)

Server Script:

local ReplicatedStorage = game:GetService("ReplicatedStorage")
local ServerScriptService = game:GetService("ServerScriptService")
local oc = require(ServerScriptService.OpenCloud.V2)

-- Find at https://create.roblox.com/dashboard/creations in the overflow menu of an experience tile
local universeID = <UniverseID>

-- Create RemoteFunction
local remoteFunction = Instance.new("RemoteFunction")
remoteFunction.Name = "TranslateTextFunction"
remoteFunction.Parent = ReplicatedStorage
remoteFunction.OnServerInvoke = function(player, text, locale, uni)

      print(player.Name .. " requested translation for text: " .. text .. " to locale: " .. locale)

      -- Prepare the translation request

      local request : oc.TranslateTextRequest = {
            path = oc:UniversePath(universeID),
            text = text,
            -- target language codes supports a list of multiple locales to translate to.
            -- Here we are passing just one language:
            --The player locale retrieved in the local script
            target_language_codes = {locale}
      }

      local result = oc:TranslateText(request)

      if result.Error == nil then
            return result.Response.translations[locale] -- Assuming translations[locale] contains the translated text
      else
            return "Error: " .. result.Error.message
      end
end

Translation API Limits

Roblox throttles requests for this API based on the number of players in your experience. The formula for the rate limit is as follows:

max requests per minute per experience = 600 + 1.5 * # concurrent users

There is also a default Open Cloud API request limit of 150 requests per minute per game server.

Testing the Translation API

The real-time translation API currently only supports RCC authentication. As a result, you will need to deploy your code to a test instance in order to test the API from Studio. Use Team Test to deploy the script to a test instance and test your changes.

Feedback

Note that the API is still in beta, so some of the settings and limits we’ve established may be subject to change. Please let us know if you run into any issues while using the API, and as always, please let us know if you have any questions, concerns, or suggestions!

66 Likes

This topic was automatically opened after 10 minutes.

Amazing update!
I will use this in my upcoming story games, or where some kind of dialogue system is involved!
Thanks!

2 Likes

well uhhh okay… kinda decent i guess

but i dont see why to let it communicate to server, wouldnt it be the best time for exploiters to cause false string positivies so translate tab would get flooded with swears and to be in risk of possible moderation?

but its still useful i guess

2 Likes

good point, i think roblox will do something with that…

2 Likes

Hey @pumpkyrofl - this is a great callout. All input text will be passed through text filter before translation, and translation will fail if it doesn’t pass. This should eliminate the risk of creators being moderated for bad user-submitted content.

10 Likes

Why is this exposed here as open cloud API when it’s only usable by a game server? That’s a little antithetical. Why don’t we have in-engine developer-facing API for this? This is wildly unusual in comparison to the way the rest of Roblox’s API for localization and text works. This shouldn’t be open cloud if you’re not going to make it “open”. It should just be engine API.

Do we need to pass the translated result through the filter before showing it to the user?

This rate limit is not usable for much. That’s effectively a little over once per player per minute ignoring the constant.

16 Likes

Is Roblox very confident that the translation service always produces an appropriate result, and is not capable of mistranslating to an inappropriate string? This order of operations does not guard against translation mistakes.

4 Likes

You can view the Translation API reference documentation here

The API reference doc sends to a 404 page. :frowning:

3 Likes

this is very cool to see
Is this done with AI? Also does this support words that use slang?

1 Like

Wow this incredible news to hear! I do have some concerns however for the ratelimits. If you have big servers in a social quiz-like game, would the 150 a minute be able to keep up if u have multiple people not in the game’s native language looking at multiple strings a minute? If you have a community browser that has names for items, would we need to store the creator’s localeId to translate the text from? What about if a non-native speaker looks at creations from other players, would that eat up tons of requests if they go through a bunch of pages?

I wonder if different genre’s of games would get different ratelimits based on how many times they see strings?

Anyway this is incredible news and I’ll look forward to using this alongside the current translation service


Anyway, this is another (fire) update from Roblox!

This is really cool.

1 Like

Effectively 1.5 requests per minute per player seems far too low to use this for any practical applications.

Also, why is it that any time the question about moderation in regards to new chat systems comes up, it’s always: “this should eliminate the risk” and not “this will eliminate the risk”? Why can’t we be given definitive answers about how these new features interact with moderation?

Hey @PeZsmistic, super valid concerns. Addressing a few things -

Why not an engine API: We built this in Open Cloud with the intention of eventually making it completely “open.” That’s going to take some more work on our side, and we wanted to get this API out for everyone to use as soon as possible, so apologies that it’s in a bit of a awkward middle state right now.

Text filter: Input text is passed through the text filter, and the API will error if it doesn’t pass. We have pretty high confidence the machine translation model won’t translate into something inappropriate, which is why we’ve ordered it this way.

Rate limit: We hear you and others in the thread on the rate limit being too restrictive. We’re starting out small to make sure our resources can support traffic through the API, but we’re open to adjusting based on feedback as people starting using it - that’s why we’re still in beta :slight_smile: Some optimization notes from the engineering team:

  • Having multiple target locales in a request only counts as one request. So where possible, you can request translations for many languages in a single request.
  • Where possible, try to only make one request (e.g. don’t have every client make a request if you can have the server make one request and forward it to everyone)
  • Have in memory-caching on the server to reduce repeats (could just store them in a Lua map)

Hope this provides some clarity, and thank you for your early feedback!

6 Likes

Finally, translating text is as easy as filtering it!
This is an immaculate addition to the Roblox API. Lovely!!

Rate limit seems like a pain, but hopefully that can be adjusted in the future

This is great, love it. Will we see support in the future for non-specific locales? I have a system that takes in codes such as en, cn, es, pt, etc instead of their full en_US codes. Would be great if I could pass the same es into this instead of having to do es_ES or something else.

When will GenerateText become available?

I really love the idea of being able to translate text. I currently use the localization service to translate all of the non-custom text in the game, but this is great for translating player-generated text. Is there a timeline for roughly when live text translation will be an engine API?

OOHH NICE!!! ,With this we can translate text wrotten by player because this havent released in years

And what happens in the scenario that the model does translate into something inappropriate? Will developers be moderated as if it was them who put it into the game or is there some sort of failsafe/fallback that would let moderation know this text was automatically translated?