Plugins that do not get shipped with b2evolution have to provide their own translations.
Inside your plugin’s directory (e.g.
example_plugin/), create a directory called
locales, where you create a subdirectory and a
_global.php file therein for each locale that is supported:
Note: The directory structure is the same as what you have below
To help you generate this, b2evo has a ‘'’xg.php”’ script in
/gettext/xg.php. This does not get shipped with releases, but is available from the CVS: http://evocms.cvs.sourceforge.net/evocms/b2evolution/gettext/xg.php?view=markup Get xg.php. You will also need the file
_pofile.class.php in the current directory, which you can get also from the http://evocms.cvs.sourceforge.net/viewvc/evocms/b2evolution/blogs/inc/locales/_pofile.class.php?view=log CVS repository.
The process to create this is:
- First the plugin needs a
messages.pot(PO-template) file. This gets generated whenever some translation strings in the plugin’s source get changed:
- A) Then you’ll need a
messages.pofile for every language (e.g. for ‘’de_DE'’). You’ll have to do the following only to init the
messages.pofile of a language (if there is not already one):
- B) If there’s already a
messages.pofile for a locale, you can update it from
messages.pot. The following will update
- Edit the
messages.pofile with a normal text editor or tool like poedit or KBabel. You should normally only have to update untranslated or fuzzy strings.
- Convert the
messages.pofile to the final
_global.phpfile. The following command will create a new
- Send your updated
_global.phpfiles to the Plugin maintainer (if you are not maintaining it yourself, of course)
Plugins only use the
_global.php file, not the
messages.po files. The messages files are only important to people who want to translate the Plugin.
So, you do not have to package them with your plugin and if your plugin only has very few strings to be translated, you could even skip the whole procedure above and just create the
_global.php files "by hand", in the following way:
It’s just an array, in fact. But providing the "gettext-Extra-Step" might help your translators a lot, because there are powerful editors for
messages.po files available.
The charset for the localized strings must be supplied in the
$trans['xx_XX'] array inside of the ‘’ (empty) key, which is the default gettext behaviour.
E.g., for de_DE it may look like:
Because "Content-Type:" is the only line used by b2evo, you may also just add
'' => 'Content-Type: text/plain; charset=ISO-8859-1', into your
- The locales that your plugin supports also need to be supported by b2evo. And the charset of the
_global.phpfile must be the same as defined there (see
- The Plugin has to use the
$this->T_('Hello world!');(and not the global function with the same name).
Submit plugin translations
If you want to translate some plugin, you basically have to get the existing
messages.po file (if there’s any) and update that, or get the template (
messages.pot), create a new translation based on it.
Then, submit the
messages.po file to the plugin author.
Created by • Last edit by on Oct 07, 2013