Purpose
Player-facing text is kept out of the product itself so that you can own it. A product ships one file per language it supports, and picks the one your configuration selects.locales configuration namespace, in
configs/locales.jsonc. That file is the only place the choice is recorded.
Options
Choosing the language
The active language is a configuration value, in thelocales namespace:
Each value is a language code matching a file in
locales, without the extension: it needs
locales/it.json.
Set active to a language that is not in available and the product uses fallback instead.
Nothing fails and nothing is reported, so check the spelling against the file names in locales if
the language does not change.
The same values apply to every player on the server. There is no per-player language selection.
How a missing piece of text behaves
Text is looked up by key. Three outcomes, in order:- The key exists in the active language: that text is shown.
- The key is missing from the active language but present in the fallback language: the fallback text is shown, in the middle of otherwise translated text.
- The key is missing from both: the key name itself is shown on screen, for example
hud.legend.title.
Rewording shipped text
Open the file for the active language and edit the value. Keys are grouped into sections; keep the structure and change only the text.Placeholders and plurals
Text can contain placeholders that the product fills in at the moment it is shown. Keep them exactly as they appear in the shipped text, including their names: a renamed placeholder is filled with nothing and leaves a gap in the sentence.
Inside a plural,
# is replaced by the number itself, and a branch named =0, =1 and so on
covers one exact number:
one and other cover
English, Italian, Spanish, Portuguese, German and Dutch. French treats zero as one. Polish,
Russian and Ukrainian also use few and many. A language the product has no rules for behaves like
English. Always provide other: it is used whenever no other branch matches.
Adding a language
-
Copy the file of a language the product already ships, for example
locales/en.json, tolocales/<code>.json. - Translate the values. Keep every key, and keep the placeholders unchanged.
-
Add the new file to the
filesblock in the resource’sfxmanifest.lua, beside the language files already listed there. Without this line the file stays on the server and never reaches players, so the language appears to have no effect. -
Add the code to
availableinconfigs/locales.jsonc, and setactiveto it:availablereplaces the shipped list rather than adding to it, so include the languages the product already has. - Restart the resource.
fxmanifest.lua, and the configuration. An
update replaces all three. Keep copies of every one of them.
Example
Switching a product to Italian and rewording one line:Applying changes
Language files and thelocales configuration are read when the resource starts. Restart the
resource to apply an edit:
Safety
- Your edits are replaced by an update. Language files ship inside the release, exactly like configuration files. Keep your copies outside the resource directory and restore them after an update. See Update a product or the SDK.
- A language file that cannot be read yields no text at all for that language, so every key falls back to the fallback language. It reports one warning naming the language. Check for a trailing comma or a missing bracket if a translation stops appearing after an edit.
activeandfallbackmust both appear inavailable. Anactiveoutside the list usesfallback; afallbackoutside the list uses the first language inavailable. Both are silent.- Keep the fallback language complete. It is what fills every gap in every other language, so a key missing from it is a key name on screen.
Related
- Configuration files: the rules that apply to
configs/locales.jsonc - Text is wrong or missing
- Update a product or the SDK