Skip to end of metadata
Go to start of metadata

You are viewing an old version of this page. View the current version.

Compare with Current View Page History

« Previous Version 7 Next »

On This Page:

Plugin Translations.

Managing translations for Revive Adserver plugins.

 


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

The Revive Adserver code team uses poedit to edit the master English .po files.

3rd Party Plugins / Core Plugin Development

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).

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 to generate the .mo files for plugins manually - either because they will need to generate them to include as part of their 3rd party plugin, or so that they can simply see the proposed changes to .po files in a development environment.

Generating .mo Files

An updated .mo file can be generated from the .po file using poedit.

For core Revive Adserver plugins, do NOT commit changed .mo files to the repository. See above for how .mo files are managed using Crowdin.

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');
  • No labels