views:

35

answers:

1

I am localizing some PHP/XHTML using the gettext() function in a WordPress plugin. WordPress has 'aliases' for these functions such as __() and _e(), the latter of which automatically echoes the arguments.

Now, most of my localization has gone pretty straightforward, such as:

<h3><?php _e('Authentication', 'domain'); ?></h3>

However, I am wondering what to do in the following situation:

<p>
  <strong>Note</strong>: Be <em>sure</em> not to mix them up! The public and private keys are not interchangeable!
</p>

As you can see, XHTML is mixed into the message for emphasis of certain words. I am wondering how I should go about localizing this. I could of course remove the strong and emphasis tags to make this a lot easier, but is that really necessary when localizing? There's no way to create this form of emphasis? I would imagine one way of localizing this would be to use printf or some variation of it, but I am not really sure on the details. Or should I just include the XHTML in the localized string?

Thanks!

+1  A: 

Why don't you do something like this?

<p>
  <strong><?= _('Note', 'domain'); ?></strong>: <?= _('Be <em>sure</em> not to mix them up! The public and private keys are not interchangeable!', 'domain'); ?>
</p>
Alix Axel
Thanks, that's too obvious I can't believe I missed it. Probably because I was unsure of whether or not it was okay to include the xhtml in the localized string. But I guess there's no problem with that then. Thanks!
Jorge Israel Peña
Please, stop using short_open_tags ! http://www.php.net/manual/en/ini.core.php#ini.short-open-tagThanks :)
OcuS