Language
Chevereto uses gettext .po files for its translations. Dozens of languages are included out of the box at app/languages/.
| Path | Purpose |
|---|---|
app/languages/ | Language files, one per locale (en.po, es.po) |
app/languages/overrides/ | Your custom strings, per locale |
app/.cache/languages/ | Compiled translations used at runtime |
Cache required
.po files are not read at runtime. After adding a language or editing overrides you must cache languages for changes to take effect.
To choose the default language, enable or disable languages, and toggle the language chooser, see Languages settings.
Contributing
To add a new language or improve an existing one for everybody, contribute to the public repository. Accepted translations ship with the Chevereto distribution.
Add a new language
- Copy
app/languages/en.potoapp/languages/<code>.po, where<code>is the locale code. For examplees-AR.pofor Spanish (Argentina). - Update the
LanguageandPlural-Formsentries in the file header to match the target language. - Translate each
msgstrvalue. - Cache languages.
Locale code
The file name must match a locale code known by Chevereto, using a hyphen for regional variants (pt-BR, not pt_BR). Files with an unknown code are silently ignored.
Use a dedicated PO editor such as Poedit to edit translation files. These handle the file header metadata (such as plural rules) and plural forms for you.
Customize strings
Any string shown to visitors can be changed without touching the theme by using overrides. An override replaces the translation of a given string for a single language, without modifying the shipped language files.
The following example replaces Upload and share your media with Upload, do it now! for English.
1. Find the string
Open the language file you want to customize at app/languages/, for example en.po, and search for the text. Copy its msgid and msgstr lines:
msgid "Upload and share your media"
msgstr ""TIP
The msgstr is empty in en.po because English is the base language and the msgid is the text displayed. In other language files msgstr holds the translated text.
2. Create the override
Create the file app/languages/overrides/en.po (create the overrides folder if it doesn't exist) and set msgstr to your text:
msgid "Upload and share your media"
msgstr "Upload, do it now!"The override file must use the same name as the language it customizes, so overrides/en.po affects only en. To customize Spanish, use overrides/es.po and copy the msgid from es.po.
Keep these rules in mind:
- Copy
msgidexactly as it appears in the language file, it is case-sensitive. - Keep any placeholders like
%sor%din yourmsgstr. - Wrap values in double quotes and escape any double quote inside them as
\".
3. Add more strings
Add as many entries as you need to the same file, separated by a blank line:
msgid "Upload and share your media"
msgstr "Upload, do it now!"
msgid "Recent"
msgstr "New!"For strings with plural forms, copy the whole entry including msgid_plural and each msgstr[n] line:
msgid "image"
msgid_plural "images"
msgstr[0] "picture"
msgstr[1] "pictures"Semantics
To rename core concepts like image, album or user across the whole site, use the Semantics settings in the dashboard instead. These take precedence over overrides.
4. Cache languages
Cache languages to apply your overrides.
Cache languages
Run the langs command to compile all .po files, including overrides, into the language cache:
sudo -u www-data app/bin/cli -C langsdocker exec -it --user www-data \
container_name \
app/bin/cli -C langsThe command lists each compiled file and ends with [OK] Languages cached.
After updates
Chevereto ships with the cache for its built-in languages. If you have added languages or overrides, run the langs command again after every system update.
