Google translate powered backend for Rails-2.2 i18n
Ruby
Switch branches/tags
Nothing to show
Fetching latest commit…
Cannot retrieve the latest commit at this time.
Permalink
Failed to load latest commit information.
lib/i18n/backend
README.textile

README.textile

Rails i18n Google Translate Backend

I18n is not painful anymore. Let’s google translate help you do it.

Install

    sudo gem install htmlentities
    sudo gem install json
    script/plugin install git://github.com/ihower/i18n_google_translate.git

Usage Example

environment.rb

    I18n.backend = I18n::Backend::GoogleTranslate.new
    I18n.default_locale = 'en' # your source language
    LOCALES_AVAILABLE = I18n::Backend::GoogleTranslate::GOOGLE_LANGUAGES.map.sort

application.rb

  before_filter :set_locale

  def set_locale
    session[:locale] = params[:locale] if params[:locale]
    I18n.locale = session[:locale] || I18n.default_locale
  end

view example

  <%= 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 & License