Ecosyste.ms: Awesome
An open API service indexing awesome lists of open source software.
https://github.com/printercu/activemodel_translation
Translation helpers for models
https://github.com/printercu/activemodel_translation
activemodel activerecord i18n ruby translation
Last synced: 3 months ago
JSON representation
Translation helpers for models
- Host: GitHub
- URL: https://github.com/printercu/activemodel_translation
- Owner: printercu
- License: mit
- Created: 2014-06-02T19:01:53.000Z (over 10 years ago)
- Default Branch: master
- Last Pushed: 2016-05-29T14:19:57.000Z (over 8 years ago)
- Last Synced: 2024-04-23T16:21:33.943Z (9 months ago)
- Topics: activemodel, activerecord, i18n, ruby, translation
- Language: Ruby
- Size: 5.86 KB
- Stars: 3
- Watchers: 3
- Forks: 1
- Open Issues: 0
-
Metadata Files:
- Readme: README.md
- License: LICENSE.txt
Awesome Lists containing this project
README
# ActivemodelTranslation
Lazy translations for models.
`::tranlate` method performs translation with fallback similar to resolving errors.
With one difference - it uses `strings` scope.* `activemodel.strings.admin.key`
* `activemodel.strings.user.key`
* `strings.key``User.model_name.human(plural: true)` returns translated plural model name.
## Installation
Add this line to your application's Gemfile:
```ruby
gem 'activemodel_translation'# or pick a module:
# gem 'activemodel_translation', require: 'activemodel_translation/helper'
# gem 'activemodel_translation', require: 'activemodel_translation/plural'
```And then execute:
$ bundle
Or install it yourself as:
$ gem install activemodel_translation
## Usage
```ruby
class User < ActiveRecord::Base
# lazy translation
def title
super || self.class.t('.default_title')
end
end# translated plural model name
User.model_name.human_plural# ru.yml
# activerecord:
# models_plural:
# user: Пользователи
```## Contributing
1. Fork it ( http://github.com/printercu/activemodel_translation/fork )
2. Create your feature branch (`git checkout -b my-new-feature`)
3. Commit your changes (`git commit -am 'Add some feature'`)
4. Push to the branch (`git push origin my-new-feature`)
5. Create new Pull Request