Home > i18n_google_translate

i18n_google_translate

I18n_google_translate is a project mainly written in Ruby, it's free.

Google translate powered backend for Rails-2.2 i18n

h1. Rails i18n Google Translate Backend

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

h2. Install

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

h2. Usage Example

h3. environment.rb

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

h3. application.rb

  before_filter :set_locale

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

h3. 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 %>

h2. Author & License

  • Author: "Wen-Tien Chang":mailto:[email protected]
  • Copyright (c) 2008 Handlino Inc.
  • Licensed under the MIT: http://www.opensource.org/licenses/mit-license.php
Previous:wibget