Transforms gettext to I18n API and generate SimpleBackend locale files
Ruby JavaScript
Switch branches/tags
Nothing to show
Pull request Compare This branch is 9 commits ahead of japetheape:master.
Fetching latest commit…
Cannot retrieve the latest commit at this time.
Permalink
Failed to load latest commit information.
lib
rdoc
tasks
test
.gitignore
MIT-LICENSE
README
Rakefile
init.rb
install.rb
uninstall.rb

README

GettextToI18n
=============

This plugin will convert your complete Rails project from Gettext calls to the new i18n api calls introduced in Rails 2.2.2. 
Please Backup your Code before running this plugin. It will touch your code and things could always go wrong.

Example
=======

CONTROLLERS:
Following code is placed in apps/controllers/articles_controller.rb

def foo
  flash[:notice] = _("Some string that will be translated")
  render :foo
end

this will be converted into:

def foo
  flash[:notice] = I18n.t("controllers.articles.some_string_that0")
  render :foo
end

it will place an entry into config/locales/controllers/articles_controller/en.yml

en: 
  controllers: 
    articles_controller:
      some_string_that0: "Some string that will be translated, into %{lan}}"
      
The same way this plugin works with Models, Helpers, Mailers and files in lib.

With the views it works a little bit different.       

VIEWS:
Following string is placed in apps/views/articles/index.html.haml

  <%=_("Another string that will be translated, into %{lan}", % {:lan => 'english'}) %>

will be converted into:

  <%=t(:another_string_that0, :lan => 'english' %>

it will place an entry into config/locales/views/articles/en.yml

en:
  articles:
    index:
      another_string_that0: "Another string that will be translated, into %{lan}}"

It will follow the lazy lookup standard.

If a yml-file already exists, it will merge the existing entries with the new entries, without deleting stuff.

This plugin does not cover an automatically translation from model attributes and error messages yet. But it should help you to migrate from gettext to I18n.

Usage
=======
To convert all your views, controllers, models, mailers, helper and lib files to the new format.

  rake gettext_to_i18n:transform

But you can also uncomment a few types in the plugin code (base.rb), and just convert the views in the first step. 
Further you can configure the languages the way you like it. You can translate for example just from English to German, or ten languages in one step.

Installation
=======
./script/plugin install github.com/mattherick/gettext_to_i18n/


-------------

This is a fork from Jaap van der Meer (http://github.com/japetheape/gettext_to_i18n)
Copyright (c) 2010 Matthias Frick, released under the MIT license