Not a developer? Go to MovableType.com

Ask an Expert

Switching to different language versions of a site

Asked by Bill
Posted August 7, 2012, in Featured.

I have a website in the Thai language and I have been requested to mirror that site in English. The site would be a 1 to 1 copy of the original. Every Page and Entry would have a corresponding Page or Entry on the English site. I have been asked if there is a way to put a Thai/English toggle link that would allow me to switch to the same page on the corresponding site.

Is something like this possible with MT tags in my template headers? I’m not sure where to begin on this one.

Back

3 Answers

François Nonnenmacher

François Nonnenmacher on August 7, 2012, 2:04 a.m. Reply

Bill, here’s how I do it on my own site with MT: use the language negotiation capability of browsers and the web server (Apache in my case, here’s the feature in detail). The process works as follows:

  • setup each site to produce files that end with .html.LANG where LANG is the ISO country code (.fr for my French site and .en for the English one)
  • make sure the sites templates are outputing pages exactly in the same place on the server. this means index.html.en and index.html.fr, or /folder/mypage.hml.en and /folder/mypage.html.fr are produced next to each other on the server document root
  • make sure that all corresponding pages share the same “slug” in the URL, i.e. they have the same basename in the two sites.
  • configure your web server to handle language negotiation. For Apache, the instructions are in the link I provided above).
  • optionally you can provide a simple link to switch language, using a cookie, if your web server also knows how to handle that. For Apache, it’s explained on the same page under “Language Negotiation Exceptions”.

If you want to see it live (and study the code for the language switch via cookie), you can check http://ubiquitic.com/ - If your browser language preference is set to anything but French, you should see any page in English. If you set ti in French, you’ll see them in French.

The advantage of this system is that all your pages can have exactly the same URL, because you do not need to expose the .LANG part of it. This means that I can send people to my home page with the URL above (or any other, really), without thinking about the language (they’ll get what they prefer). The only caveat I see with this solution is a potential drawback in SEO (meaning that the language in which you chose to write the basenames will be reflected in the URLs, but I don’t know how much weight search engines place in URLs). But many big sites have URLs written in English even so the pages language isn’t, so reckon it’s a small issue.

Dan Wolfgang

Dan Wolfgang on August 7, 2012, 7:09 a.m. Reply

Hey Bill — I recently built a custom field specifically for this purpose: the Reciprocal Entry Association (and Reciprocal Page Association) fields that are part of the More Custom Fields plugin.

The field is used to link two entries together, and a popup entry picker lets the author easily find which entries they want linked together. When editing Entry A and linking to Entry B, an association from Entry B back to Entry A is automatically created. When deleting an association, the reciprocal is also removed. The best part: on the Edit Entry screen is a link to edit the reciprocal Entry, allowing authors to easily jump between Entries.

The advantage of this system is that it’s a familiar and user-friendly interface to build the cross-language link. A benefit for my client’s use (though perhaps a drawback for your use) is that entries must be explicitly linked together.

Shmuel Fomberg

Shmuel Fomberg on August 8, 2012, 10:52 p.m. Reply

Hi.

Just a month ago I created a plugin exactly for your problem: https://github.com/semuel/mt-plugin-multilangsite

The plugin uses some MT5 features (such as the listing framework) and generally assumes MT5, so it won’t work on MT4.

It let you makes multiple language versions of a site and manage which page needs update. If you will look in the TODO section, you can see that I planed to add a tag for switching between languages, but decided to wait and see if someone will want to use this plugin.

So if you do, I will add the tag.

Shmuel.

François Nonnenmacher

Founder of Ubiquitic, a web consultancy based in Noumea, New Caledonia. François has more than 10 years of experience with Movable Type (from the time it was just Mena and Benjamin Trott in a garage!) and has implemented it in small and big business sites, such as the blogs of the Capgemini Group, as well as the blogs of Le Figaro, the first online news site in France.

Website: http://ubiquitic.com/
Twitter: @François Nonnenmacher

Dan Wolfgang

Dan is an engineering creative and uses his vast knowledge of the web to solve unique client problems with specialized solutions. Complex or straightforward, his focus is to find the most efficient, functional, elegant, and stable solutions for each project. 10 years in web engineering and 14 more in the print publishing industry give him a special insight to the needs, restrictions, and workflows of content publishers, both traditional and new media. Dan is an active Movable Type community member who has written and contributed to countless plugins including some of the most popular: More Custom Fields, Poll Position, and Asset Image Quality.

Website: http://uinnovations.com
Twitter: @danwolfgang

Shmuel Fomberg

Website: http://www.shmuelfomberg.com

Ask An Expert