Multilingual support for WordPress: improved!

I’ve been using wordpress ZdMultilang plugin to  write articles in several languages.

The truth is that the plugin is awesome. It works great! The only thing I missed was the lack of support for keeping separate comments, so the users reading the post in English only see the comments that the English-readers version made, and so for the Spanish readers/commenters. To me it seemed logic to keep separate comments since an English person will probably not understand Spanish, and he could get discouraged to leave a comment if he sees that all the comments are in Spanish. The opposite case is also true.

Some time ago  I asked Anthony Petitbois, the original writer of the plugin (awesome work), if he could make a couple of improvements to the plugin.

This request was around 10 months ago, and I wanted this functionality of keeping separate comments for a new blog, so I though:

“Hey! I never did a WordPress  plugin, the ZdMultilang is Open Source… it should not be that hard! Let’s contribute to the project!”

Around 4 hours and a half later, the plugin was completely written and this blog was updated. After several tests it seems that everything works like a charm! Then, hopefully it should work perfectly for any version of WordPress >= 2.8.x

What improvements are included?

  • zd_multilang_get_locale(): it’s a function to get the current language(Inglés, Español, …), before that, you had to use the global $locale
  • The ability to keep separate comments for each language
  • The ability to keep all comments in the same thread, to behave as the plugin was already behaving

Please note that ALL existing comments, prior to the installation and activation of this plugin improvement, will be shown for ALL languages. From my point of view it makes sense to show all comments since I have no idea of which language where those comments written.

Please note as well that I added a new option to the translation preferences, so the user (you) can control whether you want to enable this functionality or you want the blog to behave as always (with all the comments for all the languages).  Anyway, whatever option you choose, ALL comments will be visible from the administration panel, so you could easily administer comments in ALL languages 😉

The only additional thing you will have to do, to get this new functionality working, is to update the comments.php file in the current theme you are using, and change the form for posting comments:

From this:

action=”<?php echo get_option(‘siteurl’); ?>/wp-comments-post.php”

to this:

action=”<?php echo get_option(‘siteurl’); ?>/wp-comments-post.php?lang=<?=zd_multilang_get_locale()?>

In the following link you could download a TGZ that contains the DIFF of the zdmultilang.php changes, the zdmultilang.php with the changes, and the readme.txt file:

Finally, I updated the version to 1.2.5, although this can produce “future” problems, unless I convice Anthony to include these improvements on the next version of the plugin 😉

Trackback URL

,

  1. Pau Sánchez
    29/10/2009 at 1:24 am Permalink

    This is a comment in English. If you check the Spanish version of the post, you will see Spanish comments only (or at least, comments for those users who have read the Spanish version of this post).

  2. Sam
    29/10/2009 at 2:48 am Permalink

    Hi Pau,

    I have already posted a message on Zdmultilang Website, but I’m wondering if you know how modified the plugins to have the page title in the all language in the address bar of navigator.
    Thanks for your help !

    Sam

  3. Pau Sánchez
    29/10/2009 at 8:36 am Permalink

    Hi Sam,
    You mean that the html <title> is not translated in WP “pages” right?
    I haven’t noticed until you mentioned. I don’t know how hard would it be to fix, but it should probably be easy.

    I need to make some time for looking at this. I’ll let you know after I have a look to it – expect some days to pass, but I’ll have a look at this. Promised 🙂

  4. Anthony
    19/11/2009 at 10:44 am Permalink

    Hey Pau,

    I’ve included the changes to the current dev version of the plugin, it’s tested and works with the new features. I don’t know yet when this will be released but I’ll tell you 😉

    Do you have an account on WordPress Dev site ? so that I can add you as a contributor ?

  5. Pau Sánchez
    20/11/2009 at 1:15 am Permalink

    Hi Anthony!
    Great to see you, I’m glad everything works 🙂

    I don’t currently have any account in there, although I can create one.

    I’ll send you an e-mail.

    Pau