<?xml version="1.0" encoding="UTF-8"?>
<rss version="2.0"
	xmlns:content="http://purl.org/rss/1.0/modules/content/"
	xmlns:wfw="http://wellformedweb.org/CommentAPI/"
	xmlns:dc="http://purl.org/dc/elements/1.1/"
	xmlns:atom="http://www.w3.org/2005/Atom"
	xmlns:sy="http://purl.org/rss/1.0/modules/syndication/"
	xmlns:slash="http://purl.org/rss/1.0/modules/slash/"
	>

<channel>
	<title>WP Wizard &#187; languages</title>
	<atom:link href="http://wpwizard.net/tag/languages/feed/" rel="self" type="application/rss+xml" />
	<link>http://wpwizard.net</link>
	<description>I ❤ WordPress</description>
	<lastBuildDate>Sat, 05 Mar 2011 12:30:52 +0000</lastBuildDate>
	<language>en</language>
	<sy:updatePeriod>hourly</sy:updatePeriod>
	<sy:updateFrequency>1</sy:updateFrequency>
	<generator>http://wordpress.org/?v=3.0.4</generator>
		<item>
		<title>Setting up a multilingual WordPress site</title>
		<link>http://wpwizard.net/customizing-wordpress/setting-up-a-multilingual-wordpress-site/</link>
		<comments>http://wpwizard.net/customizing-wordpress/setting-up-a-multilingual-wordpress-site/#comments</comments>
		<pubDate>Tue, 19 Jan 2010 14:25:40 +0000</pubDate>
		<dc:creator>Stian Andreassen</dc:creator>
				<category><![CDATA[Customizing WordPress]]></category>
		<category><![CDATA[CMS]]></category>
		<category><![CDATA[languages]]></category>
		<category><![CDATA[template]]></category>
		<category><![CDATA[theme]]></category>
		<category><![CDATA[wordpress]]></category>

		<guid isPermaLink="false">http://stianandreassen.com/?p=316</guid>
		<description><![CDATA[With just a simple Template and script in place of wp_list_pages(), you can make multilingual WordPress sites.]]></description>
			<content:encoded><![CDATA[<p>I often have clients who need a <strong>multilingual website</strong>. This isn&#8217;t plug &amp; play when it comes to WordPress (though rumor has it WP 3.0 will support multiple sites in one install, which probably will make multilingual WP sites a breeze), but there are sollutions. WordPress’s <strong>Page</strong> system is pretty flexible, and can with just a few moderations be used for multiple languages.</p>
<h3><span id="more-316"></span>How-To:</h3>
<p>First off I add the <a href="http://www.wprecipes.com/wordpress-page-template-to-redirect-to-first-child-page">Redirect To First Child Template</a> to the <strong>Theme</strong>. What this does, is look for the first <strong>Child</strong> of a <strong>Page</strong>, and redirect to it. (To controll which Child is the first, I use the plugin <a href="http://wordpress.org/extend/plugins/my-page-order/">My Page Order</a>.) I then create a Page for each of the languages I want, employing the <strong>Redirect-Template</strong> on them. I then add what is to be the main menu items for each language, and add them as Children of their respective language Page. If the site has any subnavigation, I simply add these as Children to the Child-of-language-Pages. Follow me?</p>
<p>This gives me a rough navigation along the lines of:</p>
<ul>
<li>ENGLISH
<ul>
<li>Main Page</li>
<li>Products</li>
<li>About Us</li>
<li>Contact</li>
</ul>
</li>
<li>GERMAN
<ul>
<li>Startseite</li>
<li>Produkte</li>
<li>Wir über uns</li>
<li>Kontakt</li>
</ul>
</li>
<li>FRENCH
<ul>
<li>Page principale</li>
<li>Produits</li>
<li>A propos de nous</li>
<li>Contact</li>
</ul>
</li>
</ul>
<p>(Apologies for poor translation, if any, had to use Google Translator.)</p>
<p>Then I add the code for the navigation to the <strong>Theme</strong>. We can&#8217;t simply use <code>wp_list_pages()</code> for this, as it will simply output a list like the one above. Instead we use this script where we want our navigation to appear:</p>
<pre class="brush: php; highlight: [40]; title: ;">
&lt;?php
// CHECK IF WE ARE ON A PAGE
 if(is_page()) {
 $currenttitle = $post-&gt;post_title.'&lt;/a&gt;';
 $subpages = wp_list_pages('title_li=&amp;echo=0&amp;sort_column=menu_order&amp;depth=1&amp;child_of='.$post-&gt;ID);

 $id = $post-&gt;post_parent;
 $sidebar_title = get_page($id);
 if($sidebar_title) {
 $prevpageparent = $sidebar_title-&gt;post_parent;
 }
 rewind_posts();

 if($subpages) {
 $pages=wp_list_pages(&quot;title_li=&amp;echo=1&amp;sort_column=menu_order&amp;depth=1&amp;echo=0&amp;child_of=&quot;.$post-&gt;post_parent);
 $pagelisting = str_replace($currenttitle, $currenttitle.'&lt;div id=&quot;submenu&quot;&gt;&lt;ul&gt;'.$subpages.'&lt;/ul&gt;&lt;/div&gt;', $pages);
 echo $pagelisting;
 }

 elseif($post-&gt;post_parent &amp;&amp; $prevpageparent&gt;'0') {
 $parent = $post-&gt;post_parent;

 $id = $post-&gt;post_parent;
 $myquery = new WP_Query(&quot;page_id=$id&quot;);
 $currenttitle = $myquery-&gt;post-&gt;post_title.'&lt;/a&gt;';

 $subpages = wp_list_pages('title_li=&amp;echo=0&amp;sort_column=menu_order&amp;depth=1&amp;echo=0&amp;child_of='.$post-&gt;post_parent);

 $pages = wp_list_pages(&quot;title_li=&amp;echo=1&amp;sort_column=menu_order&amp;depth=1&amp;echo=0&amp;child_of=&quot;.$prevpageparent);
 $pagelisting = str_replace($currenttitle, $currenttitle.'&lt;div id=&quot;submenu&quot;&gt;&lt;ul&gt;'.$subpages.'&lt;/ul&gt;&lt;/div&gt;', $pages);
 echo $pagelisting;
 }

 else { wp_list_pages(&quot;title_li=&amp;echo=1&amp;sort_column=menu_order&amp;depth=1&amp;child_of=&quot;.$post-&gt;post_parent);
 }
 rewind_posts();
} else {
// WE ARE NOT ON A PAGE, BUT A POST, CATEGORY VIEW, ETC
// SO WE HAVE TO DEFINE THE DEFAULT LANGUAGE MANUALLY AT THE END OF THE STRING
 wp_list_pages(&quot;title_li=&amp;echo=1&amp;sort_column=menu_order&amp;depth=1&amp;child_of=1&quot;);
} ?&gt;
</pre>
<p><strong>Line 40 is important</strong>; if we&#8217;re <em>not</em> on a <strong>Page</strong> the script can&#8217;t traverse back to it&#8217;s source (the Page that defines the language), so we have to manually put in the ID for the language Page we want to use as default, f.i. ENGLISH, at the end of <code>child_of=</code>.</p>
<p><strong>Also note</strong> that this script is custom made to show vertical navigation, with any subnavigation positioned directly below its Parent both <em>when the Parent is active</em> and <em>when the Child is active</em>, like this:</p>
<ul>
<li>Main Page</li>
<li><strong>Products</strong>
<ul>
<li>Software</li>
<li><em>Hardware</em></li>
<li>Upgrades</li>
</ul>
</li>
<li>About us</li>
<li>Contact</li>
</ul>
<p>It can be shortened and/or modified for other needs and types of navigation.</p>
<h3>A few notes:</h3>
<ul>
<li>It&#8217;s easiest to add the links for each language into the <strong>Theme</strong> manually. If you want to use flag icons, or simply text links, you can simply add: <code>&lt;a href="&lt;?php echo get_bloginfo('home').'/english/'; ?&gt;"&gt;English&lt;/a&gt;</code> and so forth.</li>
<li>If you want the <em>ENGLISH &gt; Main Page</em> to be the default Front Page, simply go to <strong>Settings &gt; Reading</strong> in <strong>WP-admin</strong> and set Static Page: ENGLISH to display as Front Page.</li>
<li><strong>And most important:</strong> This won&#8217;t take you from the English <strong>Product</strong> Page to the French <strong>Produits</strong> Page by clicking the flag. When you change language, you will be redirected to the Front Page of the selected language!</li>
</ul>
<div class="shr-publisher-316"></div>]]></content:encoded>
			<wfw:commentRss>http://wpwizard.net/customizing-wordpress/setting-up-a-multilingual-wordpress-site/feed/</wfw:commentRss>
		<slash:comments>0</slash:comments>
		</item>
	</channel>
</rss>

