Ecosyste.ms: Awesome
An open API service indexing awesome lists of open source software.
https://github.com/gbh/acts_as_localized
Localization accessor mechanism for AR models
https://github.com/gbh/acts_as_localized
i18n rails
Last synced: 22 days ago
JSON representation
Localization accessor mechanism for AR models
- Host: GitHub
- URL: https://github.com/gbh/acts_as_localized
- Owner: GBH
- License: mit
- Created: 2015-04-08T23:08:52.000Z (almost 10 years ago)
- Default Branch: master
- Last Pushed: 2015-05-28T15:01:05.000Z (over 9 years ago)
- Last Synced: 2024-12-27T05:10:55.718Z (about 1 month ago)
- Topics: i18n, rails
- Language: Ruby
- Homepage:
- Size: 168 KB
- Stars: 12
- Watchers: 3
- Forks: 0
- Open Issues: 0
-
Metadata Files:
- Readme: README.md
- License: LICENSE
Awesome Lists containing this project
README
# ActsAsLocalized
[![Gem Version](https://img.shields.io/gem/v/acts_as_localized.svg?style=flat)](http://rubygems.org/gems/acts_as_localized) [![Gem Downloads](https://img.shields.io/gem/dt/acts_as_localized.svg?style=flat)](http://rubygems.org/gems/acts_as_localized) [![Build Status](https://img.shields.io/travis/GBH/acts_as_localized.svg?style=flat)](https://travis-ci.org/GBH/acts_as_localized)ActsAsLocalized extends ActiveRecord to add localization mechanism for model attributes.
## Example
```ruby
create_table :pictures do |t|
t.string :title_en
t.string :title_fr
t.text :description_en
t.text :description_fr
endclass Picture < ActiveRecord::Base
acts_as_localized :title, :description
endpicture = Picture.create!(
:title_en => 'Title EN',
:title_fr => 'Title FR',
:description_en => 'Description EN',
:description_fr => 'Description FR',
)I18n.locale = :en
picture.title #=> Title EN
picture.title = 'Updated Title EN' # same as `picture.title_en=`I18n.locale = :fr
picture.title # => Title FR
picture.title = 'Updated Title FR' # same as `picture.title_fr=`
```---
Copyright 2015 Oleg Khabarov