0000sir / i18n_from_comments

Make i18n locales file of rails projects from database table & field comments

Geek Repo:Geek Repo

Github PK Tool:Github PK Tool

I18nFromComments

This gem will help you create i18n locales file from your database comments.

You should (always) comment your database first.

Installation

Add this line to your application's Gemfile:

gem 'i18n_from_comments', git: 'https://github.com/0000sir/i18n_from_comments.git'

And then execute:

$ bundle

Or install it yourself as:

$ gem install i18n_from_comments

Usage

  1. Add table and field comments in your migrations like:
create_table :products, comment: '产品' do |t|
    t.string :name, comment: '产品名称'
    t.string :barcode, comment: '条形码'
    t.string :description, comment: '产品说明'
    t.float :msrp, comment: '最高售价'
    t.float :our_price, comment: '售价'

    t.timestamps
end
  1. Run your migration.
rake db:migrate
  1. rake command:
rake i18n:from_comments LANG=zh-CN

This will generate config/locales/zh-CN.yml file for views.

Special any other language with environment variable LANG

Development

After checking out the repo, run bin/setup to install dependencies. You can also run bin/console for an interactive prompt that will allow you to experiment.

To install this gem onto your local machine, run bundle exec rake install. To release a new version, update the version number in version.rb, and then run bundle exec rake release, which will create a git tag for the version, push git commits and tags, and push the .gem file to rubygems.org.

Contributing

Bug reports and pull requests are welcome on GitHub at https://github.com/[USERNAME]/i18n_from_comments.

License

The gem is available as open source under the terms of the MIT License.

Thanks

Active Record Database Documentation

Rails 5 supports adding comments in migrations

About

Make i18n locales file of rails projects from database table & field comments

License:MIT License


Languages

Language:Ruby 97.3%Language:Shell 2.7%