'If you need to go global, a Localist may help!' :-)
Localist helps in multilanguage/globalized rails applications. It automatically finds the best match between the locales accepted by your users and the locales supported by your application (per rules defined in RFC2616, section 14.4: HTTP/1.1 - Header Field Definitions - Accept-Language) and maintain it in successive requests. It also offers a nice country-flag menu to allow the users to manually switch to another locale.
Features
- only 3-5 lines of code required to use it
- finds, sets and maintains the best locale match in successive requests
- smart fallback when no match is possible
- RFC2616 compilant
- provides a nice flag menu with the active locale indicator
- allows the user to manually switch the locale
- includes the flag icons of all the ISO3166-1 alpha-2 countries
- fully configurable (by variables)
- fully customizable (by overriding methods and templates)
Requirements
Download the meta-tools lib form here http://ruby.4pro.net/meta-tools/download/ and install it:
% [sudo] gem install meta-tool-1.0.gem
Repository
http://rails-localist.googlecode.com/svn/trunk/
Quick Start
in app/controllers/application.rb:
before_filter :localist
in config/environment.rb:
Localist.supported_locales = %w[ en-US it-IT es-ES fr-FR ..... ]
Localist.callback = lambda{ |client_locale| do_something_with( client_locale ) }in the head container of your layout:
<%= stylesheet_link_tag 'localist/stylesheet.css', :media=>'all' %>
somewhere in the body container of your layout or template:
<%= localist_menu %>
Author and Copyright
Copyright (c) 2007 by Domizio Demichelis