Oct 08 2012

Howto: Updating WPML From Free to Commercial

I tried to manage with WPML – the last free version of WPML. It works great with WordPress up to version 3.2.1. However, I soon discovered that I need to update my WordPress because of some security fixes introduced in the newer versions. This also meant that I needed to buy the commercial version of the great plugin.

Update Procedure


I first purchased my copy of WPML plugin from the site. I chose the version “Multilingual Blog” over “Multilingual CMS” because I weighed that I don’t need the additional translation features of the more expensive CMS. Additionally, I thought I could later upgrade to CMS, should I find need to extended features.

Manual Upgrade

Unfortunately I cannot use this option in my test environment because I cannot install anything through WordPress but I must instead upload the source files to correct folders in the server. If I try to install with WordPress, I will get “Cannot create directory” error. So I began with disabling the old WPML plugin. Then using SSH I logged in to the server and copied the old plugin directory to a new name: [blog root]/wp-content/plugins/sitepress-multilingual-cms[blog root]/wp-content/plugins/sitepress-multilingual-cms. and deleted the old directory. With wget I downloaded my purchased WPML zip package straight to the plugins directory. Next I unzipped the compressed file and it was automatically decompressed as sitepress-multilingual-cms directory.

When I logged in to /wp-admin/ with my browser, the plugins page (/wp-admin/plugins.php) showed the old free version and the new bought version side by side. After activating the new version, I noticed that the Language Switcher that was earlier visible was now missing. I tried to enable it in Language Switcher Options by selecting the placement in sidebar and pressing “Apply”. However this did not work. It just rendered a thin red box that supposedly should have had some error message in it. Then I tried to enable it in Appearance → Widgets by drag and dropping the Language Selector to the sidebar. This time it worked!


In Dashboard, I selected WPML → Theme & plugins localization → Translate using .mo files.
The next problem was that there were pieces of strings not translated here and there: tagline, “posted in”, “Topics”, commenting, etc. All displayed in English no matter what language was selected. Damned. The “String Translation” module of WPML used to take care of these but since they now belong to the more expensive CMS package I decided to to some extra work to get them translated.

Extra Work Required for Multilingual Blog Package

  1. Modifying PO/MO Files: Please refer to Customizing WordPress Translation how to operate with Poedit. Poedit does not have a functionality to add more translations to the po file so you need to open it with a text editor. Add new string pairs anywhere in the file, copy the syntax from the other pairs. When done, upload the mo file to wp-content/languages/. If WordPress cannot find your new translation string you can print the array of translations to check if is has been updated in mo file. Printing can be done in wp-includes/l10n.php in function translate:
    function translate( $text, $domain = 'default' ) {              
      $translations = &get_translations_for_domain( $domain );                        

    I had to save the po/mo file twice before my new strings were updated correctly in the mo file.

  2. Categories Widget: If you want to customize the title of categories, it can be easily done by setting the title in Appearance → Widgets → Categories → Title. By default WordPress however does not support it to be translated so you need to modify WordPress core code a bit. In the file wp-includes/default-widgets.php add localization function to the title setting condition in the widget function, e.g. wrap $instance[‘title’] inside __():
    class WP_Widget_Categories extends WP_Widget {                                  
      function widget( $args, $instance ) {
        $title = apply_filters('widget_title', empty( $instance['title'] ) ? 
                               __( 'Categories' ) : __( $instance['title'] ), 
                               $instance, $this->id_base);
  3. Theme String “posted in”: Although I had “posted in” in my translation mo file, WordPress could not find the translation. I spent many hours debugging this until I noticed that the string was not “posted in” but “posted in ” with an additional space in the end. I corrected this in the theme (both single.php and index.php) and it started working.
  4. Theme Domain: Go through your theme files and make sure that all translation function calls, __() that is, are using your theme’s domain. E.g. <?php _e(‘Not Found’, ‘elegant-grunge’) ?>.
  5. Error: ‘msgstr’ is not a valid PHP format string, unlike ‘msgid’. Reason: In the directive number 1, the character ‘k’ is not a valid conversion: The translation po file had:

    #: index.php:35 search.php:19
    #, php-format
    msgid "% comments"
    msgstr "% kommenttia"

    I deleted the line #, php-format and Poedit compiled mo file without errors.

  6. Capitalization: If you wonder why your string is not translated, check that it is written in exactly the case. For example “No comments” does not translate if it is written “No Comments” in the translation po file.
  7. Blog Description/Tagline: You need to add translation of the tagline to the po file and then make sure that your theme uses translation functions (__() or _e()) where the tagline is displayed. Please note that you may need to modify the code where it is displayed. The theme author may have used bloginfo(‘description’) which echoes the tagline. In this case you need to save the tagline into a variable using get_bloginfo(‘description’) and print it later using the translated echo _e() function:

    In header.php:
    (Somewhere in the beginning)
    <?php $tagline = get_bloginfo('description'); ?>
    <?php _e($tagline); ?> 

Automated Upgrade

In the WPML site there are detailed instructions how to install WPML via WP Installer and get it to be up to date. For most production environment this is the way to go.

After upgrading WPML Multilingual CMS to the new and commercial version there is only one WPML visible in the plugins, unlike in the manual procedure.

Optional: Update WordPress

I decided to update my WordPress before modifying its core files. I just used “Please update now” link displayed at the top of the wp-admin dashboard.


If you want to save some extra bucks and are not afraid to modify some code, then the cheaper WPML Multilingual Blog can be used to achieve a good localization. I would suggest to consider if the extra work is worth the save in dollars.

Leave a Reply