Translations
Add new panel strings and keep translations in sync with Tolgee.
Every string the panel shows lives in one file per language, resources/lang/<locale>/ui.json. Only English (en-US) is kept in the repository; it is the source language. All other languages are translated on Tolgee and downloaded into the panel.
Never edit a language other than en-US by hand. Those files are replaced on every pull from Tolgee, so changes made there are lost. Translate on Tolgee instead.
How ui.json is organized
The top-level keys of ui.json are groups:
uiholds the strings of the React panel.- The other groups (
validation,exceptions,admin,auth, ...) are used by the Laravel backend.
Keys are nested objects, and you refer to a string by its dotted path.
| Where | How to use a string | Placeholder syntax |
|---|---|---|
| React | t('ui.admin.settings.saved') | {name}, e.g. "Created {date}" |
| PHP | __('exceptions.admin.mail_smtp_only') | :name, e.g. "The :attribute field is required." |
To name a validation attribute that contains dots, such as allowed_ips.*, add it as a single key ("allowed_ips.*") under validation.attributes.
Adding a string
- Add the English text to
resources/lang/en-US/ui.json, next to related keys. - Use it from the code with its full path. React keys are typed, so a missing or misspelled key fails type checking.
- Ask a maintainer to add the new keys to the Tolgee project, so translators can pick them up. Until a key is translated, every language falls back to the English text.
Only add new keys in the repository. Changing or removing an existing English string should also be done on Tolgee, otherwise the next pull brings the old value back.
Getting the latest translations
There are two ways to download translations into your local panel:
- From the panel: open Admin → Settings → Translations and click Pull latest translations. No key is needed. English is updated too, but keys you added locally and that are not on Tolgee yet are kept.
- From the command line: run
./bin/pullTranslations.sh, optionally followed by language codes (for example./bin/pullTranslations.sh de-DE es-ES). This uses the Tolgee API directly, so it needsTOLGEE_API_KEYin your.env(andTOLGEE_PROJECT_IDwith a personal access token).
bin/pullTranslations.sh makes each file match Tolgee exactly, so it also removes English keys that are not on Tolgee yet. Pull only other languages with it (./bin/pullTranslations.sh de-DE es-ES ...) while you have new English strings waiting, or use the panel's button.
Don't commit the downloaded files for languages other than English. See Translations for how the panel's Tolgee connection is configured.
Last updated on