Multilingual WordPress Sites
Overview[edit]
Information about setting up multilingual support for WordPress sites.
WPML WordPress plugin[edit]
Installation[edit]
WordPress "Installer" plugin[edit]
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[edit]
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[edit]
- 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[edit]
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.
If a page should remain untranslated even when viewed via the non-default language:
(E.g. the "Calendar and Events" page on the Thousand Oaks site.)
- WordPress Dashboard > Pages > The Page > Click the "translate" icon
- In the "Language" module click the "Copy content from English" button.
- Click "Publish".
- After the page reloads, click the "Overwrite with English content" button in the Language module.
This will keep the content of the page on the non-default language in sync with any edits made to the page in its default language.
Translating themes[edit]
Thousand Oaks[edit]
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; %>