Skip to content


Subversion checkout URL

You can clone with HTTPS or Subversion.

Download ZIP
Demo for Rails 2.2 internationalization & localization features
branch: master
Failed to load latest commit information.
app Err, fixing stupid code written in haste
config Bring Czech locale file uptodate
db Initial commit (working application)
doc More RDoc formatting; README_FOR_APP as symlink
log Fixed .gitignore in log/ and /tmp
script Initial commit (working application)
test Err, fixing stupid code written in haste
tmp Deleted Rails as submodule from vendor/rails since version 2.2 was fi…
vendor Deleted Rails as submodule from vendor/rails since version 2.2 was fi…
.gitignore Do not gitignore Rails as we will put them in submodule
README.rdoc Fixed typos. "Internalization" really has nothing to do with internat…
README_FOR_RAILS Initial commit (working application)
Rakefile Initial commit (working application)


Demo application for Rails internationalization API

Simple & minimal Rails application to test the internationalization and localization features of Rails 2.2 and later. I keep this application up-to-date with my current contract, so you can follow the commits for (possible) API changes and gotchas.

It shows how you can override Rails default locale/language ('en') in views, in ActiveRecord validation messages, etc. It shows you how to test internationalization features.

Tries to set some reasonable pattern to load translation files and set locale either from request domain (.com, .de, etc) or request params. Do not ever set locale to cookie or session, as it breaks basic assumptions about web. Read this discussion for context:

The application includes translation file for Czech language so you can easily roll your own Spanish, German, Polish, etc version just by duplicating the file, renaming it and changing the translation strings. After server restart you should see your language in language bar at the top of the page.

Installation & Requirements

  • Download & unpack archive or git clone from Github []

  • The application requires Rails version 2.2 or later. Either upgrade your Rails gem by running

    $ sudo gem update rails
  • or just download and freeze Rails into vendor/rails

    $ rake rails:freeze:edge RELEASE=2.2.2
  • Run migrations (to be able to test ActiveRecord message localizations) by rake db:migrate

  • Run script/server and point your browser at localhost:3000

About setting the locale from the request domain

Usually the most sane approach to setting locale/language version of the application is from the domain: loads English, Spanish. This works best for content heavy websites and search engines love it.

The ApplicationController#extract_locale_from_tld sets locale from the top-level domain (ie. the “es” in loads Spanish version). To test this locally, you have to edit your /etc/hosts file by inserting lines like:

Then just load your application as usual at or and you should see the locale being switched.

About Rails i18n

See guide at See for more info and get in touch at

Something went wrong with that request. Please try again.