Multilingual WordPress Sites: Difference between revisions

From Littledamien Wiki
Jump to navigation Jump to search
No edit summary
Line 27: Line 27:


There is an option in the WPML settings that controls what happens if a page has not been translated. The two options boil down to either throw a 404 error or show the post in the default language.
There is an option in the WPML settings that controls what happens if a page has not been translated. The two options boil down to either throw a 404 error or show the post in the default language.


===Translating themes===
===Translating themes===

Revision as of 18:00, 9 October 2012

Overview

Information about setting up multilingual support for WordPress sites.

WPML WordPress plugin

WordPress Multilingual Plugin

Installation

WordPress "Installer" plugin

There is a page on the site that describes using the "Installer" WP plugin to install WPML components. The Installer plugin allows you to install paid plugins, as they cannot be hosted by WordPress.org.

The Installer plugin did not work when installed on my development server. It needs to search "repositories" which should be loaded by default. Even when I manually entered the WPML repository it did not load.

Installing on local development server

It's also possible to download the WPML components as zip files from the WPML website. Each component gets unzipped into the WP plugins directory. After the files are installed, return to the WP admin, click on "Plugins" and activate the component.

Settings

  • WordPress Dashboard > WPML (left column) > Languages
    • "Add/Remove languages" button to add the necessary languages
    • Language URL format:
      Different languages in directories (e.g. http://thousandoaks.dbarchowsky.com/es/)
    • Blog posts to display: All posts (display translation if it exists or posts in default language otherwise)

Translating posts and pages

Once the WPML CMS component is installed, activated, and configured, a column is added to the Posts and Pages listings pages. If the page has not been translated then a "plus" sign will appear in the column.

Clicking on the plus sign will lead to a page where a translated version of the page can be entered.

There is an option in the WPML settings that controls what happens if a page has not been translated. The two options boil down to either throw a 404 error or show the post in the default language.

Translating themes

See theme localization

Thousand Oaks

Existing set of theme files edited to support the two languages.

Spot edits to existing files to check the current language, inserting language-appropriate paths and links.

<%php if (ICL_LANGUAGE_CODE=="en"): %>
<li><a href="http://mysite.com/">English link</a></li>
<%php if (ICL_LANGUAGE_CODE=="es"): %>
<li><a href="http://mysite.com/es/">Spanish link</a></li>
<%php else: %>
<li>I don't know what language it is!</li>
<%php endif; %>

Examples