Localization: reaching other languages

Translate a Roblox game. Learn the localization table, automatic text capture and translation, parameters for dynamic text, Translator and FormatByKey in code, and how to test a second language in Studio.

Tool lesson, about 70 minutes, 10 steps

By the end you can

  • Read a localization table by its columns and say what Source, Context and Key are for
  • Turn on automatic text capture and automatic translation, and say what they will not translate
  • Rewrite a dynamic string as a key with a parameter and format it through a Translator
  • Test a second language with the Player Emulator, using Locale, Pseudolocalize and Elongate

Before this: Publishing: versions, rollback, store page, UI fundamentals: ScreenGui, UDim2, layouts

Step 1 of 10

English, written into the code

Open Beacon Yard's HUD in a game running for a French player. It says Go to the beacon and hold E to start the drill. The text is in the script:

	local IDLE_OBJECTIVE = "Go to the beacon and hold E to start the drill"
	local ACTIVE_OBJECTIVE = "Survive and collect coins, swing the wrench at the drone"
 
	local function renderClock()
		local remaining = math.max(0, endsAt - workspace:GetServerTimeNow())
		if phase == "Active" then
			phaseLabel.Text = string.format("Active  %.1fs", remaining)
			objectiveLabel.Text = ACTIVE_OBJECTIVE
		elseif phase == "Cooldown" then
			phaseLabel.Text = "Cooldown"
			objectiveLabel.Text = string.format("Next drill in %ds", math.max(0, math.ceil(remaining)))
		else
			phaseLabel.Text = "Idle"
			objectiveLabel.Text = IDLE_OBJECTIVE

Roblox players come from many countries and speak many languages1. Every string above is English for all of them. Some lines are worse than they look: Next drill in %ds is built with string.format, so the finished sentence changes every second. A table of fixed sentences cannot hold it.

Roblox Studio
Beacon Yard's HUD at the top left of the viewport, reading Coins 485, Idle, and an objective sentence telling the player to hold E at the beacon.

Select a numbered pin, or a row below, to read what it marks.

The HUD in Idle. Every piece of readable text here is English, written by the script.

Choose all that apply

Which pieces of the HUD in the picture are text a translator should handle?

Which pieces of the HUD in the picture are text a translator should handle?

Press 1 to 4 to choose, Enter to check.

Link to this step · This confused me

Step 2 of 10

The localization table

Roblox's answer is a localization table stored on the cloud for your game2. Each row is one piece of text, with these columns:

ColumnWhat it is
SourceThe text in your source language. Required.
ContextOptional. Names the object the text belongs to, so two uses of the same word can translate differently.
ExampleOptional note for translators.
KeyOptional. A name your code can look up with Translator:FormatByKey.
LocationFilled in for you when a string is captured automatically.

One rule keeps it sane: no two rows may share the same Source and Context, and no two may share a Key. You set one source language (Roblox supports one at a time) and pick the supported languages you want to add1.

Client sideThe localization table is a phrasebook with a key on every line.
In the pictureIn Roblox
A line in the phrasebookOne row of the localization table
The number beside the lineThe Key that code looks up with FormatByKey
The same line in another languageThe column for a supported language

See the whole analogy cast

The table is a phrasebook with a key on every line. The game says "show me line 12 in Spanish" and the book gives back the Spanish sentence.

Think of it as A phrasebook with a key on every line

Match the pairs

Match each column to its job.

Link to this step · This confused me

Step 3 of 10

Let Roblox collect and translate

You do not have to type the table by hand. Automatic text capture collects text from UI objects as players (or you, in Studio) see it, and adds it to the table. Automatic translation then fills in blank entries for the languages you turned on3.

The steps:

  1. Creator Hub, your game, Audience, Localization: set the source language and add supported languages.
  2. Under Settings, turn on text capture, and turn on Use Translated Content.
  3. Under Languages, enable automatic translation for each language.

Three things to know. Automatic translation only fills blank entries and never overwrites a human translation. Manual translations are always shown to players, whatever their own setting. And it has quotas, counted per character and per language: translating "hello" into 10 languages counts as 50 characters3.

Capture only sees text objects whose AutoLocalize property is on. Switch it off on anything that must stay as written, such as a player name or a street sign3.

Work it out

How many characters of automatic-translation quota does it use to translate the string Idle into 3 languages?

characters

Link to this step · This confused me

Step 4 of 10

Dynamic text needs a parameter

Capture works on strings it sees. Next drill in 7s and Next drill in 6s are different strings, so a naive table would need a row for every number, forever. The fix is a parameter: one row whose Source has a named slot, written in braces with an optional format specifier4.

KeySourcefr
Hud_NextDrillNext drill in {Seconds:int}sProchain exercice dans {Seconds:int} s

int prints a whole number without separators. Other specifiers include num (two decimals with thousands separators, for example 1,234.50 or 1234,50 depending on the language) and translate, which looks up another string4.

The code asks for the key and passes the values. You can test the idea in plain Luau:

Luau
Ctrl Enter runs the cell. Checked against the expected output

This is a toy of what FormatByKey does for you, including every specifier. It also shows the real point: the number and the words travel separately, so each language can put them where it wants.

Choose one

Why use one entry with {Seconds:int} instead of building the sentence in code and translating the pieces?

Why use one entry with {Seconds:int} instead of building the sentence in code and translating the pieces?

Press 1 to 4 to choose, Enter to check.

Link to this step · This confused me

Step 5 of 10

Where the phrasebook picture breaks

Client sideRemember: The localization table is a phrasebook with a key on every line.

A phrasebook only has sentences someone wrote down. A game builds sentences while it runs.

Where does it break?“A phrasebook with a key on every line” is a good picture of the localization table. Where does it stop being true?

It breaks here. A phrasebook only holds sentences someone wrote in advance, but a game builds sentences while it runs, such as a countdown with a changing number, a player's name or text a player types, none of which are lines in the book.

The true model. The table holds the strings you know ahead of time. Dynamic text uses a parameter slot in one entry so each language can place the value. Text players write or names should not go through the table; a real-time translation API exists for generated text and is in early development.

So a finished string like Next drill in 7s is not in the book, and neither is player-written text or a name. Free text needs a different tool: the real-time translation API, an Open Cloud call that translates a string on demand. The documentation marks it as early in development and subject to change5.

Choose one

Which of these can a localization table handle well?

Which of these can a localization table handle well?

Press 1 to 4 to choose, Enter to check.

Link to this step · This confused me

Step 6 of 10

Translate in code

For text a script sets, ask for a Translator. LocalizationService:GetTranslatorForPlayerAsync(player) yields and can fail, so wrap it in pcall and keep an English fallback6:

luau
local LocalizationService = game:GetService("LocalizationService")
local Players = game:GetService("Players")
 
local ok, translator = pcall(function()
	return LocalizationService:GetTranslatorForPlayerAsync(Players.LocalPlayer)
end)
 
local function nextDrillText(seconds: number): string
	local whole = math.max(0, math.ceil(seconds))
	local english = string.format("Next drill in %ds", whole)
	if not ok then
		return english
	end
	local good, text = pcall(function()
		return translator:FormatByKey("Hud_NextDrill", { Seconds = whole })
	end)
	return if good then text else english
end

Two more details. FormatByKey throws when the key is missing, so it needs its own pcall too. And when a player changes language mid-game, a script that cached the translator should listen to the translator's LocaleId change and redraw6.

Find the broken line

This HUD code can break the whole HUD for one player. Which line is the risk?

This HUD code can break the whole HUD for one player. Which line is the risk?

Press 1 to 5 to choose, Enter to check.

Link to this step · This confused me

Step 7 of 10

Test a language without leaving Studio

You do not have to change your Roblox account language to see a translation. Studio's Player Emulator (Test menu, then turn on Enable Test Profile) has three options for this7:

  • Locale emulates a language while you playtest.
  • Pseudolocalize swaps letters for look-alikes, so Bloxy Cola becomes something like ßℓôж¥ Çôℓá. Any text that stays plain English is not going through the translation system.
  • Elongate lengthens strings by a percentage you choose, to show where a longer translation will overflow a button.
Roblox Studio
Studio's Player Emulator window opened from the Test menu with Enable Test Profile on, showing the Locale, Pseudolocalize and Elongate options.

Select a numbered pin, or a row below, to read what it marks.

The Player Emulator with the test profile on.

Build along

m06-drone-wrench

  • src/client/Hud.luau
  • src/client/ShopGui.luau
  1. Open the Player Emulator from the Test menu and turn on Enable Test Profile.

    You should see Output and the HUD look the same as before; Enable Test Profile shows as on.

  2. Turn on Pseudolocalize and press Play.

    You should see The HUD labels and shop buttons now show look-alike letters. Any label still in plain English is not being translated.

  3. Turn Pseudolocalize off, set Elongate to 50 percent, and press Play again.

    You should see Shop buttons such as Speed or Shield, and the objective sentence, get longer. Note which ones clip or wrap badly.

  4. Add one French entry for the Idle phase and choose French (fr-fr) as the emulated Locale. For a published game, add the row under Creator Hub, your game, Audience, Localization; to test locally in Studio without touching the cloud table, insert a LocalizationTable under LocalizationService in Explorer and add a row with Source Idle and French translation En attente.

    You should see With a French translation entered for Idle, picking French (fr-fr) in Locale shows it in the HUD.

Roblox Studio
Beacon Yard in Play with Pseudolocalize on: the Quartermaster shop title and buttons show look-alike letters, while the HUD at the top left still reads plain English Coins, Idle and the objective sentence.

Select a numbered pin, or a row below, to read what it marks.

With Pseudolocalize on, translated labels change. The plain English HUD text is not going through the translation system.

Choose one

With Pseudolocalize on, the shop title shows look-alike letters, but the Coins label still reads plain Coins. What does that tell you?

With Pseudolocalize on, the shop title shows look-alike letters, but the Coins label still reads plain Coins. What does that tell you?

Press 1 to 4 to choose, Enter to check.

Link to this step · This confused me

Step 8 of 10

How studios localize

Other ways pros do this

OptionWhat it isWhen pros pick itTrade-offs
Automatic text capture and translationRoblox collects strings and machine-translates blank entries.Early on, small teams, and long-tail languages.Quality varies, monthly quotas apply, and it misses dynamic and player text.
Manual translations in the tableYou or translators add entries in the Translator Portal or by CSV upload.Your top languages and anything with tone, jokes or brand terms.Slower and costs money or time; always shown to players.
Work with translatorsInvite native speakers as collaborators on the localization table.Languages that matter to your audience.Needs briefs, context notes and review.
Real-time translation APIAn Open Cloud call that translates a string on demand.Player-written or generated text, if you accept the preview status.Early in development and subject to change; needs a server round trip.
Put in order

Order the localization work for a new game.

  1. Replace machine translations in your top languages with human ones
  2. Turn on automatic capture and translation for a few languages
  3. Check the layout with Pseudolocalize and Elongate
  4. Move HUD strings into keys, with parameters for numbers

Link to this step · This confused me

Step 9 of 10

Challenges

Level 1, Apprentice

Challenge

List what a translator would have to handle in the HUD and the shop.

Start from
The game at milestone m06 (download)

Done means

  • A list of every English string the HUD and shop create
  • Each marked as a fixed sentence, a parameter string, or data only

Meet the criteria above, then record your own result. No test grades this check.

Level 2, Builder

Challenge

Run both emulator tests on the shop and write up what broke.

Start from
The game at milestone m06 (download)

Done means

  • A screenshot or note for each of Pseudolocalize and Elongate at 50 percent
  • A list of every label that stayed English or clipped

Meet the criteria above, then record your own result. No test grades this check.

Choose one

Why test with Elongate before you have a single translation?

Why test with Elongate before you have a single translation?

Press 1 to 4 to choose, Enter to check.

Level 3, Professional

Challenge

Start from the m14-ship tag in the game repo, then make the countdown translatable in challenges/localization_work.luau. The test uses a fake translator, so no published table is needed.

Press Play and run this in the server command bar:

luau
game.ServerScriptService.RunGameTests:Invoke("localization")
Start from
The game at milestone m14 (download)
Grade it
In Studio, press Play, then run game.ServerScriptService.RunGameTests:Invoke("localization") in the server command bar. Copy the pass code from Output.

Done means

  • nextDrillText asks the translator for Hud_NextDrill with a Seconds parameter rounded up
  • It falls back to the English line with no translator, and when FormatByKey throws
  • A late tick shows 0, never a negative number
  • challenges/localization.luau prints TEST PASS for all seven cases

The Course Runner prints this code when the test passes.

Link to this step · This confused me

Step 10 of 10

Recap

Retiring the analogy

You no longer need “a phrasebook with a key on every line”. The table holds the strings you know ahead of time. Dynamic text uses a parameter slot in one entry so each language can place the value. Text players write or names should not go through the table; a real-time translation API exists for generated text and is in early development.

Recap

  1. The localization table has a row per string: Source, optional Context and Key, and Location from capture.
  2. Automatic capture and translation give a quick first draft; human translations always win, quotas apply per character and language.
  3. Use parameters for dynamic text, pcall every translator call, and test with Locale, Pseudolocalize and Elongate.

The localization table is a phrasebook with a key on every line, until a phrasebook only holds sentences someone wrote in advance, but a game builds sentences while it runs, such as a countdown with a changing number, a player's name or text a player types, none of which are lines in the book.

Next LiveOps: updates, events, feature flags, migrations

Link to this step · This confused me