<?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>Dmitri's Blog &#187; Ruby</title>
	<atom:link href="http://www.dmitri.me/blog/category/ruby/feed/" rel="self" type="application/rss+xml" />
	<link>http://www.dmitri.me/blog</link>
	<description>Dmitri Smirnov. Web development in Estonia.</description>
	<lastBuildDate>Tue, 10 Aug 2010 12:07:30 +0000</lastBuildDate>
	<generator>http://wordpress.org/?v=2.9</generator>
	<language>en</language>
	<sy:updatePeriod>hourly</sy:updatePeriod>
	<sy:updateFrequency>1</sy:updateFrequency>
			<item>
		<title>Internationalization in Rails 2.2</title>
		<link>http://www.dmitri.me/blog/internationalization-in-rails-22/</link>
		<comments>http://www.dmitri.me/blog/internationalization-in-rails-22/#comments</comments>
		<pubDate>Tue, 13 Oct 2009 06:41:38 +0000</pubDate>
		<dc:creator>Dmitri</dc:creator>
				<category><![CDATA[Ruby]]></category>
		<category><![CDATA[Ruby on Rails]]></category>
		<category><![CDATA[web-development]]></category>
		<category><![CDATA[code]]></category>
		<category><![CDATA[Internationalization]]></category>
		<category><![CDATA[Rails]]></category>

		<guid isPermaLink="false">http://www.dmitri.me/blog/?p=274</guid>
		<description><![CDATA[This tutorials is about Internationalization in Ruby on Rails 2.2 and later. You don&#8217;t need to invent a wheel from scratch all stuff for internationalization and localization of your application is available in standard Rails package since version 2.2.

Configuration
So let&#8217;s start with empty Rails application.
$rails test_locale
In directory APP_ROOT/config/locales/ you will find file en.yml this is [...]]]></description>
			<content:encoded><![CDATA[<p>This tutorials is about Internationalization in <a href="http://www.rubyonrails.org/">Ruby on Rails 2.2</a> and later. You don&#8217;t need to invent a wheel from scratch all stuff for internationalization and localization of your application is available in standard Rails package since version 2.2.</p>
<p><span id="more-274"></span></p>
<h3>Configuration</h3>
<p>So let&#8217;s start with empty Rails application.<br />
<code>$rails test_locale</code></p>
<p>In directory APP_ROOT/config/locales/ you will find file <strong>en.yml</strong> this is file which contains all texts for English version of your application. Here in Estonia we usually make applications for 3 or more languages. So I copy en.yml and name files as locale.</p>
<p><strong>en.yml</strong> &#8211; for English<br />
<code>en:<br />
&nbsp;&nbsp;hello: "Hello world"<br />
</code></p>
<p><strong>ru.yml</strong> &#8211; for Russian<br />
<code>ru:<br />
&nbsp;&nbsp;hello: "Привет мир!"<br />
</code></p>
<p><strong>ee.yml</strong> &#8211; for Estonian<br />
<code>ee:<br />
&nbsp;&nbsp;hello: "Tere maailm!"<br />
</code></p>
<p>Now lets do a controller for test.<br />
<code>test_locale$ ruby script/generate controller SayHello index</code></p>
<p>Now open view file in APP_ROOT/app/views/say_hello/index.html.erb and edit like:<br />
<code>&lt;%=t :hello %&gt;</code><br />
<strong>t</strong> &#8211; function is a helper that translates the text for current locale. If locale text is missing, it will generate message that &#8220;translation is missing&#8221; it doesn&#8217;t halt your application.</p>
<p>Locale will pass the parameter as query_string ?locale=ru and you need to add this manually for every URL in you application, of course you don&#8217;t like to do this manually. If you want that our app looks like <a href="http://www.example.com/ru/say_hello">http://www.example.com/ru/say_hello</a> go to APP_ROOT/config/routes.rb end add following line<br />
<code>map.connect ':locale/:controller/:action/:id', :controller =&gt; 'say_hello', :action =&gt; 'index', :requirements =&gt; {:locale =&gt; /ee|ru|en/}<br />
</code><br />
This will set for ROOT controller too. In requirement we set all available locales to avoid people enter in URL shitty things. After you set this route, Rails will generate pretty nice URLs with <strong>link_to, link_to_remote, etc&#8230;</strong></p>
<p>Now we need to a function to set locale in every controller of you application. Open APP_ROOT/app/controllers/application_controller.rb and edit:<br />
<code>class ApplicationController &lt; ActionController::Base<br />
&nbsp;&nbsp;helper :all # include all helpers, all the time<br />
&nbsp;&nbsp;protect_from_forgery<br />
&nbsp;&nbsp;<strong>before_filter :set_locale<br />
&nbsp;&nbsp;def set_locale<br />
&nbsp;&nbsp;&nbsp;&nbsp;locale = params[:locale]<br />
&nbsp;&nbsp;&nbsp;&nbsp;I18n.locale = locale<br />
&nbsp;&nbsp;&nbsp;&nbsp;I18n.load_path += Dir[ File.join(RAILS_ROOT, 'config', 'locales', '*.{rb,yml}') ]<br />
&nbsp;&nbsp;end</strong><br />
end<br />
</code></p>
<p>If you want to setup default locale different than English(en). Open file APP_ROOT/config/environment.rb and commentate following lines (usually at the end of file) and set up default locale. For example it will be Russian:<br />
<code>config.i18n.load_path += Dir[Rails.root.join('config','locales', '*.{rb,yml}')]<br />
config.i18n.default_locale = :ru<br />
</code></p>
<h3>Result</h3>
<p>Lets see what we got:<br />
<code>$ruby script/server</code></p>
<p>Open the URL in your browser <a href="http://localhost:3000/say_hello">http://localhost:3000/say_hello</a></p>
<p>Default (we set by default Russian[ru] locale)<br />
<img src="/misc/ri-ru.jpg" alt="" /></p>
<p>English<br />
<img src="/misc/ri-en.jpg" alt="" /></p>
<p>Estonian<br />
<img src="/misc/ri-ee.jpg" alt="" /></p>
<p>Thats all! Really isn&#8217;t hard?</p>
]]></content:encoded>
			<wfw:commentRss>http://www.dmitri.me/blog/internationalization-in-rails-22/feed/</wfw:commentRss>
		<slash:comments>0</slash:comments>
		</item>
		<item>
		<title>Isikukoodi valideerimine</title>
		<link>http://www.dmitri.me/blog/isikukood-valideerimine/</link>
		<comments>http://www.dmitri.me/blog/isikukood-valideerimine/#comments</comments>
		<pubDate>Fri, 29 May 2009 09:29:07 +0000</pubDate>
		<dc:creator>Dmitri</dc:creator>
				<category><![CDATA[Java]]></category>
		<category><![CDATA[PHP]]></category>
		<category><![CDATA[Ruby]]></category>
		<category><![CDATA[Eesti]]></category>
		<category><![CDATA[programming]]></category>
		<category><![CDATA[Rury]]></category>

		<guid isPermaLink="false">http://www.dmitri.me/blog/?p=258</guid>
		<description><![CDATA[Leidsin täna seda → Isikukood. Algoritm on selge aga näidese kood on räpp&#8230;
Siis&#8230;
Versioon PHP by Setor
Versioon PHP 2 by MiamiBC (kõige lihtsam ja arusaadavam)
Java version by Incubo
Minu versioon Ruby keeles
Mika Tuupola versioon JavaScript
Kui sul on mingi teine versioon siis saada mulle ka  
]]></description>
			<content:encoded><![CDATA[<p>Leidsin täna seda → <a href="http://et.wikipedia.org/wiki/Isikukood">Isikukood</a>. Algoritm on selge aga näidese kood on räpp&#8230;</p>
<p>Siis&#8230;</p>
<p><a href="/misc/isikukood/isikukood.phps">Versioon PHP</a> by <a href="http://www.setor.net/">Setor</a><br />
<a href="/misc/isikukood/isikukood2.phps">Versioon PHP 2</a> by MiamiBC (kõige lihtsam ja arusaadavam)<br />
<a href="/misc/isikukood/PersonalCode.java">Java version</a> by Incubo<br />
Minu <a href="/misc/isikukood/isikukood.rb">versioon</a> Ruby keeles<br />
<a href="http://www.appelsiini.net">Mika Tuupola</a> <a href="http://www.appelsiini.net/2009/9/verify-estonian-isikukood-with-javascript">versioon</a> JavaScript</p>
<p>Kui sul on mingi teine versioon siis saada mulle ka <img src='http://www.dmitri.me/blog/wp-includes/images/smilies/icon_wink.gif' alt=';-)' class='wp-smiley' /> </p>
]]></content:encoded>
			<wfw:commentRss>http://www.dmitri.me/blog/isikukood-valideerimine/feed/</wfw:commentRss>
		<slash:comments>2</slash:comments>
		</item>
		<item>
		<title>Generate static websites with Ruby (webby)</title>
		<link>http://www.dmitri.me/blog/generate-static-websites-with-ruby-webby/</link>
		<comments>http://www.dmitri.me/blog/generate-static-websites-with-ruby-webby/#comments</comments>
		<pubDate>Mon, 19 Jan 2009 12:00:41 +0000</pubDate>
		<dc:creator>Dmitri</dc:creator>
				<category><![CDATA[HTML and CSS]]></category>
		<category><![CDATA[Ruby]]></category>
		<category><![CDATA[web-development]]></category>
		<category><![CDATA[work]]></category>
		<category><![CDATA[generate]]></category>
		<category><![CDATA[webby]]></category>

		<guid isPermaLink="false">http://www.dmitri.me/blog/?p=198</guid>
		<description><![CDATA[Often we need to generate some websites with static content, for example without any line of PHP code or without Ruby on Rails, just need to have plain HTML files. As for Me I hate to edit 50 HTML pages manually. I found a nice solution. It&#8217;s  Webby
This is a great solution to complete [...]]]></description>
			<content:encoded><![CDATA[<p>Often we need to generate some websites with static content, for example without any line of PHP code or without Ruby on Rails, just need to have plain HTML files. As for Me I hate to edit 50 HTML pages manually. I found a nice solution. It&#8217;s  <a href="http://webby.rubyforge.org">Webby</a></p>
<p>This is a great solution to complete such task.</p>
<p>You can check how it&#8217;s work <a href="http://webby.rubyforge.org/learn/">here</a> or <a href="http://clarkware.com/cgi/blosxom/2008/08/06">there (old version)</a>.</p>
<p>There are more tools like Webby, <a href="http://nanoc.stoneship.org/">Nanoc</a> and <a href="http://github.com/mojombo/jekyll/tree/master">jekyll</a>. I have didn&#8217;t tried them, but I guess the functionality is the same.</p>
]]></content:encoded>
			<wfw:commentRss>http://www.dmitri.me/blog/generate-static-websites-with-ruby-webby/feed/</wfw:commentRss>
		<slash:comments>0</slash:comments>
		</item>
		<item>
		<title>Official Estonian currency rates with Ruby</title>
		<link>http://www.dmitri.me/blog/official-estonian-currency-rates-with-ruby/</link>
		<comments>http://www.dmitri.me/blog/official-estonian-currency-rates-with-ruby/#comments</comments>
		<pubDate>Fri, 19 Dec 2008 07:28:18 +0000</pubDate>
		<dc:creator>Dmitri</dc:creator>
				<category><![CDATA[Ruby]]></category>
		<category><![CDATA[money]]></category>
		<category><![CDATA[programming]]></category>

		<guid isPermaLink="false">http://www.dmitri.me/blog/?p=172</guid>
		<description><![CDATA[Just for some Ruby practice, this class do the same (gets the currency rates) as PHP in my previous post.
Check the Ruby code on Github.
]]></description>
			<content:encoded><![CDATA[<p>Just for some Ruby practice, this class do the same (gets the currency rates) as PHP in my <a href="http://www.dmitri.me/blog/estonian-currency-rates-php/">previous post</a>.</p>
<p>Check the Ruby code on <a href="http://github.com/dknight/Ruby-Valuutakursid">Github</a>.</p>
]]></content:encoded>
			<wfw:commentRss>http://www.dmitri.me/blog/official-estonian-currency-rates-with-ruby/feed/</wfw:commentRss>
		<slash:comments>1</slash:comments>
		</item>
	</channel>
</rss>
