<?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>strictlyPHP &#187; i18n</title>
	<atom:link href="http://www.strictlyphp.com/blog/tag/i18n/feed/" rel="self" type="application/rss+xml" />
	<link>http://www.strictlyphp.com/blog</link>
	<description>web development &#38; web analytics</description>
	<lastBuildDate>Tue, 08 Mar 2011 10:47:29 +0000</lastBuildDate>
	<language>en</language>
	<sy:updatePeriod>hourly</sy:updatePeriod>
	<sy:updateFrequency>1</sy:updateFrequency>
	<generator>http://wordpress.org/?v=3.3.1</generator>
		<item>
		<title>Gettext translation with Google Translate</title>
		<link>http://www.strictlyphp.com/blog/2009/11/27/gettext-translation-with-google-translate/</link>
		<comments>http://www.strictlyphp.com/blog/2009/11/27/gettext-translation-with-google-translate/#comments</comments>
		<pubDate>Fri, 27 Nov 2009 11:34:43 +0000</pubDate>
		<dc:creator>Sam</dc:creator>
				<category><![CDATA[Development]]></category>
		<category><![CDATA[google]]></category>
		<category><![CDATA[i18n]]></category>
		<category><![CDATA[php]]></category>

		<guid isPermaLink="false">http://www.strictlyphp.com/blog/?p=1173</guid>
		<description><![CDATA[Working with gettext as your translation engine your project? In need of a rough translation of your application for a mockup/preview/&#8230;? Paul Dixon offeres a free service that automatically translates a gettext PO file with Google Translate. I personally use gettext a lot because of its speed and ease of use (with poEdit) and this [...]]]></description>
			<content:encoded><![CDATA[<p><em>Working with gettext as your translation engine your project? In need of a rough translation of your application for a mockup/preview/&#8230;?</em></p>
<p>Paul Dixon offeres a free service that <a href="http://pepipopum.dixo.net/" target="_blank">automatically translates a gettext PO file</a> with Google Translate. I personally use gettext a lot because of its speed and ease of use (with <a href="http://www.poedit.net/" target="_blank">poEdit</a>) and this will certainly be of use.</p>
<p>Of course the results should not be used in a production application.</p>
]]></content:encoded>
			<wfw:commentRss>http://www.strictlyphp.com/blog/2009/11/27/gettext-translation-with-google-translate/feed/</wfw:commentRss>
		<slash:comments>0</slash:comments>
		</item>
		<item>
		<title>Language specific tables in MySQL</title>
		<link>http://www.strictlyphp.com/blog/2008/11/13/language-specific-tables-in-mysql/</link>
		<comments>http://www.strictlyphp.com/blog/2008/11/13/language-specific-tables-in-mysql/#comments</comments>
		<pubDate>Thu, 13 Nov 2008 14:23:26 +0000</pubDate>
		<dc:creator>Sam</dc:creator>
				<category><![CDATA[Development]]></category>
		<category><![CDATA[i18n]]></category>
		<category><![CDATA[mysql]]></category>

		<guid isPermaLink="false">http://www.strictlyphp.com/blog/?p=321</guid>
		<description><![CDATA[Since a large part of the world doesn&#8217;t care about i18n and L10n, remarkably little articles on best practices are available about these topics. If you live in a multilingual country however, you can&#8217;t build an application without. For a recent project I was looking at a way to avoid language specific tables (it goes [...]]]></description>
			<content:encoded><![CDATA[<p><em>Since a large part of the world doesn&#8217;t care about i18n and L10n, remarkably little articles on best practices are available about these topics.</em></p>
<p><img class="alignnone size-medium wp-image-333" style="border: 1px solid #ccc;margin: 0 10px 10px 0;text-align: left;" src="http://www.strictlyphp.com/blog/wp-content/uploads/2008/11/languages.jpg" alt="" width="180" height="119" /></p>
<p>If you live in a multilingual country however, you can&#8217;t build an application without. For a recent project I was looking at a way to avoid language specific tables (it goes without saying language specific fields are not an option either!).</p>
<p>Since we all like to keep our data as clean as possible, I have created my language specific tables like this example:</p>
<pre>CREATE TABLE IF NOT EXISTS `country` (
  `code` char(2) NOT NULL,
  `language` char(2) NOT NULL default 'en',
  `name` varchar(100) NOT NULL,
  PRIMARY KEY  (`code`,`language`)
) ENGINE=InnoDB DEFAULT CHARSET=utf8;</pre>
<p>A sample country table with the ISO code as identifier, a language ISO code and the country name in that specific language. Notice that code and language form the composed primary key. In a multi-table set-up you would probably have a country table and a country_language table. Although this solution looks so much cleaner <strong>it creates a challenge when it comes to querying</strong>.</p>
<p>Imagine you would have these records:</p>
<pre>DE,en,Germany
DE,de,Deutschland
DE,fr,Allemagne
US,en,United States
US,fr,Étas-Unis</pre>
<p>and you want to get a list of countries for a German audience.</p>
<p>Since much <strong>data in these kinds of tables won&#8217;t be translated into all possible languages</strong> (which is the case for German in this example), you will probably want to settle for a default language if German is not available: let&#8217;s say English in this case.</p>
<p>Basically you want to have a result with Deutschland and United States. After some thought, this query is my best bet:</p>
<pre>SELECT IFNULL(language_set.`code`, default_set.`code`) AS 'code',
  IFNULL(language_set.`language`, default_set.`language`) AS 'language',
  IFNULL(language_set.`name`, default_set.`name`) AS 'name'
FROM `country` AS default_set
LEFT OUTER JOIN `country` AS language_set
  ON default_set.`code` = language_set.`code`
  AND language_set.`language` = 'de'
WHERE default_set.`language` = 'en'</pre>
<p>This creates <strong>a set of German data joined by English data if German is not available</strong>. Since MySQL supports sub-queries for some time, you can use this set as a sub-query in any larger query. In my project I&#8217;ve put this default query in each language-based model for re-use in larger queries. For example:</p>
<pre>$sql = "SELECT DISTINCT country.*
  FROM (" . $completeSet . ") AS 'country'
  INNER JOIN other_table ON country.`code` = other_table.`country_code`
  ORDER BY country.`name`";</pre>
<p>This would query all countries that have records in other_table.</p>
<p>Until now, I haven&#8217;t found a situation where this could not be used. I don&#8217;t guarantee that there isn&#8217;t one though. Any improvements are highly appreciated!</p>
]]></content:encoded>
			<wfw:commentRss>http://www.strictlyphp.com/blog/2008/11/13/language-specific-tables-in-mysql/feed/</wfw:commentRss>
		<slash:comments>0</slash:comments>
		</item>
	</channel>
</rss>

