<?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>My Beloved PHP &#187; Linux</title>
	<atom:link href="http://www.mybelovedphp.com/category/linux/feed/" rel="self" type="application/rss+xml" />
	<link>http://www.mybelovedphp.com</link>
	<description>The Art of Quick &#38; Dirty Programming</description>
	<lastBuildDate>Sun, 06 Jun 2010 21:08:36 +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>Dating takes time, women are difficult but PHP?</title>
		<link>http://www.mybelovedphp.com/2009/03/18/formatting-dates-in-different-languages/</link>
		<comments>http://www.mybelovedphp.com/2009/03/18/formatting-dates-in-different-languages/#comments</comments>
		<pubDate>Wed, 18 Mar 2009 12:28:11 +0000</pubDate>
		<dc:creator>programmer</dc:creator>
				<category><![CDATA[Apache]]></category>
		<category><![CDATA[Linux]]></category>
		<category><![CDATA[PHP]]></category>

		<guid isPermaLink="false">http://www.mybelovedphp.com/?p=81</guid>
		<description><![CDATA[One of the big annoyances is having a blog or webpage in a certain language and that all the dates appear on your website in English. Of course you can choose just numbered formats, but sometimes the month or the day of the week in words adds that needed little extra polish. Formatting a date [...]]]></description>
			<content:encoded><![CDATA[<p>One of the big annoyances is having a blog or webpage in a certain language and that all the dates appear on your website in English. Of course you can choose just numbered formats, but sometimes the month  or the day of the week in words adds that needed little extra polish.</p>
<h5>Formatting a date in PHP</h5>
<p>Normally a date is formatted like this with the <strong>date() </strong>function:</p>
<pre class="brush: php;">
&lt; ?= date('d-m-Y') ?&gt;
</pre>
<h5>Formatting a localised date in PHP</h5>
<p>But to format a date in your preferred language you need to use the <strong>strftime</strong> function:</p>
<blockquote><p>Format the time and/or date according to locale settings. Month and weekday names and other language-dependent strings respect the current locale set with setlocale().</p></blockquote>
<p>So we also need the <strong>setlocale()</strong><strong> </strong>function. This function let you set the language to use for the formatting. Your system or server should have them installed, otherwise it&#8217;s not possible! And most of them are not installed by default, although easily available.<br />
What does the <strong>setlocale() </strong>function do:</p>
<blockquote><p>Returns the new current locale, or FALSE if the locale functionality is not implemented on your platform, the specified locale does not exist or the category name is invalid.<br />
An invalid category name also causes a warning message. Category/locale names can be found in <a href="http://www.faqs.org/rfcs/rfc1766">RFC 1766</a> and <a href="http://www.w3.org/WAI/ER/IG/ert/iso639.htm">ISO 639</a>. Different systems have different naming schemes for locales.</p></blockquote>
<p>Tough pages to consume to be honest, but let&#8217;s go on.</p>
<h5>Locales settings on your server</h5>
<p>You can find the installed localisations in this file on a Linux server:</p>
<pre class="brush: xml;">
vi var/lib/locales/supported.d/local
</pre>
<p>My server only had one line by default!<br />
Simply add the one&#8217;s you&#8217;re missing. You can find all possible localisations in this file:</p>
<pre class="brush: xml;">
/usr/share/i18n/SUPPORTED
</pre>
<p>Don&#8217;t add them all: it will decrease performance.</p>
<p>So we&#8217;re nearly done:</p>
<pre class="brush: php;">
&lt; ?
setlocale(LC_TIME,'nl-NL.UTF-8');
echo strftime('%s-$b-%y',time())
?&gt;
</pre>
<p>You need to enter the correct encoding aswell, otherwise it won&#8217;t work. This is dependent of the server settings, so it will influence the portability of your code a bit.<br />
Above code will give you the current date in Dutch, but we need another function to create localised dates from stored timestamps of the MySQL database.</p>
<h5>Converting stored Timestamps to PHP understandable format</h5>
<p>A MySQL timestamp value won&#8217;t work as a direct input to the strftime function. We need to convert it with another function: <strong>strtotime</strong>.</p>
<p>So we end up with something like this:</p>
<pre class="brush: php;">
&lt; ?
setlocale(LC_TIME,'nl-NL.UTF-8');
echo strftime('%A %d $b %y',strtotime($row-&gt;timestamp))
?&gt;
</pre>
<p><strong>Quite a long road to take for a boring date!</strong></p>
]]></content:encoded>
			<wfw:commentRss>http://www.mybelovedphp.com/2009/03/18/formatting-dates-in-different-languages/feed/</wfw:commentRss>
		<slash:comments>0</slash:comments>
		</item>
		<item>
		<title>Localizing Ubuntu</title>
		<link>http://www.mybelovedphp.com/2006/10/10/localizing-ubuntu/</link>
		<comments>http://www.mybelovedphp.com/2006/10/10/localizing-ubuntu/#comments</comments>
		<pubDate>Tue, 10 Oct 2006 17:59:11 +0000</pubDate>
		<dc:creator>programmer</dc:creator>
				<category><![CDATA[Linux]]></category>

		<guid isPermaLink="false">http://mybelovedphp.com/?p=3</guid>
		<description><![CDATA[Ubuntu is a Debian based Linux distribution. In its few years of existence it made quite an impression by its support and speed of development. If offers the advantage to Debian in the way it supports the modern and rare hardware. I had no problem installing it on a new Dell right out of the [...]]]></description>
			<content:encoded><![CDATA[<p>Ubuntu is a Debian based Linux distribution. In its few years of existence it made quite an impression by its support and speed of development. If offers the advantage to Debian in the way it supports the modern and rare hardware. I had no problem installing it on a new Dell right out of the box. I use the server version of Dapper Drake 6.06 on my PHP server. Once you have installed the OS, you can run into problems localizing your system. I wanted to have Dutch dates on my Dutch website and English dates on my international sites. The way to add support for different languages differs quite a bit from earlier Ubuntu versions, because &#8216;dpkg-reconfigure locales&#8217; doesn&#8217;t work. But once you know the secret is not difficult at all.<br />
<span id="more-3"></span><br />
So here we go:</p>
<p>Open this file:<br />
<code>vi  /usr/share/i18n/SUPPORTED</code></p>
<p>Look for the supported localizations, and add your choices to</p>
<p><code>vi */*/locales/supported.d/local</code></p>
<p>Save the file and rebuild locales:<br />
<code>dpkg-reconfigure locales</code></p>
<p>Finally we have to restart apache to take the changes into effect:<br />
<code>/etc/init.d/apache2 restart</code></p>
<p>That&#8217;s all. It should work now!</p>
]]></content:encoded>
			<wfw:commentRss>http://www.mybelovedphp.com/2006/10/10/localizing-ubuntu/feed/</wfw:commentRss>
		<slash:comments>0</slash:comments>
		</item>
	</channel>
</rss>
