This gem will help you create i18n locales file from your database comments.
You should (always) comment your database first.
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
- 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- Run your migration.
rake db:migrate- rake command:
rake i18n:from_comments LANG=zh-CNThis will generate config/locales/zh-CN.yml file for views.
Special any other language with environment variable LANG
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.
Bug reports and pull requests are welcome on GitHub at https://github.com/[USERNAME]/i18n_from_comments.
The gem is available as open source under the terms of the MIT License.