<?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>WPML&#187; Tutorials</title>
	<atom:link href="http://wpml.org/category/tutorials/feed/" rel="self" type="application/rss+xml" />
	<link>http://wpml.org</link>
	<description>Using WordPress to build full multilingual websites</description>
	<lastBuildDate>Wed, 28 Jul 2010 14:08:37 +0000</lastBuildDate>
	<language>en</language>
	<sy:updatePeriod>hourly</sy:updatePeriod>
	<sy:updateFrequency>1</sy:updateFrequency>
	<generator>http://wordpress.org/?v=3.0</generator>
		<item>
		<title>Theme and Plugin Translation, WPML or MO Files?</title>
		<link>http://wpml.org/2010/06/theme-and-plugin-translation-wpml-or-mo-files/</link>
		<comments>http://wpml.org/2010/06/theme-and-plugin-translation-wpml-or-mo-files/#comments</comments>
		<pubDate>Wed, 30 Jun 2010 08:32:46 +0000</pubDate>
		<dc:creator>amir</dc:creator>
				<category><![CDATA[Tutorials]]></category>

		<guid isPermaLink="false">http://wpml.org/?p=5025</guid>
		<description><![CDATA[WPML 1.7.9 includes a significant change in the String Localization engine. We&#8217;ve talked about it before, but I think that we never really gave a comprehensive guide about translating themes and plugins. Here goes. Translation Languages First, let&#8217;s talk a minute about which languages you&#8217;re translating between. If the default language of your site is [...]]]></description>
			<content:encoded><![CDATA[<p><strong>WPML 1.7.9 includes a significant change in the String Localization engine.</strong></p>
<p><strong>We&#8217;ve <a href="http://wpml.org/2010/06/default-language-other-than-english/">talked about it before</a>, but I think that we never really gave a comprehensive guide about translating themes and plugins. Here goes.</strong></p>
<h2>Translation Languages</h2>
<p>First, let&#8217;s talk a minute about which languages you&#8217;re translating between.</p>
<p>If the default language of your site is English, you can just skip this section. Otherwise, please pay full attention &#8211; this is important stuff.</p>
<p>Your theme and plugins needs to be translated from English. Even if the default language for your site is Spanish (for example) and you&#8217;re translating only to Portuguese (yet, another example), English is involved too.</p>
<p>The original language of almost all themes and surely all plugins is English. If you&#8217;re using .mo files, they would include translation from English to both Spanish and Portuguese. Yup, although you don&#8217;t have English anywhere in your site&#8217;s contents, it still appears in many places, so you actually need to translate from English to your languages.</p>
<p>Normally, folks don&#8217;t need to worry too much about it, because they just download .mo files. So, why are we making a big deal of it?</p>
<p>Because WPML&#8217;s String Localization mechanism works exactly like GetText. It will translate everything from English to other languages. This means that if you&#8217;re using it also to translate admin texts, these texts need to be in English. We&#8217;ve talked about this a bit (with an example) in this <a href="http://wpml.org/2010/06/default-language-other-than-english/">blog post</a>.</p>
<h2>How to Translate</h2>
<p>Now that we understand which languages to use, we need to start translating.</p>
<p>WPML gives you two options for translating strings. You can either use the GetText .mo files or use WPML&#8217;s String Translation mechanism.</p>
<p>These two solutions are functionally very similar. There&#8217;s also no performance difference. The only difference is the process you&#8217;re using.</p>
<p>Have a look at our <a href="../documentation/getting-started-guide/theme-localization/">theme  localization</a> guide. It shows exactly where to click and what to do  to scan your theme and plugins.</p>
<h3>Translating With WPML&#8217;s String Translation</h3>
<p>WPML&#8217;s String Translation editor allows you to enter translations for each string in each language. It&#8217;s a simple editor, with search functionality. This interface is convenient if you&#8217;re translating for yourself, or if your translators already have WordPress user accounts.</p>
<p>In case you&#8217;re using our <a href="http://wpml.org/content-translation/">professional translation</a>, your translators don&#8217;t need to touch the String Translation editor or log in to WordPress. Just click on the button to send the strings to your translators and you&#8217;re done.</p>
<h3>Translating Using .mo Files</h3>
<p>MO files are like dictionaries, telling how to translate strings from on language to another. You would need to have as many MO files as your site&#8217;s languages.</p>
<p>The process of translating with MO files goes like this:</p>
<ol>
<li><strong>Create a POT file with the strings to translate.</strong> There are many tools for that. WPML includes a robust PHP scanner and can produce these POT files for you.</li>
<li><strong>Send the POT files to your translators.</strong> You might want to know that ICanLocalize also provides <a href="http://www.icanlocalize.com/site/services/software-localization/po-file-translation/">translation service for PO / POT files</a>. You&#8217;re also welcome to learn more about it in the <a href="http://www.icanlocalize.com/site/tutorials/how-to-translate-with-gettext-po-and-pot-files/">tutorial on translating PO and POT files</a>.</li>
<li><strong>Get the PO and MO files from the translators and upload to your site.</strong> Each translator should return at least a PO (Portable Object) file. The PO file is the text version of the translation. From that, you can create a MO (Machine Object) file.</li>
</ol>
<h2>How is it Working for You?</h2>
<p>Leave a comment and tell what you&#8217;re doing for theme and plugins localization!</p>
]]></content:encoded>
			<wfw:commentRss>http://wpml.org/2010/06/theme-and-plugin-translation-wpml-or-mo-files/feed/</wfw:commentRss>
		<slash:comments>1</slash:comments>
		</item>
		<item>
		<title>Testing on WordPress 3.0</title>
		<link>http://wpml.org/2010/05/testing-on-wordpress-3-0/</link>
		<comments>http://wpml.org/2010/05/testing-on-wordpress-3-0/#comments</comments>
		<pubDate>Thu, 27 May 2010 14:16:00 +0000</pubDate>
		<dc:creator>amir</dc:creator>
				<category><![CDATA[Tutorials]]></category>

		<guid isPermaLink="false">http://wpml.org/?p=4780</guid>
		<description><![CDATA[Following the good experience we had with WordPress 3.o, it looks like it&#8217;s time to start thinking about upgrading. But, with great power comes great responsibility. WordPress 3.0 is a major change from previous versions. True, it uses the same tables, but a lot of the API has changed. This can cause existing plugins and [...]]]></description>
			<content:encoded><![CDATA[<p>Following the <a href="http://wpml.org/2010/05/custom-types-in-wordpress-3-simplified-our-site/">good experience</a> we had with WordPress 3.o, it looks like it&#8217;s time to start thinking about upgrading.</p>
<p>But, with great power comes great responsibility. WordPress 3.0 is a major change from previous versions. True, it uses the same tables, but a lot of the API has changed. This can cause existing plugins and your theme to go wild.</p>
<p>I&#8217;d like to tell about what we did to make sure everything runs smooth after the migration.</p>
<h2>Migrating to WordPress 3.0</h2>
<h3>1. Backup</h3>
<p>First, you should do a complete backup. I just zipped everything from the <em>wordpress</em> directory (including WordPress core itself). Then, created a database backup.</p>
<p>You can make selective file backup as well, but a few more MB of backup are not going to hurt anyone and its way easier to use, should anything go wrong.</p>
<h3>2. Create a test site</h3>
<p>Going from WordPress 2.9.0 to 2.9.2 is pretty safe, but the jump to WordPress 3.0 calls for a staging site.</p>
<p>Create a new test site and unzip the files backup you made before.</p>
<p>Next, you need to copy the database.</p>
<p>For this, you can&#8217;t just copy. You need to edit the SQL dump. Open any text editor and do a global replace for the site&#8217;s domain. Supposing your live site is www.justgreat.com and your staging site is dev.justgreat.com, replace all:</p>
<pre>www.justgreat.com -&gt; dev.justgreat.com</pre>
<p>This SQL dump replacement means that everything in the staging site goes to the correct URL. Now, you can apply the database.</p>
<h3>3. Check that your test site is good</h3>
<p>So far, we haven&#8217;t done much. We just have a full copy of our live site where we can test on. Check that it works correctly and we&#8217;ll move on.</p>
<h3>4. Update to WordPress 3.0</h3>
<p>And, we&#8217;re ready. Now, get the <a href="http://wordpress.org/nightly-builds/wordpress-latest.zip">latest WordPress nightly build</a>. Unzip it over your current version <strong>in the staging site</strong>.</p>
<p>Log in to the WordPress Admin. The first thing you&#8217;ll see if that WordPress suggests to update the database.</p>
<p>And, you&#8217;re done. Now, you&#8217;re seeing how your site looks like in WordPress 3.0.</p>
<p><strong>Is it working?</strong></p>
]]></content:encoded>
			<wfw:commentRss>http://wpml.org/2010/05/testing-on-wordpress-3-0/feed/</wfw:commentRss>
		<slash:comments>3</slash:comments>
		</item>
		<item>
		<title>Multilingual Themes that Translate Well</title>
		<link>http://wpml.org/2010/04/multilingual-themes-that-translate-well/</link>
		<comments>http://wpml.org/2010/04/multilingual-themes-that-translate-well/#comments</comments>
		<pubDate>Fri, 23 Apr 2010 08:30:25 +0000</pubDate>
		<dc:creator>amir</dc:creator>
				<category><![CDATA[Multilingual]]></category>
		<category><![CDATA[Themes]]></category>
		<category><![CDATA[Tutorials]]></category>

		<guid isPermaLink="false">http://wpml.org/?p=4534</guid>
		<description><![CDATA[GetText allows translating texts in themes and plugins, but in order to work right, you must create texts that translate well. We&#8217;ll show you frequent mistakes and how to correct them. GetText is a GNU&#8217;s text localization package. It allows replacing text in one language with texts in another language. We&#8217;ve already talked about using [...]]]></description>
			<content:encoded><![CDATA[<p><strong>GetText allows translating texts in themes and plugins, but in order to work right, you must create texts that translate well. We&#8217;ll show you frequent mistakes and how to correct them.</strong></p>
<p><a href="http://www.gnu.org/software/gettext/">GetText</a> is a GNU&#8217;s text localization package. It allows replacing text in one language with texts in another language.</p>
<p>We&#8217;ve already talked about <a href="http://wpml.org/2009/05/wordpress-theme-localization/">using GetText to build multilingual themes</a>. Now, we&#8217;ll talk about how to make the theme&#8217;s texts translatable, from the translator&#8217;s point of view.</p>
<h2>Complete sentences only, please</h2>
<p>Translators cannot accurately translate single words. They need to see the entire sentence in order to translate correctly.</p>
<p>For example, what does <strong><em>You must be</em></strong> mean?</p>
<p>In English, the word <strong><em>be</em></strong> has one meaning. But, in Spanish, <strong><em>be</em></strong> mean what you are (<em>ser</em>) or where you are (<em>estar</em>). There&#8217;s no way a translator can translate this correctly without seeing the entire sentence.</p>
<p>This is the code that&#8217;s responsible for the text:</p>
<p><code>&lt;?php _e('You must be') ?&gt; &lt;a href="&lt;?php echo get_option('siteurl'); ?&gt;/wp-login.php?redirect_to=&lt;?php echo urlencode(get_permalink()); ?&gt;"&gt;&lt;?php _e('logged in') ?&gt;&lt;/a&gt; &lt;?php _e('to post a comment.') ?&gt;</code></p>
<p>So, what do we do?</p>
<h2>Using full sentences with placeholders</h2>
<p>What we&#8217;ve actually done in this example is concatenate several parts into a sentence. The way we did it broke the sentence into different pieces, losing all meaning in the process.</p>
<p>Here is this same thing, built with a single sentence a placeholder:</p>
<p><code>&lt;?php printf(__( 'You must be &lt;a%s&gt;logged in&lt;/a&gt; to post a comment' ), ' href="'.get_option('siteurl') . '/wp-login.php?redirect_to=' . urlencode(get_permalink()) . '"') ?&gt;</code></p>
<p>What we&#8217;ve done is:</p>
<ol>
<li>Create one large text that includes a placeholder.</li>
<li>Use printf to replace the placeholder with an actual value.</li>
</ol>
<p>The translator now needs to translate this sentence:</p>
<blockquote><p><em>You must be logged in to post a comment</em></p></blockquote>
<p>The translator can easily translate this entire sentence.  No questions to ask and no problems translating!</p>
<p>Besides being easier to translate, we need to remember that in different languages words appear in different order. Supplying the complete sentence with placeholders will allow the translator to flip the order of words and produce grammatically correct (and sensible) transaltions.</p>
<h2>Really advanced case (appears in every WP site)</h2>
<p>Look at this PHP code. It appears in almost every WordPress site in the comments section.<br />
<code>&lt;h3&gt;&lt;?php comments_number(__('No Responses'), __('One Response'), __('% Responses') );?&gt;<br />
&lt;?php _e('to') ?&gt; &amp;#8220;&lt;?php the_title(); ?&gt;&amp;#8221;&lt;/h3&gt;</code></p>
<p>The translator would have to translate the word <strong><em>to</em></strong>. But, it&#8217;s impossible without understanding how <strong><em>to</em></strong> is used in the sentence.</p>
<p>The word <strong><em>to</em></strong> is part of a sentence, which would be:</p>
<blockquote><p>3 Responses <strong>to</strong> new widgets</p></blockquote>
<p>Once the translator sees the entire sentence, it all becomes clear and easy to translate.</p>
<p>To turn this into a single sentence, we&#8217;ll use this PHP code:<br />
<code>&lt;h3&gt;&lt;?php printf(__('%s to %s'),<br />
get_comments_number_ml(__('No Responses'), __('One Response'), __('% responses') ),<br />
'&amp;#8220;' . get_the_title() . '&amp;#8221;')?&gt;&lt;/h3&gt;</code></p>
<p>This code produces a full sentence to translate. Now, the translator can produce correct translation to your comments heading.</p>
<p><em>Note: we&#8217;ve replaced the standard WP get_comments_number with an identical function that returns the comment count as a value and doesn&#8217;t echo to the screen. You can download this PHP code from <a href="http://wpml.org/wp-content/uploads/2010/04/get_comments_number_ml.zip">get_comments_number_ml.zip</a>.</em></p>
<h2>What about your themes?</h2>
<p>Are your multilingual themes built for correct translation?</p>
<p>An easy way to test is to open your <em>.po</em> file in <em>poedit</em> and review the strings. If you&#8217;re seeing anything that isn&#8217;t clear by itself, look for it in the source and revise.</p>
]]></content:encoded>
			<wfw:commentRss>http://wpml.org/2010/04/multilingual-themes-that-translate-well/feed/</wfw:commentRss>
		<slash:comments>1</slash:comments>
		</item>
		<item>
		<title>Building a Company Site with Thesis and WPML</title>
		<link>http://wpml.org/2010/04/building-a-company-site-with-thesis-and-wpml/</link>
		<comments>http://wpml.org/2010/04/building-a-company-site-with-thesis-and-wpml/#comments</comments>
		<pubDate>Sun, 11 Apr 2010 04:15:04 +0000</pubDate>
		<dc:creator>amir</dc:creator>
				<category><![CDATA[Themes]]></category>
		<category><![CDATA[Tutorials]]></category>

		<guid isPermaLink="false">http://wpml.org/?p=4497</guid>
		<description><![CDATA[Intro In this guest post, Wolf-Dieter Grabner, tells about building a multilingual corporate site using WordPress, Thesis theme and WPML. Wolf-Dieter gives both the why and the how, which are equally interesting. It shows how WordPress is used as a time saving tool for both the web developer and the client. The Client SBA Roll [...]]]></description>
			<content:encoded><![CDATA[<h2>Intro</h2>
<p><em>In this guest post, </em><a href="http://www.theflow.cc/"><em>Wolf-Dieter Grabner</em></a><em>, tells about building a multilingual corporate site using WordPress, Thesis theme and WPML.</em></p>
<p><em>Wolf-Dieter gives both the why and the how, which are equally interesting. It shows how WordPress is used as a time saving tool for both the web developer and the client.</em></p>
<h2>The Client</h2>
<p><a href="http://wpml.org/wp-content/uploads/2010/04/SBA-english-version.png" rel="lightbox[4497]"><img class="alignright size-medium wp-image-4500" title="SBA-english-version" src="http://wpml.org/wp-content/uploads/2010/04/SBA-english-version-215x300.png" alt="" width="215" height="300" /></a><a href="http://www.sba-rss.com/">SBA Roll Shop Solutions</a> is one of the leading manufacturers of roll grinders. While most of us haven&#8217;t seen these high precision devices in real life, a lot of everyday products like paper or metal foils depend on extremely even rolls.</p>
<p>In January 2010 SBA approached me through one of my clients, asking me for a new homepage, as the old one was still based on frames and static HTML pages.</p>
<p>We had a short time available, because there was an upcoming conference in South America that the company was going to attend so designing the website first and writing the content afterwards was not a good option. I supplied the members of the company&#8217;s marketing with a basic setup of <a href="http://www.wordpress.org/">WordPress</a> and <a href="http://www.diythemes.com/">Thesis</a> and they could easily start writing the content right away.</p>
<h2>WordPress and Thesis</h2>
<p>What I really like about WordPress is the ease of use in comparison to other content management system for this type of site (for example <a href="http://www.typo3.org">Typo3</a> or <a href="http://www.drupal.org/">Drupal</a>). If you can use a text editor or word processor, you&#8217;re ready to use WordPress. Thanks to plugins like <a href="http://www.wpml.org/">WordPress Multi Language (WPML)</a>, even very complex sites work surprisingly well.</p>
<p>Clients often have problems imagining a prototype or draft version if is looking too rough and unfinished. After using quite a lot of open-source and custom-made templates, I have been switching to <a href="http://www.pearsonified.com/">Chris Pearson&#8217;s</a> <a href="http://www.diythemes.com/">Thesis Framework</a> for all recent projects: I find it to be the best solution to design prototypes. It is very easy to customize, once you are accustomed to the use of the custom CSS file and the template&#8217;s hooks system. By keeping the template and the adaptions for the individual site separate, updating the template does not imply any changes to the site.</p>
<h2>Going International</h2>
<p><a href="http://wpml.org/wp-content/uploads/2010/04/SBA-chinese-version.png" rel="lightbox[4497]"><img class="alignright size-thumbnail wp-image-4501" title="SBA-chinese-version" src="http://wpml.org/wp-content/uploads/2010/04/SBA-chinese-version-150x125.png" alt="" width="150" height="125" /></a>Right from the start, SBA wanted the site to be available in multiple languages. About one month after the <a href="http://www.sba-rss.com/">English version</a>, also the <a href="http://www.sba-rss.com/zh-hans/">Chinese version</a> went online; German will follow.</p>
<p>Setting up WPML took about five minutes. Apart from choosing the languages, almost nothing was changed from the defaults.</p>
<h2>Using WPML with Thesis</h2>
<p>Thesis&#8217; default drop-down menu is quite nice as you can rearrange the items in the theme&#8217;s preferences and also rename pages. Nevertheless, it does not work with WPML right out of the box: it&#8217;s showing all languages of an individual page at the same time instead of just the current language.</p>
<p>As an alternative, one can use WPML&#8217;s drop down menu but it does not support more than two levels, which was not meeting the client&#8217;s requirements. <a href="http://www.adahas.com/work/navigo/">Navigo 1.2</a> offers XHTML strict output, works with WPML and offers custom classes and IDs for formatting the drop down menu. It proved to be a nice companion to <a href="http://users.tpg.com.au/j_birch/plugins/superfish/">Superfish</a>, a jQuery enhanced drop down menu.</p>
<p>Using Thesis <code>custom_functions.php</code>, the navigation can easily be added to the template:</p>
<h2>Adding your own Navigation to Thesis</h2>
<pre>function custom_thesis_nav_menu() {
    echo ('&lt;div id="top-nav"&gt;&lt;div id="top-nav-fix"&gt;');
    if(function_exists('navigo')) {
      navigo('sort_column=menu_order&amp;level1=sf-menu&amp;level2=l2&amp;level3=l3');
    }
    echo ('&lt;/div&gt;&lt;/div&gt;');
}

remove_action('thesis_hook_before_header', 'thesis_nav_menu');
add_action('thesis_hook_before_html', 'custom_thesis_nav_menu');</pre>
<p>The example shows a simple function that&#8217;s creating the needed nesting and also calling navigo with some parameters to get the desired markup.</p>
<p>After removing the default Thesis navigation, the new function is added to the appropriate hook. Two div-tags were used to fix the position of the drop down menu even when scrolling the page. After adding the Superfish CSS markup to the template&#8217;s custom.css file, everything works nicely. When not pinning the menu to the top of the page, you can of course use <code>thesis_hook_before_header</code> for it. The following source snippet allows you to use the default drop down menu of WPML with Thesis:</p>
<pre>function thesis_navigation_wpml() {
    do_action('icl_navigation_menu');
}

remove_action('thesis_hook_before_header', 'thesis_nav_menu');
add_action('thesis_hook_before_header', 'thesis_navigation_wpml');</pre>
<h2>Breadcrumb Navigation</h2>
<p>Because of the large number of pages, we have also added WPML&#8217;s breadcrumb navigation to the site. Again, by using <code>custom_template.php</code>, it&#8217;s a matter of minutes:</p>
<pre>function custom_thesis_WPMLbreadcrumbs() {
    echo ('&lt;div id="breadcrumbs"&gt;');
    do_action('icl_navigation_breadcrumb');
    echo ('&lt;/div&gt;');
}

add_action('thesis_hook_before_content', 'custom_thesis_WPMLbreadcrumbs');</pre>
<p>Add some custom styles to <code>custom.css</code> and you&#8217;re done.</p>
<h2>Experience and next Steps</h2>
<p>WPML works just the way it should &#8211; even details like the XML sitemaps plugin. Being able to teach via Skype a Chinese sales person how to use the tool for translating the site is certainly a good thing.</p>
<h2>About the author</h2>
<p><em><img class="alignleft size-thumbnail wp-image-4505" title="wolf-dieter_0342" src="http://wpml.org/wp-content/uploads/2010/04/wolf-dieter_0342-100x150.jpg" alt="" width="100" height="150" />As a photographer with an engineering background and a business degree, Wolf-Dieter Grabner regularly works for clients like Coke, Universal Music, the Vienna Musikverein or Austrian petrol company OMV.</em></p>
<p><em>He&#8217;s lecturing visual communications at Linz University for Art and Industrial Design and still, he enjoys working on web projects a lot. One thing all his jobs have in common? Changing perspectives and bringing new views.</em></p>
]]></content:encoded>
			<wfw:commentRss>http://wpml.org/2010/04/building-a-company-site-with-thesis-and-wpml/feed/</wfw:commentRss>
		<slash:comments>0</slash:comments>
		</item>
		<item>
		<title>Video Tutorial &#8211; localizing themes using WPML</title>
		<link>http://wpml.org/2009/12/video-tutorial-localizing-themes-using-wpml/</link>
		<comments>http://wpml.org/2009/12/video-tutorial-localizing-themes-using-wpml/#comments</comments>
		<pubDate>Tue, 08 Dec 2009 15:09:21 +0000</pubDate>
		<dc:creator>amir</dc:creator>
				<category><![CDATA[Themes]]></category>
		<category><![CDATA[Tutorials]]></category>

		<guid isPermaLink="false">http://wpml.org/?p=3694</guid>
		<description><![CDATA[This tutorial shows how to translate your theme using WPML&#8217;s built-in translation interface. It works without any .mo files and you can edit translations from within WPML directly. The video (3 minutes) Steps to follow Go to the WPML menu and click on Advanced. Go to Theme localization. Select to translate the theme using WPML. [...]]]></description>
			<content:encoded><![CDATA[<p><strong>This tutorial shows how to translate your theme using WPML&#8217;s built-in translation interface. </strong>It works without any .mo files and you can edit translations from within WPML directly.</p>
<h2>The video (3 minutes)</h2>
<p><!-- Smart Youtube --><span class="youtube"><object width="400" height="250"><param name="movie" value="http://www.youtube.com/p/B0B4AD4FC6CC4161&amp;rel=0&amp;color1=d6d6d6&amp;color2=f0f0f0&amp;border=0&amp;fs=1&amp;hl=en&amp;autoplay=0&amp;showinfo=0&amp;iv_load_policy=3&amp;showsearch=0" /><param name="allowFullScreen" value="true" /><embed wmode="transparent" src="http://www.youtube.com/p/B0B4AD4FC6CC4161&amp;rel=0&amp;color1=d6d6d6&amp;color2=f0f0f0&amp;border=0&amp;fs=1&amp;hl=en&amp;autoplay=0&amp;showinfo=0&amp;iv_load_policy=3&amp;showsearch=0" type="application/x-shockwave-flash" allowfullscreen="true" width="400" height="250" ></embed><param name="wmode" value="transparent" /></object></span></p>
<h2><span id="more-3694"></span>Steps to follow</h2>
<ol>
<li>Go to the WPML menu and click on <strong>Advanced</strong>.</li>
<li>Go to <strong>Theme localization</strong>.</li>
<li>Select to <strong>translate the theme using WPML</strong>.</li>
<li>Make sure that the <strong>language locales are set correctly</strong> and that the WordPress .mo files are found in <em>wp-includes/languages</em>.</li>
<li>Review your themes strings and click to <strong>translate untranslated strings</strong>. This will send you to WPML String translation page.</li>
<li>Click on <em>translations</em>, next to each string, <strong>translate and save</strong>.</li>
</ol>
<p>Any edits that you make in WPML&#8217;s translation interface will appear in the site immediately. You don&#8217;t need to upload anything or change anything in the theme.</p>
<p>To work, the theme needs to be multilingual-ready. All strings need to be wrapped in <em>gettext</em> calls and have a textdomain argument. This is already standard practice for most WordPress themes. If you&#8217;re creating your own theme, you can check out the post about <a href="http://wpml.org/2009/05/wordpress-theme-localization/">how to build a multilingual-ready theme</a>.</p>
<h3>More reading</h3>
<ul>
<li><a href="http://wpml.org/documentation/getting-started-guide/theme-localization/">Theme localization in WPML&#8217;s getting started guide</a></li>
<li><a href="http://wpml.org/documentation/support/creating-multilingual-wordpress-themes/">Building multilingual themes</a> (the comprehensive guide)</li>
</ul>
]]></content:encoded>
			<wfw:commentRss>http://wpml.org/2009/12/video-tutorial-localizing-themes-using-wpml/feed/</wfw:commentRss>
		<slash:comments>3</slash:comments>
		</item>
		<item>
		<title>Creating a multilingual product catalog</title>
		<link>http://wpml.org/2009/09/creating-a-multilingual-product-catalog/</link>
		<comments>http://wpml.org/2009/09/creating-a-multilingual-product-catalog/#comments</comments>
		<pubDate>Tue, 29 Sep 2009 23:34:33 +0000</pubDate>
		<dc:creator>amir</dc:creator>
				<category><![CDATA[Tutorials]]></category>

		<guid isPermaLink="false">http://wpml.org/?p=2830</guid>
		<description><![CDATA[In this is guest post, Michael Wassmer explains how to build a multilingual product catalog using WordPress. The idea for this post came from a discussion in the forum about sharing custom fields and media between translations. The goal -  a multilingual product catalog with WordPress To set up my small bilingual shop I didn&#8217;t [...]]]></description>
			<content:encoded><![CDATA[<p><em>In this is guest post, <a href="http://www.michaelwassmer.net/">Michael Wassmer</a> explains how to build a multilingual product catalog using WordPress.</em></p>
<p><em>The idea for this post came from a discussion in the forum about <a href="http://forum.wpml.org/topic.php?id=376">sharing custom fields and media between translations</a>.</em></p>
<h2>The goal -  a multilingual product catalog with WordPress</h2>
<p>To set up my small bilingual shop I didn&#8217;t want to use a complex e-commerce CMS, WordPress was just the right thing for what I needed. Also I was looking forward to testing the WPML plugin on a slightly more complex project than the usual classical blog or website.</p>
<p>So, in my English/French online catalog, the products are each described in a dedicated post. To add a product I simply add a post in the back-end of WordPress, giving it the name of my product as title, typing the description in the content text-area, uploading the products photos to the images gallery of the post, and using the custom fields for values like price, reference and size.</p>
<p>Here&#8217;s how a product post in English (the default language) would look :</p>
<p><a href="http://wpml.org/wp-content/uploads/2009/09/post_example.jpg" rel="lightbox[2830]"><img class="alignnone size-medium wp-image-2832" title="post_example" src="http://wpml.org/wp-content/uploads/2009/09/post_example-300x207.jpg" alt="post_example" width="300" height="207" /></a></p>
<p>Now, after creating the original post for a product, how do I create the translated (French) version of it? Following WPML&#8217;s instruction, I simply click on the Language box under the post content window, click on &#8220;show&#8221; next to &#8220;Translations&#8221; and then click on &#8220;add&#8221;. It opens up a new post page where I can type in all the translated informations of my product : French title, French description, etc.</p>
<h2>Problem &#8211; translations duplicate product information</h2>
<p>But wait! Here is the annoying thing. I also have to type in again the custom fields values: reference, price and size. In my case those values are the same in any language so it makes no sense having to enter them twice. This is an obvious problem that would make me lose a lot of time if I had to type in the same information multiple times for each product post translation.</p>
<p>It&#8217;s the same issue with the product images, I don&#8217;t want to upload all the product photos a second time for the same product in it&#8217;s translated version. Logically, product photos are the same in any language, so I should be able to upload them only once.</p>
<p>So, let&#8217;s save the translated post just like this, <strong>without</strong> typing in a translation for the custom fields and <strong>without</strong> uploading the product images.</p>
<p>Ok, now let&#8217;s have a look at some code. Here&#8217;s a very basic example of a product listing page for a category (usually the <em>archive.php</em> file of your WP theme) :</p>
<pre>&lt;?php while (have_posts()) : the_post(); ?&gt;
  &lt;ul class = "product"&gt;
    &lt;li class = "title"&gt;&lt;a href="&lt;?php the_permalink() ?&gt;"&gt;&lt;?php the_title(); ?&gt;&lt;/a&gt;&lt;/li&gt;
    &lt;li class = "ref"&gt;&lt;?php echo get_post_meta($post-&gt;ID, 'Reference', true); ?&gt;&lt;/li&gt;
    &lt;li class = "price"&gt;&lt;?php echo get_post_meta($post-&gt;ID, 'Price', true); ?&gt;&lt;/li&gt;
  &lt;/ul&gt;
&lt;?php endwhile; ?&gt;</pre>
<p>That&#8217;s the classical loop. It shows a list of my products and the associated custom field values &#8211; Price and Reference.</p>
<p>Now if I click on another language in the language selector on the front-end of my website (French in my case), it shows the translation of the articles title, but it doesn&#8217;t show the reference and the price value. That&#8217;s normal, remember we didn&#8217;t enter them in the translated post..</p>
<p>So, how do I get WordPress to show the custom values I entered in the original English post ?</p>
<h2>Solution &#8211; sharing custom fields between translations</h2>
<p>Well, WPML is a powerful plugin that provides us with a very useful function to fetch those values from the original post, even on the translated pages.</p>
<p>We are going to use the <em>icl_object_id()</em> function and replace the previous code by the following :</p>
<pre>&lt;?php while (have_posts()) : the_post(); ?&gt;
&lt;?php
  // Get the original post ID (in my case the english one)
  $o_ID = icl_object_id($post-&gt;ID, 'post', false, 'en'); ?&gt;
  &lt;ul class= "product"&gt;
    &lt;li class = "title"&gt;&lt;a href="&lt;?php the_permalink() ?&gt;"&gt;&lt;?php the_title(); ?&gt;&lt;/a&gt;&lt;/li&gt;
    &lt;li class = "ref"&gt;&lt;?php echo get_post_meta($o_ID, 'Reference', true); ?&gt;&lt;/li&gt;
    &lt;li class = "price"&gt;&lt;?php echo get_post_meta($o_ID, 'Price', true); ?&gt;&lt;/li&gt;
  &lt;/ul&gt;
&lt;?php endwhile; ?&gt;</pre>
<p>Basically what we did was to retrieve the ID of the original post corresponding to any translated post, and using this ID to get the custom values. Depending on the original language of your posts, you can change the last parameter of icl_object_id (&#8216;de&#8217; for German, &#8216;fr&#8217; for French, etc.). You can get more information about the other parameters of this function <a href="http://wpml.org/documentation/support/creating-multilingual-wordpress-themes/language-dependent-ids/">here</a> and a list of other functions in the <a href="http://wpml.org/documentation/support/wpml-coding-api/">coding API page</a>.</p>
<p>That was for the custom fields, now how do I do the same with the image gallery?</p>
<p>Let&#8217;s take our first example and also show three thumbnails images for each post in the list:</p>
<pre>&lt;?php while (have_posts()) : the_post(); ?&gt;

&lt;?php
  // Get the original post ID (in my case the english one)
  $o_ID = icl_object_id($post-&gt;ID, 'post', false, 'en'); ?&gt;

  &lt;ul class= "product"&gt;
    &lt;li class = "title"&gt;&lt;a href="&lt;?php the_permalink() ?&gt;"&gt;&lt;?php the_title(); ?&gt;&lt;/a&gt;&lt;/li&gt;
    &lt;li class = "ref"&gt;&lt;?php echo get_post_meta($o_ID, 'Reference', true); ?&gt;&lt;/li&gt;
    &lt;li class = "price"&gt;&lt;?php echo get_post_meta($o_ID, 'Price', true); ?&gt;&lt;/li&gt;

&lt;?php

  // Get 3 thumbnails from the original post
  $args = array('post_type' =&gt; 'attachment','numberposts' =&gt; 3,'post_status' =&gt; null,'post_parent' =&gt; $o_ID);
  $attachments = get_posts($args);
  if ($attachments) {
    foreach ($attachments as $attachment) {
      echo '&lt;li class="thumbnail"&gt;'.wp_get_attachment_image($attachment-&gt;ID).'&lt;/li&gt;';
    }
  }
?&gt;
&lt;/ul&gt;

&lt;?php endwhile; ?&gt;</pre>
<h2>Summary</h2>
<p>You can easily customize this little script to fit your needs, showing more (or less) images or different sizes.</p>
<p>That&#8217;s it. Now we can show our product list in any language, and it will always contain all the product custom fields and images, even if technically these are only stored in the original post.</p>
<p>This gets really interesting for bigger catalogs with more languages. Imagine you have to change the price of a product in five languages. With the normal method you would have to edit all five posts. With this easy method you always have one &#8220;master&#8221; language with its posts containing the complete information about your products and translations reusing it.</p>
<p><em><strong>Michael Wassmer</strong> is a freelance web designer based in <strong>Barcelona</strong>, <strong>Spain</strong>. You can contact him at <strong>mike@michaelwassmer.net</strong></em></p>
]]></content:encoded>
			<wfw:commentRss>http://wpml.org/2009/09/creating-a-multilingual-product-catalog/feed/</wfw:commentRss>
		<slash:comments>13</slash:comments>
		</item>
		<item>
		<title>Switching between development and live sites</title>
		<link>http://wpml.org/2009/09/development-and-live-sites/</link>
		<comments>http://wpml.org/2009/09/development-and-live-sites/#comments</comments>
		<pubDate>Sun, 13 Sep 2009 18:26:04 +0000</pubDate>
		<dc:creator>amir</dc:creator>
				<category><![CDATA[Tutorials]]></category>

		<guid isPermaLink="false">http://wpml.org/?p=2541</guid>
		<description><![CDATA[How can we do a major update for a live WordPress site, while it&#8217;s already running? WPML is getting a major usability overhaul (by Joen Asmussen). This includes the WPML plugin and wpml.org. We&#8217;re going to do vast website changes, including theme edits, changes to page hierarchy and the addition of new pages. These changes [...]]]></description>
			<content:encoded><![CDATA[<p><strong>How can we do a major update for a live WordPress site, while it&#8217;s already running?</strong></p>
<p>WPML is getting a major usability overhaul (by <a href="http://noscope.com/">Joen Asmussen</a>). This includes the <a href="http://wordpress.org/extend/plugins/sitepress-multilingual-cms/">WPML plugin</a> and <a href="/">wpml.org</a>. We&#8217;re going to do vast website changes, including theme edits, changes to page hierarchy and the addition of new pages.</p>
<p>These changes can&#8217;t be done gradually. We need to build everything offline and then deploy to the production server. However, we can&#8217;t just copy the database over as the site is running. During this update, we&#8217;re still going to write new posts and people leave comments.</p>
<p>We need to figure out a way to take a snapshot of the current site, work on the changes offline and then apply all the changes at once and merge with new content that&#8217;s been created on the live site.</p>
<p>Here is a diagram of that process:</p>
<p><img class="size-full wp-image-2543 alignnone" title="wordpress_build_process" src="http://wpml.org/wp-content/uploads/2009/09/wordpress_build_process.png" alt="Initial build and offline rework process" width="395" height="444" /></p>
<p><a href="http://wordpress.org/search/staging?documentation=1&amp;forums=1">A search in WordPress Codex for staging</a>, reveals some interesting discussions about this, but nothing conclusive nor usable. People agree that it&#8217;s a problem, but no one has yet to create a full working process that can be used for any WordPress site.</p>
<p>The biggest challenge is merging between the development version and the live site. Remember that the live site keeps running while we&#8217;re working on the development version. When we update the live site with the new development version the new theme will upload, new pages created and some existing pages update. However, blog posts and comments that were written during that time will be preserved. It&#8217;s not trivial to do as posts and pages share the same table in WordPress.</p>
<p>The things that will need to move from the development site to the live server:</p>
<ol>
<li>Everything from wp-contents, including the theme, new uploaded files and plugins.</li>
<li>New entries in the wp_options table. These entries control the way the site and plugins are configured.</li>
<li>New pages and updates to existing pages.</li>
</ol>
<p>Many of our blog readers are professional designers and developers, so your feedback is very helpful. Do you have a process for moving a site from development to production? <strong>How do you handle major updates?</strong></p>
]]></content:encoded>
			<wfw:commentRss>http://wpml.org/2009/09/development-and-live-sites/feed/</wfw:commentRss>
		<slash:comments>2</slash:comments>
		</item>
		<item>
		<title>Your own URL shortener for WordPress</title>
		<link>http://wpml.org/2009/09/your-own-url-shortener-for-wordpress/</link>
		<comments>http://wpml.org/2009/09/your-own-url-shortener-for-wordpress/#comments</comments>
		<pubDate>Thu, 10 Sep 2009 20:13:35 +0000</pubDate>
		<dc:creator>amir</dc:creator>
				<category><![CDATA[Tutorials]]></category>

		<guid isPermaLink="false">http://wpml.org/?p=2518</guid>
		<description><![CDATA[Fancy links are great, but they generate huge URLs. These cause problems when you want to send links to others via email, instant message or Twitter. I&#8217;ll show a solution that doesn&#8217;t require any plugin, doesn&#8217;t go through an external service and doesn&#8217;t create any load on your site. WordPress has default link aliases to [...]]]></description>
			<content:encoded><![CDATA[<p>Fancy links are great, but they generate huge URLs. These cause problems when you want to send links to others via email, instant message or Twitter.</p>
<p>I&#8217;ll show a solution that doesn&#8217;t require any plugin, doesn&#8217;t go through an external service and doesn&#8217;t create any load on your site.</p>
<h2>WordPress has default link aliases to every page</h2>
<p>Let&#8217;s start with an example. This page talks about using Contact Form 7 multilingual:</p>
<p><a href="http://wpml.org/documentation/support/translation-for-texts-by-other-plugins-and-themes/how-to-use-contact-form-7-in-multilingual-websites/">http://wpml.org/wordpress-translation/translation-for-texts-by-other-plugins-and-themes/how-to-use-contact-form-7-in-multilingual-websites/</a></p>
<p>Do you think that&#8217;s a long URL, check out the Japanese version:</p>
<p><a href="http://wpml.org/ja/documentation-5/%e3%82%b5%e3%83%9d%e3%83%bc%e3%83%88/%e3%81%9d%e3%81%ae%e4%bb%96%e3%81%ae%e3%83%97%e3%83%a9%e3%82%b0%e3%82%a4%e3%83%b3%e3%81%a8%e3%83%86%e3%83%bc%e3%83%9e%e3%81%ab%e3%82%88%e3%82%8b%e3%83%86%e3%82%ad%e3%82%b9%e3%83%88%e7%bf%bb%e8%a8%b3/contactform7-m17n-steps/">http://wpml.org/ja/%E3%83%9E%E3%83%AB%E3%83%81%E3%83%AA%E3%83%B3%E3%82%AC%E3%83%AB/%E3%81%9D%E3%81%AE%E4%BB%96%E3%81%AE%E3%83%97%E3%83%A9%E3%82%B0%E3%82%A4%E3%83%B3%E3%81%A8%E3%83%86%E3%83%BC%E3%83%9E%E3%81%AB%E3%82%88%E3%82%8B%E3%83%86%E3%82%AD%E3%82%B9%E3%83%88%E7%BF%BB%E8%A8%B3/contactform7-m17n-steps/</a></p>
<p>It&#8217;s got 306 characters! Doesn&#8217;t even fit into two tweets.</p>
<p>But, try these two:</p>
<ul>
<li><a href="http://wpml.org/documentation/support/translation-for-texts-by-other-plugins-and-themes/how-to-use-contact-form-7-in-multilingual-websites/">http://wpml.org/?page_id=2496</a></li>
<li><a href="http://wpml.org/ja/documentation-5/%e3%82%b5%e3%83%9d%e3%83%bc%e3%83%88/%e3%81%9d%e3%81%ae%e4%bb%96%e3%81%ae%e3%83%97%e3%83%a9%e3%82%b0%e3%82%a4%e3%83%b3%e3%81%a8%e3%83%86%e3%83%bc%e3%83%9e%e3%81%ab%e3%82%88%e3%82%8b%e3%83%86%e3%82%ad%e3%82%b9%e3%83%88%e7%bf%bb%e8%a8%b3/contactform7-m17n-steps/">http://wpml.org/?page_id=2476</a></li>
</ul>
<p>These are actually links to the same pages. There&#8217;s no magic here. These are the default-format links to those pages. Every page, post, tag or category can be accessed via its default link as well as its fancy link. It&#8217;s built into WordPress and doesn&#8217;t rely on anything else.</p>
<p>And, here is the function that produces those links:</p>
<pre>function wpml_default_link($anchor){

  $qv = false;

  if(is_single()){
    $qv = 'p=' . get_the_ID();
  }elseif(is_page()){
    $qv = 'page_id=' . get_the_ID();
  }elseif(is_tag()){
    $tag = &amp;get_term(intval( get_query_var('tag_id') ), 'post_tag', OBJECT, 'display');
    $qv = 'tag=' . $tag-&gt;slug;
  }elseif(is_category()){
    $qv = 'cat=' . get_query_var('cat');
  }elseif(is_year()){
    $qv = 'year=' . get_query_var('year');
  }elseif(is_month()){
    $qv = 'm=' . get_query_var('year') . sprintf('%02d', get_query_var('monthnum'));
  }elseif(is_day()){
    $qv = 'm=' . get_query_var('year') . sprintf('%02d', get_query_var('monthnum')) . sprintf('%02d',get_query_var('day'));
  }elseif(is_search()){
    $qv = 's=' . get_query_var('s');
  }

  if($qv){
    $link = '&lt;a rel="nofollow" href="' . get_options('home') . '?' . $qv . '"&gt;' . $anchor . '&lt;/a&gt;';
  }else{
    $link = '';
  }

  return $link;
}</pre>
<p>What it does is:</p>
<ol>
<li>Determines what kind of page you&#8217;re looking at now.</li>
<li>Constructs the default URL for that type of page. It&#8217;s different for pages, posts, tags, categories and archives.</li>
<li>Creates a link to that URL.</li>
</ol>
<h2>Adding short links to your pages</h2>
<p>You can copy the function from above and paste it to your <em>functions.php</em> file. This will make it available to all the files in your theme. Then, add it somewhere. I think that the footer is a good place, but you choose for yourself.</p>
<p>For wpml.org, we&#8217;ve added it to <em>footer.php</em>, making it look like this:</p>
<p><img class="alignnone size-full wp-image-2531" title="default_link" src="http://wpml.org/wp-content/uploads/2009/09/default_link1.png" alt="default_link" width="308" height="136" /></p>
<p>Now, whenever I want to send someone a link to a page on my site, I just use that URL. When visitors come to that URL, they will be redirected by WordPress to the permalink (the fancy URL).</p>
<p>To include in footer, I added this code:</p>
<pre>&lt;?php echo(wpml_default_link(__('Short link to this page','yourtheme'))); ?&gt;</pre>
<h2>Using WPML? It&#8217;s already built in!</h2>
<p>WPML includes a set of theme helper functions, stored in a file called <em>docs/theme-integration/wpml-integration.php</em>. Just copy that file to your theme&#8217;s directory and include it from <em>functions.php</em>. It will already contain a modified version of that function (which also includes the language path), so you can go ahead and use in your theme.</p>
]]></content:encoded>
			<wfw:commentRss>http://wpml.org/2009/09/your-own-url-shortener-for-wordpress/feed/</wfw:commentRss>
		<slash:comments>5</slash:comments>
		</item>
		<item>
		<title>Multilingual Atahualpa theme</title>
		<link>http://wpml.org/2009/08/multilingual-atahualpa-theme/</link>
		<comments>http://wpml.org/2009/08/multilingual-atahualpa-theme/#comments</comments>
		<pubDate>Tue, 18 Aug 2009 23:25:58 +0000</pubDate>
		<dc:creator>admin</dc:creator>
				<category><![CDATA[Themes]]></category>
		<category><![CDATA[Tutorials]]></category>

		<guid isPermaLink="false">http://wpml.org/?p=2320</guid>
		<description><![CDATA[I&#8217;m going to show how to use Atahualpa, by Bytes For All, for building multilingual WordPress sites using WPML. A theme for a multilingual WordPress site needs to have all strings wrapped in gettext calls, but it&#8217;s not quite enough. Using gettext in the theme allows it to display in a different (single) language from [...]]]></description>
			<content:encoded><![CDATA[<p><a href="http://wpml.org/wp-content/uploads/2009/08/atahualpa_screenshot.jpg" rel="lightbox[2320]"><img class="size-medium wp-image-2323 alignright" title="atahualpa screenshot" src="http://wpml.org/wp-content/uploads/2009/08/atahualpa_screenshot-300x209.jpg" alt="atahualpa screenshot" width="300" height="209" /></a><strong>I&#8217;m</strong><strong> going to show how to use <a href="http://wordpress.org/extend/themes/atahualpa">Atahualpa</a>, by <a href="http://wordpress.bytesforall.com/">Bytes For All</a>, for building multilingual WordPress sites using WPML.</strong></p>
<p>A theme for a multilingual WordPress site needs to have all strings wrapped in gettext calls, but it&#8217;s not quite enough. Using gettext in the theme allows it to display in a different (single) language from what it was originally built with.</p>
<p>To run multilingual, the theme needs to to allow visitors to choose their display language and deliver the correct content per language.</p>
<h2>A multilingual version for Atahualpa</h2>
<p>Let&#8217;s start at the end. Here is a <a href="http://themes.wpml.org/?preview=1&amp;stylesheet=atahualpa&amp;template=atahualpa">demo site powered with a modified version of Atahualpa</a> and here is the <a href="http://media.icanlocalize.com/wordpress_themes/atahualpa.zip">modified theme</a> which you can download and use.</p>
<h2>What we changed to make Atahualpa multilingual</h2>
<h3>1. Adding wpml-integration.php to the theme&#8217;s directory</h3>
<p>wpml-integration.php is found in WPML&#8217;s directory under <em>docs/theme-integration</em>. It includes a collection of functions which help turn themes into multilingual.</p>
<p>All these functions are designed to make themes use WPML if it&#8217;s active or ignore it if it&#8217;s missing. This means that the theme would run multilingual if WPML is available or normally (single language) otherwise.</p>
<p>Added to <strong>functions.php</strong>:</p>
<pre>include dirname(__FILE__) . '/wpml-integration.php';</pre>
<p>This statement loads wpml-integration.php and makes it available to all the files in the theme.</p>
<h3>2. Adding language selectors</h3>
<p>Language selectors make it possible for visitors to choose the language in which the site is displayed. Often, it&#8217;s a good idea to add several types of language selectors. Visitors scan the site quickly and look for visual hints to contents in their languages. Different people look at different places, so adding different types of language selectors to different parts of the page will help move visitors find their language.</p>
<p>We added WPML&#8217;s drop-down language selector to the sidebar by adding it to <strong>header.php</strong>:</p>
<pre>&lt;?php wpml_languages_selector() ?&gt;</pre>
<div id="attachment_2331" class="wp-caption alignnone" style="width: 171px"><img class="size-full wp-image-2331" title="atahualpa_drop_down_language_selector" src="http://wpml.org/wp-content/uploads/2009/08/atahualpa_drop_down_language_selector.png" alt="atahualpa_drop_down_language_selector" width="161" height="180" /><p class="wp-caption-text">Drop down language selector</p></div>
<p>We also added a horizontal list of languages to the site&#8217;s footer. Many users first scroll all the way to the bottom to see what&#8217;s there (and how long pages are), so it&#8217;s a good place to tell pages are available in other languages. We added the following code to <strong>footer.php</strong>:</p>
<pre>&lt;?php wpml_languages_list() ?&gt;</pre>
<div id="attachment_2333" class="wp-caption alignnone" style="width: 530px"><em><img class="size-full wp-image-2333" title="atahualpa_horizontal_language_selector" src="http://wpml.org/wp-content/uploads/2009/08/atahualpa_horizontal_language_selector.png" alt="Horizontal language selector in footer" width="520" height="38" /></em><p class="wp-caption-text">Horizontal language selector in footer</p></div>
<p>Finally, we added a language selector at the end of each post. This adds a sentence to each post, telling in what other languages it&#8217;s available. Added the following to <strong>index.php</strong> (which includes a custom version of WordPress&#8217; display loop):</p>
<pre>&lt;?php if(is_singular()) wpml_content_languages(); ?&gt;</pre>
<div id="attachment_2336" class="wp-caption alignnone" style="width: 303px"><img class="size-full wp-image-2336" title="atahualpa_content_languages_list" src="http://wpml.org/wp-content/uploads/2009/08/atahualpa_content_languages_list.png" alt="List of translation languages" width="293" height="27" /><p class="wp-caption-text">List of translation languages</p></div>
<h3>3. Making the home page link go to each language&#8217;s home</h3>
<p>When visitors click on &#8216;Home&#8217;, they expect to get to the home page without switching language. Since each language has a &#8216;home page&#8217; with a different URL, a single value for all will not work.</p>
<p>Normally, WordPress themes calculate the address for the &#8216;Home&#8217; page based on the &#8216;Blog URL&#8217; value set in the admin page. WPML created a function that calculates the correct home address according to the display language.</p>
<p>We replaced <strong>get_option(&#8216;home&#8217;)</strong> with <strong>wpml_get_home_url()</strong>. Also, the get_option(&#8216;home&#8217;) function returns the site&#8217;s localication without a trailing slash (/), so themes add it manually. WPML&#8217;s function includes this slash (there&#8217;s a long story behind this).</p>
<p>To do this change, we had to edit two files. Modified <strong>functions/bfa_get_options.php</strong> and change:</p>
<pre>$bfa_ata['get_option_home'] = get_option('home');</pre>
<p>into</p>
<pre>$bfa_ata['get_option_home'] = wpml_get_home_url();</pre>
<p>Also, edited <strong>functions/bfa_header_config.php</strong> and removed the trailing slash from the home page link:</p>
<pre>'&lt;a href="' . $bfa_ata['get_option_home'] . '"&gt;' . $bfa_ata['bloginfo_name'] . '&lt;/a&gt;'</pre>
<h3>4. Really advanced &#8211; translating texts users enter in the theme admin screen</h3>
<p>Atahualpa allows controlling some texts through the admin screen. This is a great thing which allows to manage the site without editing PHP files. WPML can translate these strings too using its String Translation mechanism.</p>
<p>To do this, the theme needs to tell WPML which strings need to be translated and then display the translation if it exists.</p>
<p>When users go to the theme&#8217;s admin screen, update the texts and click on Save, the function <strong>bfa_ata_add_admin</strong> from <strong>functions/bfa_ata_add_admin.php</strong> is executed. We added the following section to it (starting at line 11):</p>
<pre>global $wpml_translatable_strings;
 foreach($wpml_translatable_strings as $wpml_str ){
   if(isset($_REQUEST['bfa_ata_'.$wpml_str]) &amp;&amp; trim($_REQUEST['bfa_ata_'.$wpml_str])){
    wpml_register_string('atahualpa theme', $wpml_str, stripslashes($_REQUEST['bfa_ata_'.$wpml_str]));
  }
 }</pre>
<p>What this does it run through a list of strings defined in the global variable <strong>$wpml_translatable_strings</strong>. It registers each string in WPML&#8217;s string translation list.</p>
<p>The first argument is the context for the strings. Any name would go, but you should select a name that describes the strings. The second argument is the name for the string (doesn&#8217;t get translated). The last argument is the value of the string &#8211; gets translated.</p>
<p>To display the translations (if they exist), we added the <strong>wpml_t</strong> function to <strong>functions/bfa_get_options.php</strong> (starting at line 204):</p>
<pre>global $wpml_translatable_strings;
foreach($bfa_ata as $k=&gt;$v){
   if(in_array($k, $wpml_translatable_strings) || $__first){
    $bfa_ata[$k] = wpml_t('atahualpa theme', $k, $v);     
  }
}</pre>
<p>This code is run when the site is displayed to visitors. It will loop through the list of strings, check if it&#8217;s been registered for translation (<strong>in_array</strong>) and if so, get the translation. The <strong>wpml_t</strong> function will return the translated string in the current language, if translation exists, or just return the original string if there&#8217;s no translation.</p>
<h2>Turning other WordPress themes multilingual</h2>
<p>We&#8217;ve already done similar work on <a href="http://wordpress.org/extend/themes/inove">iNove</a> and <a href="http://wordpress.org/extend/themes/arras-theme">Arras</a> and are planning to convert more themes to multilingual.</p>
<p>Our intention is to provide ready-to-use multilingual themes and help you build your own multilingual-ready themes. Using the techniques we described here, you can build themes that will run multilingual when WPML is available or in a single language without WPML.</p>
<p>If you&#8217;re building themes and need help turning them multilingual, feel free to open new threads in the <a href="http://forum.wpml.org">forum</a>.</p>
<p>You can also make money (really passive income) by adding multilingual support to your themes. We&#8217;ll talk about including affiliate IDs in themes in the next post.</p>
]]></content:encoded>
			<wfw:commentRss>http://wpml.org/2009/08/multilingual-atahualpa-theme/feed/</wfw:commentRss>
		<slash:comments>10</slash:comments>
		</item>
		<item>
		<title>Making your WordPress theme multilingual</title>
		<link>http://wpml.org/2009/07/making-your-wordpress-theme-multilingual/</link>
		<comments>http://wpml.org/2009/07/making-your-wordpress-theme-multilingual/#comments</comments>
		<pubDate>Thu, 09 Jul 2009 07:26:05 +0000</pubDate>
		<dc:creator>amir</dc:creator>
				<category><![CDATA[Multilingual]]></category>
		<category><![CDATA[Tutorials]]></category>

		<guid isPermaLink="false">http://wpml.org/?p=1911</guid>
		<description><![CDATA[To run a truly multilingual site your theme must be multilingual as well. Instead of repeating our textbook explanation of how to build a multilingual WordPress theme, we&#8217;re going to go over a live example. We&#8217;ll go over the theme used for nadelspiel.com, a German site about hand made needle sewing. Things that need to [...]]]></description>
			<content:encoded><![CDATA[<p>To run a truly multilingual site your theme must be multilingual as well. Instead of repeating our textbook explanation of how to build a multilingual WordPress theme, we&#8217;re going to go over a live example.</p>
<p>We&#8217;ll go over the theme used for <a href="http://www.nadelspiel.com/">nadelspiel.com</a>, a German site about hand made needle sewing.</p>
<h2>Things that need to change to go multilingual</h2>
<p>nadelspiel.com uses a theme based on the very popular <a href="http://michaelhutagalung.com/arthemia/">arthemia theme</a>. It mixes between a magazine and a blog.</p>
<p>nadelspiel&#8217;s theme needed several changes in order to become truly multilingual:</p>
<ol>
<li>Like all arthemia based themes, category IDs are hard coded to the theme&#8217;s PHP. WPML assigns a different ID to translations, so these hard coded IDs needed to be changed to dynamic IDs.</li>
<li>All the texts in the theme needed to wrapped in gettext calls, so that they&#8217;re translated using the theme&#8217;s .mo file.</li>
<li>The home link needed to change, so that it points to the home page in each language.</li>
<li>A language selector needs to be inserted.</li>
</ol>
<p>We&#8217;ll go over each of these items and show how the theme&#8217;s files changed.</p>
<h3>Hard coded category IDs</h3>
<p>This is probably the biggest challenge when it comes to running multilingual sites that use complex themes. The arthemia theme includes a special <em>featured articles</em> box and also highlights certain categories. To do this, the category IDs are hard coded in the theme&#8217;s index.php file.</p>
<p>Since in WPML, translations for the category will receive different IDs, some translation is required.</p>
<p>Before:</p>
<pre>&lt;?php query_posts("showposts=1&amp;cat=NN"); $i = 1; ?&gt;</pre>
<p>After:</p>
<pre>&lt;?php query_posts("showposts=1&amp;cat=".icl_object_id(NN,'category')); $i = 1; ?&gt;</pre>
<p>What this does is use WPML&#8217;s ID translation function (<em>icl_object_id</em>), to convert from the category ID in the default language to the category ID in the actual language displayed.</p>
<h3>Localization for texts in the theme</h3>
<p>This is relatively straight forward. All the texts in the theme need to be wrapped in gettext calls. Then, you create a .po (or .pot) file that includes all the strings to translate, translate them and create a .mo file with the translations.</p>
<p>You can read about this in details in our previous post about <a href="http://wpml.org/2009/05/wordpress-theme-localization/">localizing WordPress themes</a>.</p>
<h3>Changing the link to the home page</h3>
<p>Normally, when you click on the site&#8217;s logo at top left corner of any page, you get to its home page.</p>
<p>When the site runs in a single language, its home page is found in the <em>Blog address (URL)</em> in <em>Admin-&gt;Setting-&gt;General</em>. The theme can access this value by reading get_option(&#8216;home&#8217;), so normally people implement the home page link using:</p>
<pre>&lt;a href="&lt;?php echo get_option('home'); ?&gt;/"</pre>
<p>To adapt the home page so that it points to the correct URL per language, this needs to be changed. WPML supplies its own home page URL function, which we&#8217;ve used for nadelspiel as well:</p>
<pre>&lt;a href="&lt;?php echo icl_get_home_url() ?&gt;"</pre>
<p>You can read more about this where we talk about the <a href="http://wpml.org/documentation/support/creating-multilingual-wordpress-themes/home-page-link/">home page link</a>.</p>
<h3>Adding a language selector</h3>
<p>nadelspiel&#8217;s theme includes multiple widget zones, so adding WPML&#8217;s drop-down language switcher is very simple. We just add it to one of the widget zone and we&#8217;re done.</p>
<p>In case you need fancier language switchers, like a horizontal list of all languages, you can add a <a href="http://wpml.org/documentation/getting-started-guide/language-setup/custom-language-switcher/">custom language switcher</a>.</p>
]]></content:encoded>
			<wfw:commentRss>http://wpml.org/2009/07/making-your-wordpress-theme-multilingual/feed/</wfw:commentRss>
		<slash:comments>2</slash:comments>
		</item>
	</channel>
</rss>
