A Unity localization system from a developer’s perspective
Article languages: English and Russian
Contents
What this article is about
We built a localization system. Here is how it works and why we chose to build our own rather than use an existing solution.
Some time ago, Alexander Shtachenko and I wrote an article on the subject, http://progamedev.net/localization/, focusing on general issues. This article is more about our own solution.
Who will find this useful? People planning to develop a localization system or write its specification; people choosing an existing localization system for their project who do not know what to look for; and people who want to fix localization-related processes but do not yet know what needs attention or how to fix it.
How it all began
In 2005, we sent the Dawn of Magic localization kit out for translation. Four localization teams translated it into 13 languages in total. Changes naturally arose during the process, and we had to synchronize different kit versions from different teams. Part of the credit for getting the game translated and released at all belongs to the excellent people at our publisher, Deep Silver, who were doing LQA themselves in parallel. They were a pleasure to work with overall.
Here is a brief list of the problems we encountered:
- New text being replaced with an already-translated older version.
- Translators finding errors of meaning in the original, requiring revisions.
- Rows shifting by one during copying, breaking all the text; finding the cause took a long time.
- Some rows not making it into an updated kit because they had been inserted in the middle and nobody noticed. There was a LOT of text.
- Confusing kit versions and inserting the old one instead of the new one.
- Excel, where we stored localization data at the time, glitching because of some character and changing the encoding when exporting the CSV used by the engine.
- Several people editing the file in SVN. Merging color-coded XLS files was not much fun: conflicts had to be resolved by manually comparing the files. XLSX and decent Excel merging did not yet exist.
- And a great many other problems.
Defining the task
When I eventually decided to build a localization system at my own studio, I tried to account for all these problems while preparing the specification. We wrote down what we needed to be able to do—typical workflows—and what we definitely did not need. In parallel, we studied all the localization systems then available for Unity and, to some extent, the web, to avoid reinventing the wheel. Only then did we start building our own.
Who the tool is for, and what problems it solves
The localization system we built is primarily for developers. It is NOT for translators. That is why it has no translation memory, repetition counting, cost estimation or other features used by translators.
Nor does it handle content delivery: CDN uploads, build versions and so on belong to a different system.
What it does:
- Lets us add and edit keys.
- Lets us send text for translation and import translations into the game.
- Displays text in the selected language, returning values to code in the required language with all substitutions applied.
- Checks errors that can be detected without human involvement and fixes them where that can be done automatically.
What we will not need
- Multiple source languages. We planned to write all text in one language initially and then translate it into all the others. Multiple source languages might be needed for user-generated content, for example, when add-on authors can write in any language.
- We immediately decided that we did not need component-based text substitution. What does that mean? A script is attached to every text component and automatically replaces and updates the text. We did not like this approach, because we did not want text changed on every update when it was unnecessary: performance problems and a lack of control. Instead, all fields were updated from code in response to events, when needed. References to the required text fields were populated in the constructor.
An example of the component-based approach:
![]() |
An example of assigning text from code:
| button.text = LL.get_text(“mybutton.text”); // The required text fields in the window prefab are exposed as public fields in the window class and populated in its constructor. They are updated in the window update when something changes, or in their own update when necessary. |
- Formulas directly inside localization text. By formulas, I mean taking n variables and writing something like “{current_health}/{max_health}*100%” directly in the locale, expecting it to output a percentage rather than the values separated by a slash. We considered this an unhealthy example of the programmer way that would confuse translators. We also concluded that automatic error detection would be difficult in this case. Such things belong in code, not localization.
Typical tasks
- All text values are accessible through meaningful textual keys—technical names—in a Dictionary <key, value>. By then, we had suffered enough from meaningless numeric IDs on a project we published with Disney and decided not to repeat the mistake.
- We stored all project data in Git, so resolving conflicts mattered: several people might edit the same file, sometimes in the same place. We also needed to store UTF-8 data in different languages in one file. That left two human-readable formats, XML and JSON. We chose XML because we already read configuration files from it. Binary formats are inconvenient to merge, so we did not use them for storage.
- We decided to split files by semantic groups rather than language, since updates generally ship with all language translations at once anyway. For example, changing keys in the Interfaces section would modify only the interface file. Splitting by language is more convenient when users should be able to add their own language as a separate file instead of editing the shared kit. We decided it would be easier to add overrides later if necessary; so far, it has not been necessary.
- We immediately decided that text needed substitution parameters. A typical example: “Player {killer_name} killed player {target_name}. {killer_name} received {reward} as a reward.” All parameter names were meaningful too, rather than “%1,” giving translators more context.
- Typical actions:
- Add a new string.
- Replace a string’s text.
- Find every string requiring translation.
- Send them for translation.
- Receive translated text.
- Check that nothing is technically broken—for example, that the number of parameters matches.
- Find any errors and send the affected strings for translation again.
- Save them into the game.
- In real life, all these actions can happen in ANY order, which creates plenty of problems. I will explain our solution below.
- Automatically check everything that can be checked automatically.
- When working on interfaces, translations often did not fit their allocated fields. In German, for example, a whole sentence can be represented by one word, and word lengths can differ by a factor of three or four across languages. We solved this by introducing a separate “longest” language: it selects the longest phrases from the entire localization kit and inserts them into the interface. QA thanked us.
- We wanted the application’s language to be selectable both manually and automatically—for example, from the user’s GEO when available. When a translation into that language is missing, we choose the default language, usually English.
- Some languages were not fully translated yet, so we needed editor flags indicating which languages should ship and which were unfinished and should not be released. This allowed us, for example, to keep 15 machine-translated languages for testing UI field sizes alongside four properly translated primary languages.
- To automatically synchronize different kits, we added versioning to every string and every translation. This eliminated manual checks and some of the problems described earlier.
- We wanted to limit text length—for example, for the application’s name and store description.
- We wanted to give translators as much context as possible and help maintain consistent names, without using substitutions where they were unnecessary, because that harms translation quality. We added a comments field that could include arbitrary comments and links to related keys, as well as the text-length limit. A translator could then find the relevant stat, item or character and understand what the text referred to.
- We wanted to control what entered the game’s localization kit and avoid committing obviously incorrect changes. This required access permissions and designated people responsible for importing changes.
- We did not want translators translating every piece of text currently in the game. Some text might not be final, and there is no point spending money to translate debug text.
- We wanted to deliver text in a convenient format. Most translators were comfortable with Excel or Google Sheets; we chose the latter. However, storing and synchronizing game data there is extremely inconvenient.
- Code generation. For some strings, generating methods is convenient and saves a lot of unnecessary code. We implemented class generation with such methods for strings that needed them.
- Folding. We wanted related keys together and the ability to collapse them. We agreed that a dot in a key’s name would be a separator. For example: “interface.options_window.tab_sound_settings.” That makes all the keys for a particular window easy to find, and they appear together in the exported table.
- Checking whether multiple lines are allowed in a particular string. We decided that manually inserted line breaks should be checked for matching counts across all languages. A non-breaking <nobr> tag can also always be added.
Pseudolocalization
Pseudolocalization is a way to test an application’s localization early in development, before actually translating it into other languages. It consists of generating machine-translated text and substituting it as the current language. This reveals problems that may occur when real translations are inserted.
Typical problems it can help identify:
- UI size constraints: areas where translated text may not fit, causing ugly wrapping or truncation.
- Unlocalized strings: hardcoded strings that do not use the localization system.
- Combinations of separate sentences or paragraphs arranged in ways that will be difficult to localize. Programmers often do this while trying to optimize something and “make translators’ lives easier.”
- Encoding and font problems: make sure the fonts support all characters required for each language, and that those glyphs have no design issues—for example, being borrowed from a different font and looking out of place.
- Right-to-left writing problems: a right-to-left, RTL, interface should mirror the left-to-right layout.
- Unlocalized images, such as textures containing text.
Ideally, the localization system should address most of these problems and allow pseudolocalization at any stage.
We can easily obtain machine translation using the =googletranslate function in an export. We also support importing strings as non-final and fixing many small errors that arise during machine translation, such as extra spaces or replaced underscores.
For interface testing, we added the “longest” language, allowing the interface to be tested once rather than several times.
A separate utility checks whether fonts contain the necessary glyphs.
The developer-side translation workflow
About half the problems we encountered localizing Dawn of Magic can be avoided with two simple actions: version the text and separate text stored in the game from text sent for translation.
Approaches: editing with and without an export
There are two approaches.
- The first allows translations to be edited directly in the editor.
- The second prohibits all changes except to the source language. All translation work goes through translators, with content exported to Google Sheets. The first approach offers speed and simplicity; the second provides greater control.
We use the second approach. Every change to the localization kit’s source language—the language from which everything is translated—must be exported for translation or review and imported back after the translator checks or corrects it. Every string has a translation version that increases when the source-language text changes. This also solves the problem of multiple kit versions and their synchronization.
We also added the ability to import translations as temporary. We can export the source language, use Google Translate to translate it into ten languages, import them as temporary translations, and play with poor translations. When we export “what needs translating,” all of those strings will be included every time. The es-old column contains the outdated—or simply previous—Spanish translation; a translator can translate it properly and enter the correct value.
Localization keys and code generation
In addition to basic key access, we use C# code generation for Unity3D to make localization more convenient from code. Each string has a Static flag. When it is enabled, a method is generated in a class. Missing strings of this kind cause compile-time errors, letting us check that an important string—for example, in the interface—has not been deleted or renamed.
There are two kinds of strings: static and ordinary. Ordinary strings are accessible only by technical key, GetTextById(”…”). Static strings generate code and can also be accessed through a method. Accordingly, if the code calls LL.interface_block_window_button_reload() and the key no longer exists, the build simply will not compile.
All keys have meaningful names separated by dots. The editor groups and folds them at the dots, automatically creating nested groups. For example, interface.* keys are all in one place. Within interface., keys are grouped by window, such as interface.window_shop.*, keeping all keys related to that window together.
For temporary keys, we create a single static LL.not_localized(”…”) in advance and write all temporary text that way. Finding and replacing unlocalized text in code later is very easy.
Every string can have comments for translators and anyone else working on the text. These can link to other strings, so the translator knows which item a dialogue refers to; limit the character count; or simply say, “This message appears when there is not enough soft currency.” During code generation, these notes become method documentation. During kit export, they go into the comments column.
Each key has:
- A technical name, the key.
- A Static flag.
- A comment for translators.
- A character limit; 0 means no limit.
- A list of linked keys, added to comments during export.
- The current text version for every language. For the source language, it increases with every edit. We use even versions as temporary and odd versions as final.
- Translations into every language, each with a version. Translation versions increase when translations are imported, taking their value from the source-language version in the exported kit.
For example:
- We had a string whose source version was 5 and whose English translation version was 1.
- We exported it and sent it for translation.
- Then we edited it several more times, bringing the source version to 9.
- When the translation is imported, translation 1 is replaced by translation 5.
- At the next export, it goes into en_old, and the translator needs to translate source version 9. If the changes are minor, such as a missing space, they can reuse the previous translation. If the changes are substantial, they translate it again.
Languages
- We need to choose the list of available languages to localize into.
- A source language for translation—for example, Russian, in which we write the texts.
- A default application language, usually English. This is used when we detect the system language but do not support it, or cannot detect the language at all.
- Each listed language has an “available to the user” flag, so unfinished localization kits can be kept hidden, for example.
- The available languages include “longest.” It takes the longest value from all languages and inserts it into the game, for interface testing and similar purposes.
- Font compatibility with locales is checked by a separate utility. It verifies that the font contains all required characters. For example, many Cyrillic fonts lack certain Ukrainian letters.
Google Docs import and export support.
Translations can be exported to a Google document, either in full or only untranslated strings, edited there and imported back.
Important: translations cannot be edited by hand in the localization editor. Not at all. They can only be exported, edited and imported. Every translation change goes through import/export. This avoids many problems in a continually changing project. I have never encountered a situation where a game is translated once and nothing ever changes again.
Export can target one or several languages. Import can also handle one or several at once.
The export includes source-language key versions—the latest at export time—old translation versions, space for new translations, hints and comments. If a string does not need translation, the new-translation cell already contains a copy of the old text.
Not long ago, Google changed its API, and some older ways of working with Google Sheets stopped working, returning empty data. We have already moved everything to the new API. If you encounter the same problem, simply switch to the new API.
Parameters in localization text.
Parameters such as {param_name} can be inserted. Parameters with the same name count as one. Code is generated for static strings. Parameters can be passed directly to the generated class, with argument-count checking and documentation added automatically.
What can be selected during export
- Target language, the language to translate into.
- A partial-export flag: export only strings with an older translation version, meaning only those requiring translation, rather than the whole kit. This lets us export either all text or only untranslated text.
- Export errors: export strings with errors, such as mismatched keys in a translation.
- Export linked keys in comments, with three choices: no keys, key texts, or key names. Different translators prefer different options.
- Language for exporting linked keys, when exporting their texts. Keys can be exported in either the original or target language, which is useful when reviewing a localization kit.
- Additional languages: several other languages can be included in the kit. This sometimes simplifies translation, allowing a translator to work from two languages into a third.
For every non-source language, the exported Google spreadsheet has two columns: old_en and en.
The first contains the old translation; the new one should be entered in the second. If it has not changed, just copy it and import. Sometimes changes are insignificant, such as an extra space, and the translation remains valid; the translator only needs to check that the previous version still fits.
What we ended up with: the tool
Opening the localization editor
In Unity, open Custom tools > Localization Editor.
Editor tabs
The Languages tab
![]() English labels: Localization Editor: Languages
|
This tab lets you add languages and configure their visibility.
Source language for translation
This is the language in which all text is written and from which it is translated into other languages. It contains the most current text. It should not be changed.
Default application language
The code includes automatic language detection. If no suitable language is available, this one is selected. It is usually English. For example, a user’s system language is Turkmen, but we have translations only into Russian and English. In that case, the default language is selected.
Languages for translation
These are the languages into which text can be translated, including the source language.
Each language has an “allow display to user” checkbox. If it is unchecked, the language does not appear in the list available to users. This is useful when preparing a translation that is not yet final: for example, we want Russian and English available in the game, but not French.
The tool can also return the “longest” language. It selects the longest translation across all languages, regardless of whether their checkboxes are enabled, and returns that as the text.
The Localization tab
![]() English labels: Localization Editor: sheets and keys
|
Pages: worksheets in the Google spreadsheet
This tab contains all localizable text.
Keys are divided into pages. On export, each page becomes a separate worksheet in the Google spreadsheet.
Keys and groups of keys can be moved between pages for convenience—for example, monster names can live on a monsters page.
Pages can be removed, added and created, and keys can be moved between them; the context menu lets you move a whole group of keys at once. Each page is stored in a separate XML file.
There is also a special “this page is populated from code” checkbox, created for one external project. I will not cover it in detail here.
Filters
For convenience, the keys on a page can be filtered. Enter text in the Filter field, and only keys containing it in their name or one of their translations remain.
Show languages
The buttons let you hide unwanted language columns to make work more convenient.
Localization keys
![]() English labels: Localization table: keys and language columns
|
![]() English labels: Localization table: metadata
|
![]() English labels: Localization table: source and translation
|
A localization key’s technical name
All localization keys have meaningful names. A name may contain Latin letters, digits, underscores and dots.
Dots divide keys into groups. For example, with interface.window_shop.*,
you can collapse and expand all keys beginning with interface, or all window_shop keys inside the interface group. This makes related keys easier to find and organize.
Localization-key controls
- The arrow button beside a key’s name moves the key or a group of keys to another page.
- The Delete button removes an unwanted key. Accidentally deleted keys can be restored on the Settings tab, provided the deleted-keys list has not been cleared.
- The column headed C contains the static key checkbox. The Generate class LL button generates methods—a class—for these keys, which can then be used from C#.
- The Key column contains the key’s name and lets you rename it. Press Enter to save a name change.
- The Comments field and its “…” button are used to add comments. Clicking the three-dot button opens a window for adding comments for translators.
![]() English labels: Comment Editor
|
The Link key button adds references to other keys mentioned in the current key’s text. For example, an effect description saying “increases attack speed by 20%” can link to attack speed, so its existing translation is visible in the comments. When exporting for translators, you can choose whether to show key names or their current translations, and in which language. When keys are linked, the button displays the number of linked keys instead of three dots.
![]() English labels: Selecting a related localization key
|
![]() English labels: Comment Editor: linked keys
|
- The MaxChars column sets the maximum permitted number of characters for a key’s text. An ability name, for example, might be limited to 20 characters. When errors are exported for translators to fix, overlength keys appear in the partial-export list. The limit is shared across all languages; it cannot differ by language, which would not make sense here. Presets can also be created, for example when the same limit must be applied to many keys.
![]() English labels: Maximum string length
|
- The column headed В indicates the text version for each key. Every saved text change automatically increases that version. All other languages have versions too. A lower version means the translation is outdated and will be exported for retranslation, correction, or simply confirmation that it is still valid; see the Google Docs tab below. An asterisk may appear beside the version number. It means the translation is temporary crap produced by Google Translate or someone who does not know English, just to put something in the translation field—or that the translator has said it is not final. Such keys can be exported for updating.
Editing key text
![]() English labels: Versioned translation examples
|
![]() English labels: Cell Text Editor
|
Clicking the button beside the Russian text opens this window. You can edit the source-language text. Translations cannot be edited here: this is deliberate protection against people who think they know better. All translation edits go through exporting the localization kit and importing the translated kit.
Parameters in keys
A key’s text may contain parameters used to substitute other values into the string.
Example:
“Increased: Attack Speed by +{_attack_speed_add_}, Movement Speed by +{_move_speed_percent_}% and Critical Hit Chance by +{_crite_rate_add_}. Dodge reduced by {_dodge_rate_decrease_}.”Parameters are enclosed in curly braces {} and must have meaningful names. The name should make it clear what value to pass from code, rather than simply being param1 or param2. Because Google Sheets sometimes removed text in curly braces when automatically translating into certain languages with =googletranslate(), we decided to surround parameter names with underscores and separate the words in a name with underscores too. Do not use spaces or uppercase letters. Parameter names may contain only lowercase Latin letters, digits and underscores. Otherwise, machine translations will require extensive manual repairs, because the keys themselves get translated.
The number and names of parameters must match across all languages. If they do not, the tool considers this a translation error and includes those keys in the export list.
During code generation, parameter names are inserted into the method automatically, and the full text is included in the generated method documentation. If a method exists but its key has been deleted, the client will not compile: an error is reported.
We also introduced internal parameter-naming rules:
- If a number must be displayed with a fractional part, the parameter name must end in _fractional.
- If a number is displayed as a percentage, append _percent.
The code displays everything correctly anyway, but these conventions provide more context for translators and programmers and reduce questions from the latter.
The Google Docs tab
![]() English labels: Google Docs: export and import
|
The tool’s general workflow
All source-language text is edited in the tool. The required text is then exported to a Google spreadsheet for translation. Once translated—by Google Translate or a translator—the translations are imported back into the tool. Translations cannot be edited inside the tool! This is deliberately designed to protect against people who think they know better. The only route is to export, edit in the spreadsheet and import again.
Authorization
![]() English labels: Google Docs authorization
|
![]() English labels: Authorized Google Docs connection
|
To work with Google spreadsheets, sign in using your Google account. Exported documents can be shared with translators.
Exporting localization
Source language
This simply shows the source language for reference.
Target language and additional languages
Choose the language you want to translate into. At least two languages must have been added on the Languages tab: the source language and one other. Only languages added by the user on that tab are available in the list.
To export several languages at once, select the others using the checkboxes in Additional languages. For example, suppose we have Russian and a good English translation, and now want a German translation. We can select German as the target language and also export English as an additional language for the translator’s convenience. All of them will appear in the spreadsheet.
Partial export
When this checkbox is off, every key in the kit is exported: a complete localization kit. When it is on, only keys needing attention are exported.
This includes keys whose translation version is lower than the source-language version: changed keys and keys with no translation at all.
Export errors
With Partial export enabled, only untranslated or outdated keys are normally included. Enabling Export errors adds keys with errors, such as mismatched tag names or counts, excessive character counts and so on.
The “for all addition” checkbox also checks errors in the additional languages rather than only the target language, and includes those keys in the export.
Export non-final translations
With Export non-final enabled, the export also includes all keys whose Final translation checkbox was not selected during import.
Export linked keys
Choose how linked keys should appear in comments. There are three options: No reference keys, containing only manually written comments; Reference keys in comments, adding a list of keys; and Reference values in comments, inserting the linked keys’ translations. A neighboring control selects the language from which those translations are taken.
Filename
Generated automatically. It includes partial for a partial export and the export date for convenience; the date is not used during import.
Importing translations
The lower part of the window lists files belonging to the current project in your Google Drive, filtered by name. Each file has two buttons: View, opening it in the browser, and Import, opening the import window.
![]() English labels: Book import: one language
|
![]() English labels: Book import: all languages
|
The available checkboxes are:
All languages / Target language
When All languages is enabled, translations are imported for the additional languages as well as the selected language.
When it is off, a dropdown appears containing the languages available for import.
Allow replacement
By default, only translations with a version higher than the one in the tool are replaced: new translations only. Older ones remain unchanged. This prevents accidentally overwriting a translation while working with a complete kit.
When this checkbox is enabled, translations whose version is EQUAL to the version in the tool are also replaced.
The Import button
Imports translations using the selected options.
The Settings tab
![]() English labels: Localization Editor: Settings
|
General settings
The path to the generated .cs file for static localization specifies where it is stored. The file is replaced entirely with a new one.
Key column width is measured in pixels. Adjust it to see complete keys.
Translation column width is also measured in pixels. Adjust it to see complete text, although there is always a button beside the text for viewing it conveniently with line wrapping.
Save on button press: disabling this saves automatically after every change, which is convenient for small projects.
Do not fix spaces: disables some fixes, such as trimming leading and trailing spaces and repairing spaces in substitution keys. It is better to let the tool fix them.
Deleted keys
This contains a list of recently deleted keys. They can be restored, or the list can be cleared.
Miscellaneous
The Fix errors button repairs some—not all—errors caused by manually editing XML. It is better not to edit the XML by hand.
Generate class LL: a tab-button
Generates code for static localization. PixelWars uses only one such key: not_localized.
The Save button
This can be disabled in settings. With large amounts of text, autosaving after each change is slow. We retained autosaving for small projects; for large ones, we save manually with the button. Press it after every text-editing session, or the changes will not be saved.
An example text-workflow checklist
Written for one of the studios that licensed the tool.
Adding new text: wiki and code
Game designers choose the technical names of keys.
Names must be meaningful and in English. Do not write “posoh_s_zolotymi_sharikami_na_rukoyati.”
If you need a new key, agree it with a game designer!
For every new interface, the wiki must specify which keys it uses, as a group without details—for example, interface.window_shop.*. If no article exists for that interface, put the information in the task.
Include prefixes explaining a key’s purpose: btn_ for buttons, caption_ for window titles, label_ for section headings, text_ for ordinary text, and so on. What matters is that the name makes the key’s identity and purpose clear.
- Surround all new parameters with underscores: {tag}, not {tag}!
- Give each window its own keys so they can be changed independently later.
- If a text uses an existing term, such as a stat name, link the stat’s key to the text’s key. This will make the translator’s work easier.
Creating new keys in the tool
- Add keys once a day, in the evening.
Optionally, if some translation is urgently needed—that is, pseudolocalization:
1.1) Immediately perform a partial export with Export non-final unchecked and Export errors checked.
1.2) Translate using Google Translate, then import as non-final, with Final translation unchecked.
1.3) Perform another partial export with Export non-final unchecked and Export errors checked. If errors remain, usually in tags, fix them and import as non-final, with Final translation unchecked. Repeat step 1.3 until no errors remain: there should be no keys in the partial export.
-
Perform a partial export with Include non-final and Export errors enabled, and send it to the translator.
-
Once the translator finishes:
Import as final: Final translation checked, Allow replacement unchecked.
3.1) Perform another partial export with Export non-final unchecked and Export errors checked. If there are errors—if any keys are included—send them to the translator for correction, wait for the revisions and import with both Final translation and Allow replacement checked. Repeat step 3.1 until the errors disappear.
Changing text that has already been added
-
Change the Russian text in the tool.
-
Perform a partial export with Include non-final and Export errors checked, and send it to the translator.
-
When the translator returns it, import as final, with Final translation and Allow replacement enabled. Repeat steps 2 and 3 until the partial export is an empty document.
Additional best practices
What happens when a required key is missing
The key’s technical name is returned; we also surrounded it with asterisks. Instead of reporting “no translation” or “empty title,” QA can immediately identify the missing key and investigate whether its name differs in code or it was never added.
An error is also written to the log, and in a release build an event with the key’s name is sent to analytics. This is not part of the localization system, but it is very convenient.
Text layout
Because we use Unity and TextMeshPro, rich text and custom emoji are supported out of the box. Nothing extra is needed.
The same applies to non-breaking text—keeping a currency symbol with the number—and similar requirements. It is all already in TMP!
Highlighting terms in text
“It would be cool to do it like Tyranny, where all the terms are highlighted and a popup explains them on hover.”
This is not localization’s responsibility, and TextMeshPro tags already implement it. It is straightforward. Do not search for terms by their names and add tooltips that way, for obvious reasons.
Localizing graphics
We have not covered graphics localization in this article because everyone handles it differently. The general principle is to translate all localizable phrases as ordinary text, then manually insert them into textures—for graffiti, for example—and load the appropriate textures for the selected language.
We also made a text-decal shader for placing lettering on walls in a mobile project. But that is no different from ordinary interface text and hardly warrants a separate discussion.
Naming keys and parameters
Technical key names
The general principle is: how will you want to group them later?
For interfaces, we usually create a shared interface. group.
Inside it are groups for individual windows, such as interface.settings., then window tabs, such as interface.settings.sound., and so on.
Stats have a separate stats. group.
Examples:
stats.strength_name = “Critical Hit Chance”
stats.strength_short_name = “Crit. Chance”
stats.strength_description = “Affects the probability of dealing critical damage”
Everything related to a particular stat will then appear together in both the export and the editor.
For characters, for example:
characters.npc.<character technical name>_name
characters.monsters.<character technical name>_name
characters.bosses.<character technical name>_name
The number of folding levels can be increased by renaming the relevant keys, replacing an underscore with a dot.
In code, we try to construct key names automatically from technical names wherever possible. For example: “characters.npc.” + <character technical name> + “_name”.
For quests and their dialogue, a key’s name will probably include both the quest and who is speaking.
Example:
dialogs.q_stupid_quest_coyotes.d_01_intro.d_001_merchant_male_hero_female = “Hello, great warrior, I’d like to ask you to bring me 10 coyote pelts and a widdle hat!11”
dialogs.q_stupid_quest_coyotes.d_01_intro.d_002_hero_female_merchant_male = “Hello to you too, merchant!”
quests.q_stupid_quest_coyotes.quest_name = “Pelts and a Widdle Hat”
Dialogue order matters. Simply number the lines; in some cases this can even be automated. We were also often asked to specify the genders of the speaker and addressee, in addition to their names. Put that information in comments or in the key name, whichever is more convenient.
Whether to put dialogue inside the quest—quests.q_<quest_name>.dialogs.—or separately—dialogs.q_<quest_name>.—is up to you. We had a lot of dialogue and kept it separate because that was more convenient for us.
Where possible, keep entities of the same kind on separate worksheets so they are easier to find. Give worksheets meaningful names, such as quests or interface.
Technical names for substitution parameters
The general principle is that the context should be clear.
Try to name the same parameters consistently so programmers do not have to duplicate code.
Examples:
Mana required: {mana_cost}
Cooldown: {cooldown_fractional} sec.
The Hunter fires two flaming arrows at the target. Each deals {attack_damage} fire damage and sets the enemy alight for {influence_duration_fractional} sec.
A burning enemy loses {hp_decrease} health every {period_fractional} sec.
Mana required: {mana_cost}
Cooldown: {cooldown_fractional} sec.
Cannot miss. No critical hits.
The Gunner throws a grenade that deals {attack_percent} electrical damage to all targets within {aoe_area_radius_fractional} m. A thundercloud forms at the explosion site. Enemies caught in the cloud take {damage_increace_percent}% more damage for {influence_duration_fractional} sec.
Cloud lifetime: {area_lifetime_fractional} sec.
Inflection, grammatical gender and other complicated things
In short: you probably do not need this!
Why substitutions are difficult
Automatically assembling names is quite complicated. Let us look at examples.
Suppose we want a name—in the nominative case only, for now!—to indicate an item’s stats and other characteristics, as in Diablo.
The name consists of a modifier, an adjective + an item type, a noun + an identifier of belonging, a noun.
Both the adjective and the identifier of belonging depend on gender and number.
Examples:
Красный меч / Красная секира / Красные стрелы — red sword / red axe / red arrows, with different Russian adjective forms.
la feu DU dragon — the dragon’s fire
la feu DE LA terre — the earth’s fire
la feu DES maudits — the fire of the damned
Word order also changes in many languages, including Korean, French and Spanish.
In French, the modifier—the prefix—comes after the noun in this example:
la feu délétère de la terre — the deadly fire of the earth; literally, “the fire deadly of the earth.”
In Italian: la fiamma disastrosa de la terra.
The same word can also have different genders in different languages! That is simply how they developed historically.
Notice that this example is only in the nominative case, without any declension!
If you can put a name directly into the text without substitutions, do so and spare the translators the headache. Otherwise, you will need a fairly complicated system. Think carefully: do you really need it? Would it not be simpler to name the items properly in advance and avoid this complexity?
An implementation example using our system
Take the simplest case: a name is assembled from a prefix, noun and postfix according to the item’s class and stats. It is used on its own, not inserted into dialogue, and is not declined.
For most relevant languages, we will then use one of four groups:
- masculine,
- feminine,
- neuter,
- plural.
Create a separate naming_format key containing the text-assembly formula.
Examples of what the stats might contain:
[prefix_secondarystat|masculine] + [item_name] + [postfix_rarityclass] [prefix_class_attack_element_name] + [item_name] + [postfix_secondarystat|masculine]
Instead of plus signs, the actual text will contain spaces, articles or something else.
There will be four such keys. Alternatively, we can agree in advance that all items of a class in this slot use only masculine or only feminine names, reducing the number of keys.
The code then parses the formatting key and assembles the parts. Prefixes such as English a/an can be included directly in the item name in this case.
The gender group is specified separately somewhere, perhaps in another key or in a tag that we strip out.
And that is only for a single phrase!
An example of assembled item names from our game:
https://docs.google.com/spreadsheets/d/1uXJyIRQ2R9OOTtba0EPK3BXcghlkr8r8AjrvIXKchHM/edit?usp=sharing
The same applies to declension and cases: some languages have none, while others have more than Russian.
Word forms also vary with the number of items. This is a little simpler. There are 19 plural-rule groups, each with its own rules. You can read about them here:
https://developer.mozilla.org/en-US/docs/Mozilla/Localization/Localization_and_Plurals
These rules can be defined for every language, written as a switch and used accordingly.
The overall conclusion: if you want complicated substitutions like these, prepare for many problems and hard-to-read text. There are also dialects, exceptional word forms and so on.
Examples of existing solutions for this kind of work:
https://github.com/messageformat/messageformat
https://github.com/axuno/SmartFormat
Now consider how convenient this will be for translators, and ask yourself again whether you need it.
Most likely, if you are not making Diablo—if you do not have absurdly large numbers of generated items—and do not have a dedicated team for it, you do not need it. If you do, you can follow something like the approach above, but this is not a five-minute task, and it requires checking by native speakers.
Here is the approach we used:
Items had a primary stat and secondary stats. Two item classes, weapons and armor, could also have an element: elemental damage for weapons and a change of element for armor, similar to Ragnarok Online. Items could have different rarities.
We made different naming_format templates for ordinary weapons, elemental weapons and rare weapons, with equivalent variations for armor and so on.
We selected prefixes and postfixes based on rarity, the presence of an element, and the primary and secondary stats, choosing the most influential stat. An element took priority over everything else.
We did not implement declension—such as the different Russian forms in “you found an ordinary sword” and “you were hit with an ordinary sword”—because it would multiply the localization volume and complexity.
Development cost
Because our localization tool turned out to be quite convenient, we eventually decided to sell licenses for it.
We did not consider the Asset Store from the outset, because it would require ongoing dedicated technical support, including answering less advanced users’ questions, and we did not want to do that. We decided it was better to sell one B2B license to one legal entity for $5,000 than 100 B2C copies at $50 for the same total.
We worked exclusively with legal entities, licensing the tool for any number of projects within one legal entity. All updates were free: we use the tool in all our own projects anyway, so providing them was easy. Everyone ended up satisfied, the arrangement suited us, and we later added some requested features for free, some of which we use ourselves.
This format eventually paid back development of the localization system, including all its iterations, in roughly three years, without interrupting work on our own products.
Planned improvements
Moving to the new UIElements system
We have already moved most of our internal editors to UIElements and GraphView. The presentation is more convenient, and editor code is easier to write. We plan to make a UIElements version of the localization system and move to it completely.
Localization overrides for user translations
Let users supply a file translating some keys, to be used instead of the primary translation. We want this for fan translations, naturally checking that their keys match ours.
The main localization will remain in one file. Modders without the toolset would find that inconvenient, and we want unofficial translation support without breaking the main system.
Emoji support
We do not currently need emoji in localization, but plan to support replacing emoji with codes used by different messaging services in the future.
Obtaining the character set
Obtain the set of characters needed to generate font textures. This is planned; for now, we use complete language character sets. There is also a separate utility for checking whether fonts contain all required characters.
A standalone version
An independent application rather than an editor extension. We are considering it, but have not needed it so far.
Unity Localization support
https://docs.unity3d.com/Packages/com.unity.localization@0.8/manual/index.html
It is currently in preview. We have distant plans to add compatibility once the package leaves preview, if doing so makes sense.
There are useful features, but everything is still in R&D, so we do not want to spend time on it yet.
Integration with text-to-speech systems
We plan to add dialogue-voice generation for placeholder voice-over after a while. This could help during pre-production, because final voice acting is usually recorded at the very end, and recording temporary dialogue ourselves takes time.
We already did something like this in 2012. Now we want to use an existing asset supporting a larger number of TTS engines, so we can choose voices—ideally with emotional expression.
Generating voices in real time is theoretically possible too, but we see little point: TTS voice-over is a placeholder, not a final production solution.
Other requests
We do not need these yet, but you might if you build your own system from scratch.
- “Sisulizer as an external tool.”
- We do not use it, but people have asked, so it may be convenient. We send text directly to translators in Google Sheets.
- “Line breaks may occur in different places at different resolutions. Different tags for different breaks: each tag has a version it applies to, while the others are ignored.”
- We do not use this, so we did not implement it, but a simple replacement would solve it.
- “Specify a tag and pull the value from code at runtime.”
- We rejected that approach. It can easily be added through substitution if desired, but we consider it a source of problems for our own work.
- “Analyze scenes and prefabs for unlocalized components.”
- We do not work that way: we immediately use LL.not_localized(“unlocalized text”).
- “Localization of right-to-left Arabic languages, including changes to text alignment and so on. Loading an Arabic translation is not a problem in the text itself, but changing alignment affects interfaces, which everyone implements differently.”
- We plan to provide LTR/RTL information for each language.
- Localization/unicode related for Steam, from Anisoptera: “Steam usernames are UTF8 and frequently contain ƃᴉzɐɯ∀ st[radiation emoji here]ff. Reassembly uses Google’s Droid Sans Fallback and Open Sans Emoji to provide additional characters for rendering usernames, and SDL_ttf or Cocoa/NSFont to actually render the text, depending on the platform. In an ironic twist of fate, the first version of this article was lost because wordpress choked on a U+E10D (rocket) character.”
- We have not implemented this yet, but simply using a font that supports emoji to display Steam usernames should solve it. It is in our distant plans.
Related links
https://habrahabr.ru/post/237725/ — Localizing applications for the Chinese market.
https://habrahabr.ru/post/128536/ — The specifics of text localization, translated article.
https://habrahabr.ru/company/miip/blog/324496/ — The specifics of localizing games for foreign markets.
http://wnfx.ru/pravila-lokalizatsii-prilozheniy-v-kitae/ — Rules for localizing applications in China: money, connections and the App Store.
Some time ago, Alexander Shtachenko and I wrote an article about localization: http://progamedev.net/localization/.
https://habr.com/ru/post/694662/ — A good article on the differences between localization approaches in UE and Unity.
Which existing Unity assets can you use instead of building your own system?
L2 Localization is considered the most elaborate. Its workflow did not suit us, so we had to build our own.
https://assetstore.unity.com/packages/tools/localization/i2-localization-14884
Unity has also started developing its own localization system. Documentation for the preview package is here: https://docs.unity3d.com/Packages/com.unity.localization@0.8/manual/index.html.

















