...
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 relatively easy (i.e. edit the required English language .po file(s), and commit the changes to the master branch), 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
Similarly, this process does not allow developers changing core Revive Adserver plugin translations to see those changes in action before committing changes.
As a result, it may be necessary for developers 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
To generate a .mo file, the gettext
msgfmt
utility. For exampleOnce 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:
Code Block |
---|
cd plugins_repo/openxDeliveryLimitations/plugins/etc/Site/_lang
msgfmt -o en.mo po/en.po |
This will re-create the en.mo file, based on the en.po file, for the Site component of the plugin in the openxDeliveryLimitations directory.
Note |
---|
For core Revive Adserver plugins, do NOT commit changed .mo files to the repository. See above for how .mo files are managed using Crowdin.// 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'); |