Localisation modding

Version

This article has been verified for the current PC version (3.1) of the game.

Localisation refers to the actual text presented to the player in events, menus, weaponry, stories, and any other string of text in any window in the game. Localisation files are saved as .yml in the localisation/ folder and should be encoded with UTF-8 with BOM. The naming convention for .yml files is **<file>\_l\_<language>.yml** where <file> is the name given for this group of localisations, and <language> is the language the localisation is for. Supported languages currently include Portuguese (*braz\_por*) English (*english*), French (*french*), German (*german*), Polish (*polish*), Russian (*russian*), Spanish (*spanish*), simplified Chinese (*simp\_chinese*), Japanese (*japanese*) and Korean (*korean*).

Useful commands:

```
reload text – reloads localisation table.
switchlanguage l_english – switches used language and reloads localisation table.
toggle_string_id – displays StringIDinstead of localisation

```

### Creating Localisation Files

* In the root mod folder (not in common), create a folder named "*localisation*" spelled with an s. Note, some other paradox titles may use the Americanized "*localization*" with a z.
* Optionally, create language subfolders within the "*localisation*" folder. This is organizationally helpful but not required.
* Stellaris’s localisation files are encoded as UTF-8-BOM. They **must be** encoded in UTF-8-BOM, as even UTF-8 will fail to be parsed by Stellaris, and will not work.
* The easiest way to get the correct encoding is to copy an existing Stellaris .yml file and modify it.
* Alternatively, simply create a standard text file and save it as .yml with UTF-8 with BOM encoding. Various text editors, such as Notepad++ and Visual Studio Code, will allow you to manually save with encoding UTF-8 with BOM
* The file name must end in "*\_l\_<language>*", otherwise it will not be read.
* The first line of any localisation file must be `l_<language>:`, otherwise it will not be read.
* Example file name: `mod_buildings_l_english.yml`

Naming a YML file the same as a vanilla YML file will overwrite vanilla. Doing this is not recommended, unless you are trying to change (almost) all of the entries in the file. Localisation entries can be overwritten individually, by saving them in the "Replace" folder. See overwrite section.

Unfortunately there is no mod-friendly fallback language feature, so if localisation keys are missing, these keys are simply displayed as text. Therefore, it is practice to simply duplicate the English files for all other languages (changed with appropriate header).

### File Encoding

* Open the YML file using a text editor. Editors such as Notepad++ and Visual Studio Code are recommended, however, if those aren't available, even standard Notepad will work.
* Convert the file to UTF-8 with BOM
* If using Notepad++, go to menu bar, open the *Encoding* menu.
* If using VSC, go to the bottom right corner and click on the encoding (`UTF-8` by default), then click Save with Encoding. Alternatively, it is possible to modify the settings so YML files created using VSC have *UTF-8 with BOM* encoding by default.
* If using Notepad, go to *Save As…*, then change the encoding and save the file.
	+ If the options listed are *UTF-8* and *UTF-8 with BOM* (or similar), use *UTF-8 with BOM*.
	+ If the options listed are *UTF-8 without BOM* and *UTF-8* (or similar), use *UTF-8*.

### Localisation Keys

```
l\_<language>:
 localisation\_key\_1: "Text String 1"
 localisation\_key\_2: "Text String 2"

```

Individual localisation entries are called keys and are placed before the colon. Keys are the actual code that points to the localised text. The text itself itself is called a string. The key is to the left of the colon. The string of text that will display in game is to the right of the colon, listed within two quotation marks (" "). The colon is the separator.

* The number seen in vanilla files right after the colon can be omitted, as it is only useful for Paradox’s internal translation tracking.
* The file must contain `l_english:` (or equivalent for other languages) before any localization keys.
* Every entry after `l_english:` (or equivalent) must begin with whitespace (a space or a tab works).
* Each string to be displayed in game is encased in quotation marks. To display quotation marks in game, input a backslash before each quotation mark (for example: `text \"name\"`)
* Note that the following unicode characters are invalid inside the localisation file and will generate a "?" instead: `„ “ ‚ ‘ – ” ’ … —`

## Overwriting Vanilla Text

To overwrite vanilla localisation keys (or keys from other mods), create a folder named "replace" inside your "localisation" folder. Localisation files in this folder will load after all other localisation files, and overwrite any duplicate keys. In this way it is not necessary to overwrite entire localisation files, as individual key entries will be overwritten by the last loaded file, LIOS (Last in, only served). It is possible to overwrite localisation without a "replace" folder, however this is not a reliable method.

## Bracket Commands

Bracket commands (scoped localization statements) are enclosed in square brackets (`[ ]`), start with a primary scope, end with a text retrieval, and can have one or more secondary scopes in between. The fields are separated by periods (.). Text retrievals can be predefined (as per examples below), can mention Variables defined in the scope, or can be a scripted\_loc (see common/scripted\_loc/ files for examples). When writing "*scripted\_loc*" entries, it’s important to note that these entries cannot themselves use bracket commands (i.e., a scripted\_loc that includes `[Root.GetName]` will literally print `[Root.GetName]`).

Note: if you want to use loc commands e.g. `log = [This.GetName]` in a scripted effect or trigger, you have to write it `\\[This.GetName]` or it will bug out (at the latest the second time you use one in the effect).

In most cases, it is also possible to get the value of variables with `'[Scope.my_variable]'` and saved dates with `'[Scope.my_date_flag]'`.(*since 3.1*)

Two consecutive opening square brackets `'[['` will escape it, making a single square bracket show up in text instead, i.e. `'[[example]'` in loc will display as '[example]' in-game.

There are also several unscoped commands: `GetDate, GetMidGameDate, GetLateGameDate, GetYear, LastKilledCountryName`.

Following list is only a part of hardcoded scoped localization commands (it also does not include any scripted locs). A more complete list of commands can be found at `Stellaris\logs\script_documentation\localizations.log`.

### Text Retrieval

Added localization commands with Patch 3.1.

```
GetSpeciesFossilName
GetSpeciesFossilNamePlural
GetSpeciesRemnantName
GetSpeciesRemnantNamePlural
Species
GetFossilName
GetFossilNamePlural
GetRemnantName
GetRemnantNamePlural

```

## Color Codes

 File:Color codes in-game.png
Color codes start with `§` (Windows users Keypad shortcut: `ALT+0167`), which is followed by a single character specifying the color to be used until another color code is detected, or the end of the string: `§!`. Within a **`$`** command, the color for a displayed variable (not string definition, s. below *$ Codes*) may also be specified by preceding the closing **`$`** with **`|`** and the color code character: `$AGE|Y$`

It is also possible to change the text color in game by adding a DC1 UTF-8 character to a color code letter. Please note that doing so may unintentionally color subsequent text if the color is not changed to default at the end.
`§RR§Sa§Hi§Yn§Gb§Bo§Mw§!` will be displayed as:Rainbow

(*Defined in file:* Stellaris/interface/fonts.gfx)

## $ Codes

**$** is used to delimit strings (or variables) defined elsewhere to be expanded in the current string, or system statistics in GUI elements.

```
 @cyborg\_energy\_upkeep= 5
 "Upkeep by +$@cyborg\_energy\_upkeep$"

```

## Number Formatting

The **`|`** character can also be used to format numbers. `$VALUE|*x$` will format `VALUE` to `x` decimal places.

```
# EXAMPLE = 100
"$EXAMPLE|\*0$" # 10044
"$EXAMPLE|\*1$" # 100.0

```

## £ Codes

£ codes are used for the names of various system stats, including energy, minerals, influence, and the three research categories (engineering, physics and society.) More exist than those listed here, such as `£ship_stats_hitpoints\armor\shield£`, `£fleet_template_size£`, and `£trigger_yes\no£` among others. Search the '£' character using something like Notepad++'s Find in Files feature to find something specific. Remember that £ codes must surround the tag you're inserting, i.e. `**£**energy**£**`. (Windows users without the pound symbol on their keyboards can use `Alt + 0163`.)

It also supports the multiple frames (if the source sprite has them), i.e.: `£leader_skill|3£` will render an icon of chosen skill level.

## £ Custom Icons

You can create custom text icons to appear in game exactly like those above, by saving an icon in *<root>/gfx/interface/icons/text\_icons*. Standard text icons are 16x16 pixel .dds files. In order to reference your icon in text, you will need to define it in the same way you define event pictures. Save a text file as .gfx in *<root>/interface/* Define any custom modifiers as shown below:

```
spriteTypes = {
   spriteType = {
        name = "GFX_text_worker_produces_mult"
        texturefile = "gfx/interface/icons/text_icons/mod_planet_jobs_worker_produces_mult.dds"
    }

```

You can link multiple icons by making separate `spriteType =` blocks. All of these should be within one larger `spriteTypes =` (with an s) block.

The name must be prefixed `GFX_text_`. However, to reference this custom icon in localisation, use `£worker_produces_mult£` (without the prefix) and it will appear alongside in game text.

## Slash-Based Codes

The two slash-based codes available are `\n` and `\t`.

`\n` is the equivalent of pressing the Enter key and starting a new line, unless it is inside one of the above codes.

`\t` places a tab.

Backslashes can also be used to treat special characters as text characters, for example `\"` will make the string contain a quotation mark, instead of closing it off.

## Style Guide

Vanilla events, modifiers and all other type of localization follows punctuation and capitalization guidelines. The following table highlights some of the rules employed in the vanilla English localization, allowing custom content to blend in more seamlessly. The table is by no means comprehensive, but instead should serve as a quick cheat-sheet for the most common type of strings.
The number given for Character Limit is not a hard limit. Depending on the location, exceeding the limit might cause the text to be cut off, completely break the UI, or just look ugly and out of place.

## References

1. ↑ https://twitter.com/Martin\_Anward/status/1039175213773144066

**Modding**