<?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>GIS and Web Tricks &#187; wpml</title>
	<atom:link href="http://www.bernawebdesign.ch/byteblog/tagged/wpml/feed/" rel="self" type="application/rss+xml" />
	<link>http://www.bernawebdesign.ch/byteblog</link>
	<description>Thougts and tricks on GIS, web development and FOSS</description>
	<lastBuildDate>Tue, 23 Mar 2010 17:11:47 +0000</lastBuildDate>
	<language>en</language>
	<sy:updatePeriod>hourly</sy:updatePeriod>
	<sy:updateFrequency>1</sy:updateFrequency>
	<generator>http://wordpress.org/?v=3.0.1</generator>
		<item>
		<title>migrating wordpress from gengo to wpml</title>
		<link>http://www.bernawebdesign.ch/byteblog/2009/08/15/migrating-wordpress-from-gengo-to-wpml/</link>
		<comments>http://www.bernawebdesign.ch/byteblog/2009/08/15/migrating-wordpress-from-gengo-to-wpml/#comments</comments>
		<pubDate>Sat, 15 Aug 2009 13:13:59 +0000</pubDate>
		<dc:creator>marco</dc:creator>
				<category><![CDATA[web 2.0]]></category>
		<category><![CDATA[gengo]]></category>
		<category><![CDATA[multilingual blogging]]></category>
		<category><![CDATA[wpml]]></category>

		<guid isPermaLink="false">http://www.bernawebdesign.ch/byteblog/?p=94</guid>
		<description><![CDATA[A client of mine used to have a multilingual blog using the Gengo plugin, which I consider by now unfortunatly dead. Fortunately, the guys at http://www.wpml.org did a great job creating a new plugin that works like a charm. I did the migration from one to the other and I had no troubles (beside figuring [...]]]></description>
			<content:encoded><![CDATA[<p>A client of mine used to have a multilingual blog using the Gengo plugin, which I consider by now unfortunatly dead. Fortunately, the guys at http://www.wpml.org did a great job creating a new plugin that works like a charm.<span id="more-94"></span></p>
<p>I did the migration from one to the other and I had no troubles (beside figuring out how to map gengo&#8217;s model to wpml). Further down  are two SQL statements to check and update the posts language in wpml.</p>
<p>IMPORTANT: first disable gengo, then install wpml, then choose the default language and create the languages you had in geng. All your post will now be in the default language. you can check this with this SQL statement (for example using phpMyAdmin)</p>

<div class="wp_syntax"><div class="code"><pre class="sql" style="font-family:monospace;"><span style="color: #993333; font-weight: bold;">SELECT</span> post<span style="color: #66cc66;">.</span><span style="color: #ff0000;">`ID`</span><span style="color: #66cc66;">,</span> post<span style="color: #66cc66;">.</span><span style="color: #ff0000;">`post_title`</span><span style="color: #66cc66;">,</span> wpml<span style="color: #66cc66;">.</span><span style="color: #ff0000;">`language_code`</span> <span style="color: #993333; font-weight: bold;">AS</span> wpml_language<span style="color: #66cc66;">,</span> gengoLang<span style="color: #66cc66;">.</span><span style="color: #ff0000;">`code`</span> <span style="color: #993333; font-weight: bold;">AS</span> gengo_language
<span style="color: #993333; font-weight: bold;">FROM</span> <span style="color: #ff0000;">`wp_posts`</span> post
<span style="color: #993333; font-weight: bold;">LEFT</span> <span style="color: #993333; font-weight: bold;">JOIN</span> <span style="color: #ff0000;">`wp_icl_translations`</span> wpml <span style="color: #993333; font-weight: bold;">ON</span> wpml<span style="color: #66cc66;">.</span><span style="color: #ff0000;">`element_id`</span> <span style="color: #66cc66;">=</span> post<span style="color: #66cc66;">.</span><span style="color: #ff0000;">`ID`</span>
<span style="color: #993333; font-weight: bold;">LEFT</span> <span style="color: #993333; font-weight: bold;">JOIN</span> <span style="color: #ff0000;">`wp_post2lang`</span> gengo <span style="color: #993333; font-weight: bold;">ON</span> gengo<span style="color: #66cc66;">.</span><span style="color: #ff0000;">`post_id`</span> <span style="color: #66cc66;">=</span> post<span style="color: #66cc66;">.</span>ID
<span style="color: #993333; font-weight: bold;">LEFT</span> <span style="color: #993333; font-weight: bold;">JOIN</span> <span style="color: #ff0000;">`wp_languages`</span> gengoLang <span style="color: #993333; font-weight: bold;">ON</span> gengoLang<span style="color: #66cc66;">.</span><span style="color: #ff0000;">`language_id`</span> <span style="color: #66cc66;">=</span> gengo<span style="color: #66cc66;">.</span><span style="color: #ff0000;">`language_id`</span>
<span style="color: #993333; font-weight: bold;">WHERE</span> wpml<span style="color: #66cc66;">.</span><span style="color: #ff0000;">`element_type`</span> <span style="color: #66cc66;">=</span><span style="color: #ff0000;">'post'</span>
<span style="color: #993333; font-weight: bold;">ORDER</span> <span style="color: #993333; font-weight: bold;">BY</span> post<span style="color: #66cc66;">.</span><span style="color: #ff0000;">`ID`</span>  <span style="color: #993333; font-weight: bold;">DESC</span>;</pre></div></div>

<p>Then you can update the post language with the following statement:</p>

<div class="wp_syntax"><div class="code"><pre class="sql" style="font-family:monospace;"><span style="color: #993333; font-weight: bold;">UPDATE</span> <span style="color: #ff0000;">`wp_icl_translations`</span> wpml
<span style="color: #993333; font-weight: bold;">LEFT</span> <span style="color: #993333; font-weight: bold;">JOIN</span> <span style="color: #ff0000;">`wp_posts`</span> post <span style="color: #993333; font-weight: bold;">ON</span> wpml<span style="color: #66cc66;">.</span><span style="color: #ff0000;">`element_id`</span> <span style="color: #66cc66;">=</span> post<span style="color: #66cc66;">.</span><span style="color: #ff0000;">`ID`</span>
<span style="color: #993333; font-weight: bold;">LEFT</span> <span style="color: #993333; font-weight: bold;">JOIN</span> <span style="color: #ff0000;">`wp_post2lang`</span> gengo <span style="color: #993333; font-weight: bold;">ON</span> gengo<span style="color: #66cc66;">.</span><span style="color: #ff0000;">`post_id`</span> <span style="color: #66cc66;">=</span> post<span style="color: #66cc66;">.</span>ID
<span style="color: #993333; font-weight: bold;">LEFT</span> <span style="color: #993333; font-weight: bold;">JOIN</span> <span style="color: #ff0000;">`wp_languages`</span> gengoLang <span style="color: #993333; font-weight: bold;">ON</span> gengoLang<span style="color: #66cc66;">.</span><span style="color: #ff0000;">`language_id`</span> <span style="color: #66cc66;">=</span> gengo<span style="color: #66cc66;">.</span><span style="color: #ff0000;">`language_id`</span>
<span style="color: #993333; font-weight: bold;">SET</span> wpml<span style="color: #66cc66;">.</span><span style="color: #ff0000;">`language_code`</span> <span style="color: #66cc66;">=</span> gengoLang<span style="color: #66cc66;">.</span><span style="color: #ff0000;">`code`</span>
<span style="color: #993333; font-weight: bold;">WHERE</span> wpml<span style="color: #66cc66;">.</span><span style="color: #ff0000;">`element_type`</span> <span style="color: #66cc66;">=</span><span style="color: #ff0000;">'post'</span></pre></div></div>

<p>This will update your POSTS only, no category or tags yet. I might look at those as well and I&#8217;ll get in touch with wpml to see if they can use my snippets to get out a sort of import tool.</p>
<p>cheers Marco</p>
]]></content:encoded>
			<wfw:commentRss>http://www.bernawebdesign.ch/byteblog/2009/08/15/migrating-wordpress-from-gengo-to-wpml/feed/</wfw:commentRss>
		<slash:comments>4</slash:comments>
		</item>
		<item>
		<title>wordpress iphone app with wpml</title>
		<link>http://www.bernawebdesign.ch/byteblog/2009/08/07/wordpress-wpml-iphone-app/</link>
		<comments>http://www.bernawebdesign.ch/byteblog/2009/08/07/wordpress-wpml-iphone-app/#comments</comments>
		<pubDate>Fri, 07 Aug 2009 20:30:34 +0000</pubDate>
		<dc:creator>marco</dc:creator>
				<category><![CDATA[web 2.0]]></category>
		<category><![CDATA[web development]]></category>
		<category><![CDATA[iphone]]></category>
		<category><![CDATA[wordpress]]></category>
		<category><![CDATA[wpml]]></category>

		<guid isPermaLink="false">http://www.bernawebdesign.ch/byteblog/?p=68</guid>
		<description><![CDATA[Solution to use the iphone application for multilingual blogging with wpml]]></description>
			<content:encoded><![CDATA[<p>I&#8217;ve a client using a wordpress multilingual blog with the wpml plugin (<a href="http://wpml.org/">wpml.org/</a>) and that wants to use the wordpress iphone app (<a href="http://iphone.wordpress.org/">iphone.wordpress.org</a>). The app and the plugin work like a charm. the only problem is that in the app you can&#8217;t set the post language, hence you are (well by now were <img src='http://www.bernawebdesign.ch/byteblog/wp-includes/images/smilies/icon_smile.gif' alt=':)' class='wp-smiley' />  ) able to post only using the default language.<br />
I wrote a small PHP script<span id="more-68"></span> to put in the root dir of your blog that updates the default language of the blog when called. so basically before using the iphone app you call the script using safari (http://domain.tdl/blog/set_post_lang.php?to=de) and then use the iphone application to post to your blog.<br />
The script requires minimal configuration, you have to set the blog_id (if you have a single install, 0 should be ok, but you can find this by looking at the wp_options table in the DB) and an array of valid languages. Please note that the script uses no authentication methods, up to you to decide if you want to implement it (very easy actually for example with http_auth or with a key). I didn&#8217;t because the script does something very small and irrelevant from the security point of view.<br />
And  here the code, enjoy.</p>

<div class="wp_syntax"><div class="code"><pre class="php" style="font-family:monospace;"><span style="color: #000000; font-weight: bold;">&lt;?php</span>
<span style="color: #009933; font-style: italic;">/**
 * script to change the default language of a wpml installation
 * so that a new post written from fot example the iphone app is set to the right language
 * 
 * @use call it like this: www.domain.tld/set_post_lang.php?to=it
 * @author Marco Bernasocchi   marco@bernawebdesign.ch
 * @copyright LGPLv3
 */</span>
&nbsp;
<span style="color: #666666; font-style: italic;">//___________________SETTINGS________________</span>
<span style="color: #990000;">define</span><span style="color: #009900;">&#40;</span><span style="color: #0000ff;">&quot;BLOG_ID&quot;</span><span style="color: #339933;">,</span>  <span style="color: #0000ff;">&quot;0&quot;</span><span style="color: #009900;">&#41;</span><span style="color: #339933;">;</span> <span style="color: #666666; font-style: italic;">//id of the blog</span>
<span style="color: #000088;">$active_languages</span> <span style="color: #339933;">=</span> <span style="color: #990000;">array</span><span style="color: #009900;">&#40;</span><span style="color: #0000ff;">&quot;it&quot;</span><span style="color: #339933;">,</span> <span style="color: #0000ff;">&quot;de&quot;</span><span style="color: #009900;">&#41;</span><span style="color: #339933;">;</span> <span style="color: #666666; font-style: italic;">//use lowercase codes of the languages active in your blog</span>
&nbsp;
<span style="color: #666666; font-style: italic;">//___________________SCRIPT__________________</span>
<span style="color: #b1b100;">require_once</span><span style="color: #009900;">&#40;</span><span style="color: #0000ff;">'wp-config.php'</span><span style="color: #009900;">&#41;</span><span style="color: #339933;">;</span><span style="color: #666666; font-style: italic;">//used to get hostname, DB, USER &amp; PASSW</span>
&nbsp;
<span style="color: #666666; font-style: italic;">/*check if the passed language is a valid one*/</span>
<span style="color: #000088;">$set_to</span> <span style="color: #339933;">=</span> <span style="color: #990000;">strtolower</span><span style="color: #009900;">&#40;</span><span style="color: #000088;">$_GET</span><span style="color: #009900;">&#91;</span><span style="color: #0000ff;">&quot;to&quot;</span><span style="color: #009900;">&#93;</span><span style="color: #009900;">&#41;</span><span style="color: #339933;">;</span>
<span style="color: #b1b100;">if</span><span style="color: #009900;">&#40;</span><span style="color: #339933;">!</span><span style="color: #990000;">in_array</span><span style="color: #009900;">&#40;</span><span style="color: #000088;">$set_to</span><span style="color: #339933;">,</span> <span style="color: #000088;">$active_languages</span><span style="color: #009900;">&#41;</span><span style="color: #009900;">&#41;</span> <span style="color: #990000;">die</span><span style="color: #009900;">&#40;</span><span style="color: #0000ff;">'invalid language'</span><span style="color: #009900;">&#41;</span><span style="color: #339933;">;</span>
&nbsp;
<span style="color: #666666; font-style: italic;">/*open DB connection */</span>
<span style="color: #000088;">$mysqli</span> <span style="color: #339933;">=</span> <span style="color: #000000; font-weight: bold;">new</span> mysqli<span style="color: #009900;">&#40;</span>DB_HOST<span style="color: #339933;">,</span> DB_USER<span style="color: #339933;">,</span> DB_PASSWORD<span style="color: #339933;">,</span> DB_NAME<span style="color: #009900;">&#41;</span><span style="color: #339933;">;</span>
<span style="color: #666666; font-style: italic;">/* check connection */</span>
<span style="color: #b1b100;">if</span> <span style="color: #009900;">&#40;</span><span style="color: #990000;">mysqli_connect_errno</span><span style="color: #009900;">&#40;</span><span style="color: #009900;">&#41;</span><span style="color: #009900;">&#41;</span> <span style="color: #009900;">&#123;</span>
    <span style="color: #990000;">die</span><span style="color: #009900;">&#40;</span><span style="color: #0000ff;">'DB Connect failed'</span><span style="color: #009900;">&#41;</span><span style="color: #339933;">;</span>
<span style="color: #009900;">&#125;</span>
&nbsp;
<span style="color: #666666; font-style: italic;">/* get the actual settings of the wpml plugin */</span>
<span style="color: #000088;">$query</span> <span style="color: #339933;">=</span> <span style="color: #0000ff;">'SELECT option_value from `'</span><span style="color: #339933;">.</span>DB_NAME<span style="color: #339933;">.</span><span style="color: #0000ff;">'`.`wp_options`
          WHERE CONVERT(`wp_options`.`option_name` USING utf8) = &quot;icl_sitepress_settings&quot;
          AND `wp_options`.`blog_id` = '</span><span style="color: #339933;">.</span>BLOG_ID<span style="color: #339933;">.</span><span style="color: #0000ff;">' 
          LIMIT 1;'</span><span style="color: #339933;">;</span>
<span style="color: #b1b100;">if</span> <span style="color: #009900;">&#40;</span><span style="color: #009900;">&#40;</span><span style="color: #000088;">$result</span> <span style="color: #339933;">=</span> <span style="color: #000088;">$mysqli</span><span style="color: #339933;">-&gt;</span><span style="color: #004000;">query</span><span style="color: #009900;">&#40;</span><span style="color: #000088;">$query</span><span style="color: #009900;">&#41;</span><span style="color: #009900;">&#41;</span> <span style="color: #339933;">&amp;&amp;</span> <span style="color: #000088;">$result</span><span style="color: #339933;">-&gt;</span><span style="color: #004000;">num_rows</span> <span style="color: #339933;">==</span> <span style="color: #cc66cc;">1</span><span style="color: #009900;">&#41;</span> <span style="color: #009900;">&#123;</span>
  <span style="color: #b1b100;">while</span> <span style="color: #009900;">&#40;</span><span style="color: #000088;">$row</span> <span style="color: #339933;">=</span> <span style="color: #000088;">$result</span><span style="color: #339933;">-&gt;</span><span style="color: #004000;">fetch_assoc</span><span style="color: #009900;">&#40;</span><span style="color: #009900;">&#41;</span><span style="color: #009900;">&#41;</span> <span style="color: #009900;">&#123;</span>
        <span style="color: #000088;">$value</span> <span style="color: #339933;">=</span> <span style="color: #000088;">$row</span><span style="color: #009900;">&#91;</span><span style="color: #0000ff;">&quot;option_value&quot;</span><span style="color: #009900;">&#93;</span><span style="color: #339933;">;</span>
  <span style="color: #009900;">&#125;</span>  
  <span style="color: #666666; font-style: italic;">/* free result set */</span>
  <span style="color: #000088;">$result</span><span style="color: #339933;">-&gt;</span><span style="color: #004000;">close</span><span style="color: #009900;">&#40;</span><span style="color: #009900;">&#41;</span><span style="color: #339933;">;</span>
<span style="color: #009900;">&#125;</span>
<span style="color: #b1b100;">else</span> <span style="color: #990000;">die</span><span style="color: #009900;">&#40;</span><span style="color: #0000ff;">'Error getting the actual setting'</span><span style="color: #009900;">&#41;</span><span style="color: #339933;">;</span>
&nbsp;
<span style="color: #666666; font-style: italic;">/* check if update needed */</span>
<span style="color: #000088;">$new_pattern</span> <span style="color: #339933;">=</span> <span style="color: #0000ff;">'&quot;default_language&quot;;s:2:&quot;'</span><span style="color: #339933;">.</span><span style="color: #000088;">$set_to</span><span style="color: #339933;">.</span><span style="color: #0000ff;">'&quot;'</span><span style="color: #339933;">;</span>
<span style="color: #000088;">$replace</span> <span style="color: #339933;">=</span> <span style="color: #339933;">!</span><span style="color: #990000;">preg_match</span><span style="color: #009900;">&#40;</span><span style="color: #0000ff;">&quot;/<span style="color: #006699; font-weight: bold;">$new_pattern</span>/&quot;</span><span style="color: #339933;">,</span><span style="color: #000088;">$value</span><span style="color: #009900;">&#41;</span><span style="color: #339933;">;</span>
&nbsp;
<span style="color: #666666; font-style: italic;">/* change the language then update the DB */</span>
<span style="color: #b1b100;">if</span><span style="color: #009900;">&#40;</span><span style="color: #000088;">$replace</span><span style="color: #009900;">&#41;</span><span style="color: #009900;">&#123;</span>
  <span style="color: #000088;">$pattern</span> <span style="color: #339933;">=</span> <span style="color: #0000ff;">'/&quot;default_language&quot;;s:2:&quot;[a-z]{2}&quot;/'</span><span style="color: #339933;">;</span>
  <span style="color: #000088;">$value</span> <span style="color: #339933;">=</span> <span style="color: #990000;">preg_replace</span><span style="color: #009900;">&#40;</span><span style="color: #000088;">$pattern</span> <span style="color: #339933;">,</span> <span style="color: #000088;">$new_pattern</span><span style="color: #339933;">,</span> <span style="color: #000088;">$value</span><span style="color: #339933;">,</span> <span style="color: #cc66cc;">1</span><span style="color: #009900;">&#41;</span><span style="color: #339933;">;</span>
  <span style="color: #000088;">$query</span> <span style="color: #339933;">=</span> <span style="color: #0000ff;">'UPDATE `'</span><span style="color: #339933;">.</span>DB_NAME<span style="color: #339933;">.</span><span style="color: #0000ff;">'`.`wp_options` 
            SET `option_value` = \''</span><span style="color: #339933;">.</span><span style="color: #000088;">$value</span><span style="color: #339933;">.</span><span style="color: #0000ff;">'\'
            WHERE CONVERT(`wp_options`.`option_name` USING utf8) = &quot;icl_sitepress_settings&quot;
            AND `wp_options`.`blog_id` = '</span><span style="color: #339933;">.</span>BLOG_ID<span style="color: #339933;">.</span><span style="color: #0000ff;">'
            LIMIT 1;'</span><span style="color: #339933;">;</span>
  <span style="color: #b1b100;">if</span> <span style="color: #009900;">&#40;</span><span style="color: #000088;">$result</span> <span style="color: #339933;">=</span> <span style="color: #000088;">$mysqli</span><span style="color: #339933;">-&gt;</span><span style="color: #004000;">query</span><span style="color: #009900;">&#40;</span><span style="color: #000088;">$query</span><span style="color: #009900;">&#41;</span><span style="color: #009900;">&#41;</span> <span style="color: #009900;">&#123;</span>
    <span style="color: #b1b100;">echo</span> <span style="color: #0000ff;">'Default post language is now set to '</span><span style="color: #339933;">.</span><span style="color: #990000;">strtoupper</span><span style="color: #009900;">&#40;</span><span style="color: #000088;">$set_to</span><span style="color: #009900;">&#41;</span><span style="color: #339933;">;</span>
    <span style="color: #009900;">&#125;</span>
  <span style="color: #b1b100;">else</span> <span style="color: #b1b100;">echo</span> <span style="color: #0000ff;">'Problem updating the language, please try again'</span><span style="color: #339933;">;</span>
<span style="color: #009900;">&#125;</span>
<span style="color: #b1b100;">else</span> <span style="color: #b1b100;">echo</span> <span style="color: #0000ff;">'Default post language is already set to '</span><span style="color: #339933;">.</span><span style="color: #990000;">strtoupper</span><span style="color: #009900;">&#40;</span><span style="color: #000088;">$set_to</span><span style="color: #009900;">&#41;</span><span style="color: #339933;">;</span>
<span style="color: #666666; font-style: italic;">//close DB connection</span>
<span style="color: #000088;">$mysqli</span><span style="color: #339933;">-&gt;</span><span style="color: #004000;">close</span><span style="color: #009900;">&#40;</span><span style="color: #009900;">&#41;</span><span style="color: #339933;">;</span>
<span style="color: #000000; font-weight: bold;">?&gt;</span></pre></div></div>

]]></content:encoded>
			<wfw:commentRss>http://www.bernawebdesign.ch/byteblog/2009/08/07/wordpress-wpml-iphone-app/feed/</wfw:commentRss>
		<slash:comments>0</slash:comments>
		</item>
	</channel>
</rss>
