[wp-hackers] Re: no-code-duplication i18n for WordPress

Lionel Elie Mamane lionel at mamane.lu
Tue Mar 4 07:37:09 GMT 2008


On Mon, Mar 03, 2008 at 03:48:19PM -0800, kingler wrote:

> You should probably also post this on the polyglots maillist, as that
> is where discussion about internationalization happens.
> http://lists.automattic.com/mailman/listinfo/wp-polyglots

OK, will do.

> From what you are proposing here, you would like to add comments to
> the directly hard-coded English texts in the WP source codes, right?

Yes, but not only that. When the directly hard-coded English texts in
the WP source code contain variable references, I'd like replace to
replace them by a sprintf.

For example,
 wp_die("Could not connect to DB", 'Fatal Error');
would become
 /* WP_I18N_START */ wp_die("Could not connect to DB", 'Fatal Error'); /* WP_I18N_END */
but
 wp_die("Could not connect to DB host $db, maybe it is down?", 'Fatal Error');
would become
 /* WP_I18N_START */ wp_die(sprintf("Could not connect to DB host %s, maybe it is down?", $db), 'Fatal Error'); /* WP_I18N_END */

That is so that the .po file entries for the second example look like:
 msgid "Could not connect to DB host %s, maybe it is down?"
(one entry with the full format string) and not
 msgid "Could not connect to DB host "
 msgid ", maybe it is down?"
(two entries with pieces of sentences).

> That will not affect any functionalities, but will help the
> automatic build process in the Debian packaging. This sounds like a
> great idea.

The suggestion is that this become your localisation teams' way to
produce localised WP tarballs, too. They would do something like:

 - download http://wordpress.org/latest.tar.gz
 - download wp-static.pot (the .pot file with the hard-coded English
   strings that are tagged with the special comments, automatically
   generated by my script).
 - produce the LL.po, compile it to LL.mo
 - tar xfz latest.tar.gz
 - /path/to/wp-i18n-tools/translate-static wordpress /path/to/mofile
 - tar cfz wordoress wordpress-LL-VERSION.tar.gz
 - upload the tar to their usual place, put the LL.po file in the i18n
   SVN, ...

This allows them not to have to play catch-up with code changes: code
automatically stays the same, they only have to deal with strings and
.po files and my script does the rest.

And indeed, the plan for Debian is that we won't muck with all the
wordpress-LL-VERSION.tar.gz, only download the English one, scrape the
i18n SVN for all the .po files (I already have the script written for
that) and then run "translate-static" to create all internationalised
versions. This allows Debian to contain (as far as _source_ is
concerned) only one copy of the code, only one copy to update on
updates (whether security updates or new version updates or bugfix
updates).

-- 
Lionel


More information about the wp-hackers mailing list