[wp-polyglots] Mocha - generating L10n files from inside WordPress.

Jamie Talbot wppolyglots at jamietalbot.com
Mon Feb 5 10:33:44 GMT 2007


Hi Polyglots,

There are loads of people out there who want to localise WordPress, but the barrier to participating
is quite high if somebody has no experience using gettext or poEdit.  In an effort to lower this
barrier, I've written a plugin called Mocha, which lets people localise all three parts of WordPress
(core, plugins and themes) from one admin page.  It's not ready to go public yet, but it's to the
point where I think it's starting to become useful.  I'd really welcome feedback from anyone who
could take the time to test it out.

Usage should be very simple.  Go to Options->Mocha, make a couple of selections and click Get
Strings.  When you're done, click Save Translations.  You should see your changes take effect
immediately.  If Gengo is installed, the list of locales is auto-populated, otherwise you can type
the locale you want to use in a text box.

If a po file for your chosen language and type already exists, the po file is retrieved for editing.
 If it doesn't, the po file is copied from the base pot file.  If there is no pot file, one is
automatically generated from the __ and _e strings.  For core files, the Mocha zipfile includes
wordpress.pot and wordpress-21.pot.  Just because that's what I'm using here, the wordpress.pot file
is for 2.0.x.  If you are running WordPress 2.1, rename wordpress-21.pot to wordpress.pot.
(Basically, wordpress.pot should be the pot file for the version of wordpress you are running).

A good test of its capabilities might be to use Mocha to localise itself.  There's no mocha.pot file
in the distribution, so see how the auto-generation works and what information you think is missing.
 Be aware that WordPress Core Files contain more than 1000 strings, so it could take some time to
load up if you choose that option.

All feedback is welcomed of course, but I'd like comments specifically about any extra information
that you'd require in the headers, the file format and of course any bug reports.

Just as a precaution, make a backup of your po files somewhere before you let Mocha get near them -
it should be safe, but you wouldn't want to lose all your hard work!  It's tested and working on
2.0.x -> 2.2-bleeding, but still.

You can get it at http://jamietalbot.com/wp-hacks/mocha/mocha.zip

Caveats:

* It only works if the gettext tools are installed on the server - that would be most, if not all,
*nix servers.  The code is there for it to run on Windows, but it requires a couple of executables
and dll files, which I didn't want to redistribute with the plugin.

* It only works for plugins that are installed in their own folder.

* There isn't much error checking there yet - there's no matching of %s arguments, like poEdit does,
for example.  There's no checking to see if gettext exists yet either...

* It can't merge two catalogs yet.

* It doesn't write plural forms yet - mainly because I don't understand them.

* There's no Ajax spinning disk yet.

Future Plans:

* I'd like to put in a one-click submit to central repository button, where the localisations can be
made available for everyone.  I'd also like to use this to pull in localisations that are missing.

* Automerging of existing po file with new pot file whenever WordPress, a theme or a plugin is
updated (using version numbers).

Looking forward to your feedback,

Cheers,

Jamie Talbot.


More information about the wp-polyglots mailing list