Documentation
Multilingual Support
In this post, we’ll walk you through:
Cevento is developed in English and ships with German translations (de_DE, de_AT, de_CH and de_DE_formal). The language is chosen automatically: the site language (Settings → General) on the website, and the language in the user’s profile in the WordPress admin.
As usual in WordPress, you can customize these translations or add new languages in an update-safe way. This applies to all plugin texts, including those displayed by Cevento’s JavaScript (booking form, form builder, admin notifications, …).
Texts you enter in the Cevento settings yourself (e.g. email templates or the booking button label) are stored as settings, not translations. Change them directly in the settings.
Where Translations Are Loaded From
WordPress looks for Cevento’s translations in two places, in this order:
[wp_root]/wp-content/languages/plugins/: your own translations. This directory is not touched by plugin updates.[plugin_root]/languages/: the translations shipped with the plugin. This directory is replaced with every update, so never make changes here.
The file names must follow the pattern cevento-[locale_code].po / cevento-[locale_code].mo, e.g. cevento-de_DE.mo for German (Germany) or cevento-fr_FR.mo for French. You can find all locale codes in this list.
Important: your own file for a language replaces the shipped translation of that language completely; the two are not merged. So always start from a complete copy of the shipped file (see below). Texts missing from your file are displayed in English.
Requirements
To edit translation files, we recommend Poedit. It edits .po files and automatically creates the .mo file WordPress uses whenever you save.
Alternatively, you can use the command line tools of gettext: msgfmt compiles an edited .po file into a .mo file.
Adjusting Existing Translations
-
Copy the
.pofile of the desired language from[plugin_root]/languages/, e.g.cevento-de_DE.po, into the directory[wp_root]/wp-content/languages/plugins/. The file name must match the language of your site. For an Austrian site (de_AT), for example, copycevento-de_AT.po. -
Open the copied file and change the desired translations.
-
Create the
.mofile: Poedit does this automatically when saving. With gettext:msgfmt -o cevento-de_DE.mo cevento-de_DE.po -
Make sure both files are in
[wp_root]/wp-content/languages/plugins/. WordPress only uses the.mofile; keep the.pofile for future changes.
Your changes apply immediately to all texts, including those displayed by the plugin’s JavaScript. If a caching plugin is active, clear its cache afterwards.
If there is also a file
cevento-[locale_code].l10n.phpin[wp_root]/wp-content/languages/plugins/(e.g. created by a translation tool), WordPress prefers it over the.mofile. In that case, delete it, or regenerate it after each change withwp i18n make-php.
After a Plugin Update
New or changed texts of a new Cevento version are not part of your own file yet and are therefore displayed in English. To add them to your file:
- Poedit: open your
.pofile, choose Translation → Update from POT File… and select the file[plugin_root]/languages/cevento.pot. Translate the new entries and save. -
WP-CLI: run
wp i18n update-po [plugin_root]/languages/cevento.pot [wp_root]/wp-content/languages/plugins/cevento-de_DE.pothen translate the new entries and create the
.mofile again as described above.
Your existing translations are kept in both cases.
Changing Individual Texts
If you only want to change a few texts, you don’t need your own translation file. Use the gettext_cevento filter instead, e.g. in your (child) theme’s functions.php or in a small plugin:
add_filter('gettext_cevento', function ($translation, $text) {
if ($text === 'Download iCAL') {
return 'Add to calendar';
}
return $translation;
}, 10, 2);
$textis always the original English text of the plugin. You can find it asmsgidin the file[plugin_root]/languages/cevento.pot.- The filter applies to all languages and also to the texts displayed by the plugin’s JavaScript. To change a text for one language only, additionally check
determine_locale(), e.g.if ($text === 'Download iCAL' && determine_locale() === 'de_DE'). - For texts with singular and plural forms (e.g.
%d participants), use thengettext_ceventofilter instead, which also receives the number ($translation, $single, $plural, $number).
Adding a New Language
- Create a new translation from the template
[plugin_root]/languages/cevento.pot:- Poedit: File → New from POT/PO File…, select
cevento.potand choose the language. - Manually: copy
cevento.potand rename the copy tocevento-[locale_code].po, e.g.cevento-fr_FR.po.
- Poedit: File → New from POT/PO File…, select
- Translate all texts and save the file as
cevento-[locale_code].poin the directory[wp_root]/wp-content/languages/plugins/. -
Create the
.mofile (Poedit does this automatically when saving):msgfmt -o cevento-fr_FR.mo cevento-fr_FR.po
As soon as the site (or the user profile) is set to this language, Cevento uses your translation, including for the texts displayed by its JavaScript. After plugin updates, add new texts as described in After a Plugin Update.