[wp-hackers] Improving Plugin (and Theme) metadata

Sabin Iacob iacobs at m0n5t3r.info
Tue Mar 4 20:10:23 GMT 2008


Ryan Boren wrote:
> That plus calling translate() instead of __() in the manage plugins
> page to avoid WP catalog pollution will work.  Ugly as hell, but it
> will work.  Care would have to be taken to make sure the strings in
> the plugin header match what is in __() exactly, new lines and all.
>   

actually, xgettext is smart enough to know what a PHP variable looks like:

iacobs at moria ~/tmp $ cat t.php
<?php
/*
 * Desc: __('awerwrtg')
 * Mumu: __('sdfgreyt')
 */
$tst = 'mumu';
echo __('asdfdfgsd');
echo __($tst);

?>
iacobs at moria ~/tmp $ xgettext -L PHP --keyword=__ -o - t.php
# SOME DESCRIPTIVE TITLE.
# Copyright (C) YEAR THE PACKAGE'S COPYRIGHT HOLDER
# This file is distributed under the same license as the PACKAGE package.
# FIRST AUTHOR <EMAIL at ADDRESS>, YEAR.
#
#, fuzzy
msgid ""
msgstr ""
"Project-Id-Version: PACKAGE VERSION\n"
"Report-Msgid-Bugs-To: \n"
"POT-Creation-Date: 2008-03-04 22:04+0200\n"
"PO-Revision-Date: YEAR-MO-DA HO:MI+ZONE\n"
"Last-Translator: FULL NAME <EMAIL at ADDRESS>\n"
"Language-Team: LANGUAGE <LL at li.org>\n"
"MIME-Version: 1.0\n"
"Content-Type: text/plain; charset=CHARSET\n"
"Content-Transfer-Encoding: 8bit\n"

#: t.php:7
msgid "asdfdfgsd"
msgstr ""

however, in order to avoid looking up the same string several times, we 
would need to add a noop function like _n($x){return $x;} to mark 
strings as translatable.

now, if the wordpress pot file is not generated by xgettext, things may 
get a bit more complicated :)



More information about the wp-hackers mailing list