Skip to content

ihower/i18n_google_translate

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

3 Commits
 
 
 
 

Repository files navigation

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

About

Google translate powered backend for Rails-2.2 i18n

Resources

Stars

Watchers

Forks

Releases

No releases published

Packages

No packages published

Languages