amatsuda / i18n_generators

A pack of Rails generators gem plugin that generates Rails 2.2 I18n locale files for almost every known locale.

This URL has Read+Write access

amatsuda (author)
Tue Mar 17 17:35:27 -0700 2009
commit  ca06a6bec05eb3deacd3abb364864ff49a49b18c
tree    46d90ca0b1ccf62a1599170a776ccd807e1e5042
parent  be6f5a289b54576319c711680bc6be8ee9945817
name age message
file History.txt Tue Mar 17 17:34:16 -0700 2009 Update History for 0.6.0 [amatsuda]
file MIT-LICENSE Wed Nov 12 02:59:51 -0800 2008 Initial commit [amatsuda]
file README.rdoc Thu Dec 18 04:06:17 -0800 2008 Update document [amatsuda]
file Rakefile Wed Dec 17 16:50:31 -0800 2008 Add spec task [amatsuda]
directory generators/ Tue Mar 17 17:06:39 -0700 2009 Avoid adding blank line after blank line [amatsuda]
file i18n_generators.gemspec Tue Mar 17 17:35:27 -0700 2009 Update gem version to 0.6.0 [amatsuda]
directory spec/ Tue Jan 20 22:21:26 -0800 2009 Add magick comment [amatsuda]
README.rdoc

I18n generators

This gem plugin generates a set of locale files for Rails 2.2 i18n feature.

FEATURES

This gem/plugin provides following four script/generate commands.

1. Generate I18n Scaffold

% ./script/generate i18n_scaffold ja (de-AT, pt-BR, etc.)

Generates I18n aware scaffold.

2. Generate Locale Files for ActiveRecord/ActiveSupport/ActionPack

% ./script/generate i18n_locale ja (de-AT, pt-BR, etc.)

or

% ./script/generate i18n —locale ja (de-AT, pt-BR, etc.)

  • A. If The Locale File Exists In Rails-I18n Repository

Firstly, the generator checks here. github.com/svenfuchs/rails-i18n/tree/master/rails/locale If the spacified .yml file exists in the repository, the generator downloads and puts the file into your config/locales directory. Then the generater sets the application default locale to the specified locale.

This will generate following locale file.

    config/locales/ja.yml
  • B. Else

The generator copies the en.yml file (bundled inside Rails framework) into config/locales directory, and one-to-one localizes/translates each attribute value into the specified locale/language. Then the generater sets the application default locale to the specified locale.

For example,

% ./script/generate i18n_locale zh

will generate following locale files.

    config/locales/active_support_zh.yml
    config/locales/active_record_zh.yml
    config/locales/action_view_zh.yml

3. Generate Translation YAML File For All Models/Attributes and views/**/*.erb

% ./script/generate i18n_translation ja (de-AT, pt-BR, etc.)

or

% ./script/generate i18n —translation ja (de-AT, pt-BR, etc.)

This will generate following YAML file.

    config/locales/translation_ja.yml

The generator scans your app/models directory, and generates a YAML file with all the AR model names and attributes so that you don’t have to write the YAML skeleton manually or by copy/paste. In addition, the generator scans all the *.erb files in your app/views/** directory, and picks all the keys for I18n.translate, then adds them to the YAML file. In addition, the generator tries to translate each of them into the specified language. The generator doesn’t overwrite the existing value so that you can rerun the generator again and again just like Annotate Model command.

4. Generate All

% ./script/generate i18n ja (de-AT, pt-BR, etc.)

Executes 2 and 3 at once.

REQUIREMENTS:

INSTALL:

  • As a gem

% sudo gem source gems.github.com

% sudo gem install amatsuda-i18n_generators

  • As a Rails plugin

% ./script/plugin install git://github.com/amatsuda/i18n_generators.git

CAUTION

Current version of this plugin is very very very roughly implemented just for experiment. Every time you execute the generate command, the plugin connects to the Unicode CLDR website and scrapes the huge amount of its contents. Please be careful not to harm your network environment and CLDR website by running this plugin too many times.

Copyright © 2008 Akira Matsuda, released under the MIT license