Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

support i18n #170

Open
wants to merge 3 commits into
base: master
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
14 changes: 14 additions & 0 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -543,6 +543,20 @@ Constants are formed by first stripping all non-word characters and then upcasin

The field specified as the _enum_accessor_ must contain unique data values.

## I18n

ActiveHash supports i18n as ActiveModel.
Put following code in one of your locale file (e.g. `config/locales/LANGUAGE_CODE.yml`)

```yaml
# for example, inside config/locales/ja.yml
ja:
activemodel:
models:
# `Country.model_name.human` will evaluates to "国"
country: "国"
```

## Contributing

If you'd like to become an ActiveHash contributor, the easiest way it to fork this repo, make your changes, run the specs and submit a pull request once they pass.
Expand Down
2 changes: 1 addition & 1 deletion lib/active_hash/base.rb
Original file line number Diff line number Diff line change
Expand Up @@ -57,7 +57,7 @@ def normalize(v)
end

if Object.const_defined?(:ActiveModel)
extend ActiveModel::Naming
extend ActiveModel::Translation
include ActiveModel::Conversion
else
def to_param
Expand Down