One Website, All the Languages

How to Set up a Multilingual WordPress Website
With MultilingualPress


A talk by @thorstenfrommen

Who’s That Guy?

Thorsten Frommen

Thorsten Frommen

  • WordPress engineer and technical project lead at Inpsyde
  • Part of Inpsyde’s QA team.
  • Lead developer of MultilingualPress.
  • Certified PHP engineer, web development professional, and tester.

MultilingualPress Logo

MultilingualPress in a Nutshell

The multisite-based free open source plugin for multilingual websites.

  • Create an unlimited number of related (language) sites.
  • Choose from and customize (currently) 174 languages.
  • Translate whatever post or term you like.
  • Make translations available via menu, widget or Quicklinks.
  • No lock-in effect!

The Automagic of MultilingualPress

  • hreflang information:
    • HTML link elements in header;
    • HTTP headers indicating different language versions.
  • Language negotiation:
    • redirect users according to their browser settings.

MultilingualPress Tech Facts

  • Mature object-oriented PHP codebase. JavaScript, too!
  • Public API including functions, and action and filter hooks.
  • Rich technical inline documentation.
  • WordPress.com VIP-approved (for inclusion in VIP Go sites).
  • Development in public GitHub repository. Contribute!

Multisite Dashicon

WordPress Multisite

“A multisite network is a collection of sites
that all share the same WordPress installation.”

“The individual sites […] do not have their own directories on your server,
although they do have separate directories for media uploads […],
and they do have separate tables in the database.” WordPress Codex

Why Multisite?

  • Core WordPress feature:
    • no custom functionality (i.e., solidly integrated);
    • not (yet) widely, but heavily used (e.g., WordPress.com).
  • Performance:
    • no heavy computations for each and every post;
    • lots of cached data.
  • Search Engine Optimization:
    • truly separate language versions of your content;
    • permalinks like you set them up—no rewrites, promised.

Excursus: How to Go Multisite

…in five slides.

Allow Multisite

Add the following to your wp-config.php file:

define( 'WP_ALLOW_MULTISITE', true );
Just put it somewhere before the first require statement.

Network Setup

As Administrator, go to Tools › Network Setup at wp-admin/network.php:

Network Setup

Update Your wp-config.php File

Add the following just below the new WP_ALLOW_MULTISITE constant:

define( 'MULTISITE', true );
define( 'SUBDOMAIN_INSTALL', true );
define( 'DOMAIN_CURRENT_SITE', 'domain.tld' );
define( 'PATH_CURRENT_SITE', '/' );
define( 'SITE_ID_CURRENT_SITE', 1 );
define( 'BLOG_ID_CURRENT_SITE', 1 );

Update Your .htaccess File

Replace the current WordPress rules with the following:

RewriteEngine On
RewriteBase /
RewriteRule ^index\.php$ - [L]

RewriteRule ^wp-admin$ wp-admin/ [R=301,L]

RewriteCond %{REQUEST_FILENAME} -f [OR]
RewriteCond %{REQUEST_FILENAME} -d
RewriteRule ^ - [L]
RewriteRule ^(wp-(content|admin|includes).*) $1 [L]
RewriteRule ^(.*\.php)$ $1 [L]
RewriteRule . index.php [L]

Log in, Again

Congratulations! You’re a Super Admin now.

User Story I

I want to create a bilingual website from scratch.

Activate MultilingualPress

Go to the Plugins page in your Network Admin, and activate MultilingualPress.

Activate MultilingualPress

That’s it already. MultilingualPress can be used without any plugin settings.

Plugin activated

Set Up Your (Language) Sites

Edit your existing site.

Edit Site

Set the site language.

Set site language

Add a new site.

Add New Site

Connect Existing Posts

Change the relationship, select an existing post, and save your changes.

Connect existing post

You now have two related posts, and thus translations of each other.

Confirm post relationship

Translate Categories

Edit a category, select a translation, and save your changes.

Connect existing category

You now have two related categories, and thus translations of each other.

Confirm category relationship

Add a new category.

Add new category

On the other site now, add a new category, and select the according translation.

Add new category translation

Create and Translate a New Event (CPT)

Go to the Add new event page, and be confused.

Add new event, not

Go to the MultilingualPress settings page, and enable translation of Events.

MultilingualPress settings

Add a new event, for real this time.

Add new event

Create a copy of the original post for the other site.

Copy source post

By publishing, two related posts will be created. One on each site.

Publish

User Story II

I want to display all available language versions of the current page.

Use a Language Menu

Create a new menu, enable the Languages meta box, and add menu items.

Create menu

The front-end display of the menu totally depends on the theme, of course.

Menu front end

Use the Language Switcher Widget

Add the Language Switcher widget to a sidebar, and choose your desired settings.

Add widget

The front-end display of the widget, again, depends on the theme.

Widget front end

Use Quicklinks

Activate Quicklinks on the MultilingualPress settings page.

MultilingualPress settings

Choose your desired Quicklink position, and save your changes.

Quicklink position

The front-end display of the Quicklinks on a post.

Quicklinks front end

User Story III

I want my users to see my website in the most appropriate language.

Enable Language Negotiation

On the Sites page, you can see the redirect setting for each site.

Sites

Enable automatic redirection in the MultilingualPress settings tab for each site.

Redirect site setting

Confirm the redirect setting for each site.

Sites

User Story IV

I want to add a new language version to my multilingual website.

Duplicate an Existing Site

Add a new site, based on an existing one.

Duplicate site

Confirm the site settings.

Sites

Remove Unwanted Relations

Edit a post, remove the relationship with a translation, and save your changes.

Remove relationship

Remove Translations

Well, just go ahead and delete the post.

User Story V

I want to be able to administrate all language versions of my website.

…but I don’t speak Klingon.

Set Your Custom User-specific Admin Language

In your Personal Options, choose your preferred language for the Admin UI for all sites.

User admin language

User Story VI

I have problems with using MultilingualPress and plugin Whatsitsname.

Get in Touch With MultilingualPress People

How?

Get in Touch With Whatsitsname People

“Why is this a good idea?”

  • MultilingualPress doesn’t do much special.
  • Maybe the other plugin is not multisite-aware.
  • Simple fix for when Whatsitsname does too much:

function some_hooked_function() {

    // Bail if this is a multisite installation and the site has been switched.
    if ( is_multisite() && ms_is_switched() ) {
        return /* something, maybe */;
    }

    // Regular function code...
}

Take-aways

  • Use WordPress multisite for multilingual websites.
  • Actually, use MultilingualPress for multilingual websites.
  • MultilingualPress 3 will be requiring PHP version 5.4.0 or higher.
  • Inpsyde is hiring!

References and Further Reading

Thanks

@thorstenfrommen

slides.tfrommen.de/multilingualpress