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

Kimmo Suominen kimmo at global-wire.fi
Fri Jan 25 09:55:55 GMT 2008

I tried that already, but at least xgettext knows about the syntax of
the language (it is, after all, told about it being PHP).  It happily
skips comments.  I'd expect PoEdit to behave similarly (but maybe it
doesn't -- I haven't tested that).

My second thought was to extract the Plugin Name and Description fields
from the comment header and manually craft a pot (po) snippet that would
be merged with the other strings using the merge option to xgettext.
However, I didn't have time to write the script.  (And it would be UNIX-
centric if I wrote it.)

The "put more burden on the plugin author" approach would be to ask the
authors to duplicate the comments within __() calls inside some never
called code.  Mind you, if the plugin has an admin page, then its name
at least probably already gets translated (sort of by accident, though).

Best regards,
+ Kimmo
<A HREF="http://kimmo.suominen.com/">Kimmo Suominen</A>

On Fri, Jan 25, 2008 at 10:08:48AM +0100, Sören Weber wrote:
> It's only an optimistic assumption: the .po compiler hopefully does not
> care about whether a string is inside of PHP comments or not as long a as
> the string matches the .po's search condition (which usually is '__' and
> '_e' at the moment). I haven't verfied this yet.
> Therefore the description string can be encapsulated into a pseudo PHP
> function call and so will be recognized by the .po compiler. An example
> would look like:
> /*
> Plugin Name: Blah
> Version: 2.0.2
> Plugin URI: http://example.com
> Author: Me
> Author URI: http://example.com
> Description: __("My super duper plugin")
> Text Domain: myplugin
> */
> The encapsulating __(" ") needs to be stripped away by the WP core before
> it accesses the gettext functions with the description string. One
> downside of this solution is, that even the strings of inactive plugins
> will be loaded this way.
> I agree with Peter Westwood that this solution also requires a third
> translation function for the WP core to avoid that for these strings the
> variable names will end up in the WordPress catalogue file.
> > On Jan 25, 2008 6:25 AM, Stephen Rider <wp-hackers at striderweb.com> wrote:
> >> Text Domain: myplugin
> >
> > Sounds neat & simple, but how does the plugin author add the required
> > strings (plugin name, desc etc....) to its .mo/.po(t) ?

More information about the wp-hackers mailing list