5

One of the new features in WPML 1.4.1 will be language fallback for blog posts. This means, your translated blog can show either:

  • Only posts that have translation.
  • All posts – if there’s translation, show it, otherwise, show the post in the default language.

Our site includes pages and posts. We’re translating almost all pages, but very few posts. Now, when folks sign up to our German feed (for example), they’ll get our news in German, if they’re available and otherwise, in English.

This new feature applies only to blog posts and RSS feeds. There’s no language fallback for pages and we’re not planning to add it (for reasons such as site navigation integrity, parent/son relationships, etc.).

Want to try this new version?

Not so fast. This new version is tested very basically and has some work-in-progress functionality.

By any means, don’t install it on any live site. It’s just for testing on local test sites.

OK? No live sites please. So, here’s the download link – sitepress-multilingual-cms1.4.1.dev-2.zip

Like any time you update a plugin manually, remember to deactivate and activate it again after you install the new version.

To enable this feature, go to WPML->Languages. It’s under More options (available only in Advanced mode).

New blog posts filter in WPML 1.4.1
New blog posts filter in WPML 1.4.1

Creating a test version of your site

This is a bit unrelated to this particular version, but I think it’s going to be useful to read anyway.

It’s always a good idea to have a local version of your complete site and test things on it. This is how we create local test versions for our sites:

  1. Install Apache, PHP and MySQL. If you’re on Linux or Mac, it’s already there. For Windows, you can use XAMPP.
  2. Create a local domain by editing your hosts file. On Linux it’s /etc/hosts. On Windows – C:\Windows\System32\drivers\etc\hosts.
  3. Create a MySQL database and install WordPress locally.
  4. Copy the entire wp-contents directory from your online site to your local test site (use ZIP to finish this before Christmas).
  5. Do a database dump of your live site. You can do that using phpmyadmin or using mysqldump from an SSH command line.
  6. Download the dump and edit it. Replace all places where your online domain appears with the local domain. There should be thousands of places to replace.
  7. Import the database dump to your database. It’s easiest using a command line: mysql -u USER -pPASSWORD DB_NAME < DB_DUMP_FILE

Everything should look the same on your local test site, except you’re browsing your site locally from backup. It runs faster and can’t cause any damage.

Install whatever it is you’re testing in the local site and check it. If everything running smooth you can also install on the live site. Problems? No harm done, you’ve only messed the test site and you can import the database and try again.

Of course, this setup only needs to be done once. It’s a good idea to keep that local test site handy for the next time you’re trying something new.

Having said this, even if this current version of WPML runs flawlessly on your test site, please don’t install it on any live site. We’re going to add some migration logic to it and it will be very difficult to apply if you update now.

Let us know what you think

Like the new blog language fallback? Any problems, suggestions or ideas? Leave a comment here.

And, have a good weekend! I’m off, for my.

5 Responses to “Language fallback for blog posts”

  1. Ah, thanks Amir!

    I was actually looking for this feature for my upcoming website: pages will be translated but not (most of) blog posts and I didn’t want to duplicate all untranslated content.

    • Only posts. If we add that for pages also, we’re opening a whole bag of problems with site navigation and parent-child relationships.

      When enabled, the blog page will list all posts. If there’s translation, it will show it and otherwise, it will show the default language post.

  2. Hi,

    I like the script very much and I am using it in combination with the plugin “FeedWordPress” in order to syndicate RSS-feeds in different languages from various sources.

    Is there a way to assign a syndicated post to a particular language automatically, assuming I know that the RSS-feeds is in that particular language? I now have to do it myself, which is cumbersome.

    Thanks and keep up the good work!