You are currently browsing the page Multi languages in the Movable Type category.

Multi languages

How to make a site in two languages with Movable Type? Using the Entry Body and Extended Entry fields. Screenshot.

Before starting, your pages must be in PHP ! Go to your detailed settings, then click on the publishing tab, set the file extension to php and rebuild your site.

Step 0

Translate your entries in the extended entry field. (See previous screenshot). If you're already using this field for something else, you might want to use the RightFields plugin for Movable Type.

Step 1

First, we have to modify the templates. I recommend you to separate your menu. Make a Movable Type module for your menu and call it. The Movable Type tags I'm giving are only examples. Your entries/main templates should look like this:

<?php
$x = basename($_SERVER['QUERY_STRING']);
if(!$x || $x == en) { ?>
<!-- English is the default language
If english is selected, let's show MTENTRYBODY -->
<MTEntries>
<h1><$MTEntryTitle$></h1>
<MTEntryBody>
</MTEntries>
<? } elseif ($x == "fr") { ?>
<!-- The user has selected French now,
let's see if there's a french version with MTEntryIfExtended... -->
<MTEntries>
<MTEntryIfExtended>
<!-- Yay, a French version is available! Let's show it with MTENTRYMORE -->
<MTEntryMore>
</MTEntryIfExtended>
<MTElse>
<!-- If there's no French version, let's show the English one,
and let's apologize -->
<h1><$MTEntryTitle$></h1>
<p>Sorry, only available in english.</p>
<$MTEntryBody$>
</MTElse>
</MTEntries>
<!-- DO NOT DELETE THE FOLLOWING CODE!! -->
<? } ?>

Step 2

Done? If you want to test your pages, try to go to thepageurl.php?fr or thepageurl.php?en ! Now we have to make the menu. As I said, you'd better make a separate module for it, but this is not required.

<?php
$x = basename($_SERVER['QUERY_STRING']);
if(!$x || $x == en) { ?>
Enter your codes for your normal menu here...
Do as usual.
<? } elseif ($x == "fr") { ?>
Put your normal menu, but add "?fr" at the end !
<!-- DO NOT DELETE THE FOLLOWING CODE!! -->
<? } ?>

Step 3

Now just apply this scheme to all your archives templates... To link to the other version, just use this code:

<a href="<MTEntryPermalink>?fr"><MTEntryTitle></a>

Print This Post Print This Post



Related Posts

Sponsors


Leave a Comment

Works? Doesn't work? Other tips? Please leave a comment! :)

XHTML: You can use these tags: <a href="" title=""> <abbr title=""> <acronym title=""> <b> <blockquote cite=""> <code> <em> <i> <strike> <strong>

To post codes, please go to SimpleCode and transform your codes first, so that it will displayed properly. Indeed, < and > need to be converted to &lt; and &gt; :)


Close
E-mail It