CommentMailer Localization on The Fly

Being one of WordPress localization maintainer, I’m concerned to the fact that WP should be internationally accepted and easily localized into many languages. It applies to plugins too, so I always gettext all WP plugins I ever wrote (unfortunately only 2 of them are fully maintained and available for download here). :)

Lately I’ve been working on my 2nd plugin–commentmailer (currently in ver 0.1)–and found that it needs special i18n treatment. Unlike most plugins that need gettext to localize their appearance on the web page, commentmailer prints the localized strings into an e-mail.

Even as a non-English blog author, sometimes you do need to answer your visitor’s comment in English. More than that, if you are a true polyglot and writes your blog in several languages, you will also have to answer the comment in as many languages as you use. If you use commentmailer plugin to email those answers, you probably want to localize the email depending on the content language.

I’ve provided the localization schema to commentmailer since the first time I released it. But switching which language to use is as painful as changing your WordPress locale environment, unless you are using some multilingual plugin.

So I put some function that makes commentmailer prompt the user (blog author) with an option of which language he/she want to use to answer the visitor’s comment. It searches for commentmailer localization files inside your plugin dir and print a locale selection menu to your comment form.

Here’s what you need to do to take some advantage of this new feature:

  1. Update your commentmailer plugin to the latest version
  2. Use the localization template (commentmailer.pot) included in the distribution file to localize the plugin. Name your localization file (the machine object) commentmailer-[locale].mo and put it directly inside the plugin directory–next to commentmailer.php
  3. Using the corresponding WordPress localization is recommended since it will localize the date format printed in you e-mail
  4. When you are writing a reply in the comment form, select the language in which you are writing
  5. Of course you have to write the comment content in your language to match your preferred locale