Coder Social home page Coder Social logo

moro / i18n_generators Goto Github PK

View Code? Open in Web Editor NEW

This project forked from amatsuda/i18n_generators

1.0 2.0 0.0 274 KB

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

Home Page: http://github.com/amatsuda/i18n_generators

License: MIT License

Ruby 100.00%

i18n_generators's Introduction

I18n generators

This gem plugin generates a set of locale files for Rails 2.2 and 2.3 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.)

    1. 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
    1. 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

% gem install 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

i18n_generators's People

Contributors

amatsuda avatar moro avatar valda avatar

Stargazers

 avatar

Watchers

 avatar  avatar

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. 📊📈🎉

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.