Plugin Translations
On This Page:
Plugin Translations.
General Information
Translations for Revive Adserver plugins are packaged within the plugins themselves, to ensure that developers of plugins can include the required translations for the UI with their plugins, and not have to depend on the translations existing in the core Revive Adserver product.
Revive Adserver plugins use gettext .po/.mo
files for managing translations.
Core Revive Adserver Plugins
Please note that for core Revive Adserver plugins, the generation of the binary .mo files is handled by the Crowdin project; so, similar to the way the core product translations are handled, it is only necessary to edit the required English language .po file(s) for the plugin in the master branch, and the changes will be automatically uploaded to Crowdin, translated by the community, and the updates made there will be periodically merged by the core Revive Adserver team into the master branch's core plugin .mo files, and will be included in the next release.
Editing .po Files / Generating .mo Files
There is no need to edit .po files or generate .mo files for core Revive Adserver plugins.
When master English translation strings are added to, or updated in, core Revive Adserver plugins, and committed to the master branch, a script is automatically run to look for new strings in plugin code and add them to the .po files.
From here, translations are managed through Crowdin, and the .po and .mo files are updated for use by the core team on a regular basis.
3rd Party Plugins
While the process of updating translations for core Revive Adserver plugins is easy, this process is not suitable if you are developing a 3rd party plugin for Revive Adserver (i.e. one that is not going to be part of the core Revive Adserver product).
Generating .po Files
Accordingly, if you are developing your own plugins which are not part of core Revive Adserver, then:
- Please see the update-plugins.php script, which can be used to generate the .po files for all languages; and
- The poedit tool can then be used to update the non-English .po files, so that you can create translations for your plugin.
Generating .mo Files
Once you have generated / updated your .po files, updated .mo files can be generated from the .po files using poedit.
Translation Strings in Plugin PHP Code
In plugin PHP code, to obtain a correctly translated string for display to a user, based on their settings, use either the MAX_Plugin_Translation
 class, or the OX_Component
class:
// MAX_Plugin_Translation Approach // $this->extension and $this->group need to be set to the plugin's extension (hook) and group // This will generally already be done when inside an instantiated plugin require_once RV_PATH . '/lib/max/Plugin/Translation.php'; $text = MAX_Plugin_Translation::translate('TargetString', $this->extension, $this->group); Â // OX_Component Approach // Use when the plugin already extends the OX_Component class $this->translate('TargetString');