Bỏ qua điều hướng
7

Do you enjoy searching for WordPress translations and installing them in your sites? If not so much, you’re going to like WPML 2.6.0. We’ve added automatic download for WordPress core translations. It’s in beta and you’re welcome to test.

When you run a multilingual site, you need to translate content, but that’s not all. Some of the texts come from the theme, some from plugins and some from WordPress itself.

While your theme and most plugins usually comes with .mo files that give you the translations you need, WordPress doesn’t. You need to look for these .mo files, download and install them.

Then, when WordPress upgrades, you have to repeat this process.

WPML 2.6.0 lets you forget about translation files for WordPress. It will download them for you and keep them updated when WordPress updates. As an extra bonus, you can forget about WordPress .mo files altogether. We’re saving the translations in WPML’s String Translation table. This means, that you don’t even need to make that cryptic ‘languages’ directory writable, or create it.

How WPML 2.6.0 Gets Translations

We’ve written a (fairly complex) script that scans the entire WordPress translations repository. The structure of that repository “not so consistent” (to put it nicely), but we don’t care. We read it and learn where translations for different languages exist. Our script creates an XML directory that we’ve stored on our CDN (content delivery network), for super-fast access.

WPML 2.6.0 will load that XML file when it needs to get WordPress translations. This include first-time install, new languages or WordPress updates. You can also tell WPML to check manually.

Go to WPML->Theme and plugins localization. You’ll notice a new option for “Select how to get translations for WordPress core”. When you set it to “WPML will automatically download translations for WordPress”, WPML takes over.

WordPress core translation downloader

Once enabled, you’ll see three new columns in the languages list. The first column tells you when you last got translation for that language. The next column tells which translations are available. The last column includes the actual download buttons.

Click on Review changes and update for each of the languages.

WPML Downloads the Best Matching Translation for Each Language

WPML will download the best .mo file for your WordPress version and the selected locale. For example, if you’re using WordPress 3.4.1 and need translation for Argentine Spanish, WPML will look for a locale ‘es_AR’. If it cannot find it, it looks for the default Spanish locale (es_ES).

Then, WPML looks for the best matching WordPress version. If it can find a translation branch for what you’re running, it gets it. Otherwise, it tries the ‘trunk’ version. Finally, it looks for the most recent version.

WPML Shows You What’s New or Updated

After WPML downloads the .mo file with the updated translation, it lets you review it before applying these new translations.

Confirmation screen before updating translations

Normally, you’ll just go to the bottom of this page and update the translations. If, for some reason, you want to keep back some changes, you can un-select specific strings. You’ll see both updated and new translations.

Finally, Translations Appear in WPML’s String Translation

Once you’ve approved the new translations, they appear in WPML’s String Translation screen.

WordPress translation in WPML’s String Translation

Since we’re saving these translations to the database, there’s no more need to create a ‘translations’ directory and save WordPress .mo files there. WordPress translations will be saved just like any other translation for your site.

In case you’re wondering, there’s no performance change. WPML loads all these translations in one SQL query and looks them up efficiently. It’s not faster or slower than using .mo files.

Of course, there are plenty of advantages to having these translations in WPML’s String Translation tables. For example, you can edit them and they are included in any DB backup that you do.

Download and Try

To get this download, go to your WPML account and click on Downloads. You need the recent Beta version. Download and unzip it. The plugins that have changed are WPML core and the String Translation plugin. You need them both for this new feature (yes, this means that translation auto-download is only available for WPML CMS version, which includes the String Translation module).

Please don’t run this on production sites yet. If you’re just setting up a development site, it should be fine. This version of WPML is fresh out of the oven. We ran a bunch of development tests on it, but it didn’t go through our production QA.

What do you think? Let us know in your comments!