I18n is not painful anymore. Let’s google translate help you do it.
sudo gem install htmlentities sudo gem install json script/plugin install git://github.com/ihower/i18n_google_translate.git
I18n.backend = I18n::Backend::GoogleTranslate.new I18n.default_locale = 'en' # your source language LOCALES_AVAILABLE = I18n::Backend::GoogleTranslate::GOOGLE_LANGUAGES.map.sort
before_filter :set_locale def set_locale session[:locale] = params[:locale] if params[:locale] I18n.locale = session[:locale] || I18n.default_locale end
<%= I18n.t "Login" %> <%= I18n.l Time.now %> <% form_tag '', :method => :get do %> <%= select_tag("locale", options_for_select(LOCALES_AVAILABLE, I18n.locale), { :index => nil, :onchange => 'this.form.submit()'}) %> <% end %>
- Author: Wen-Tien Chang
- Copyright © 2008 Handlino Inc.
- Licensed under the MIT: http://www.opensource.org/licenses/mit-license.php