Skip to content

Commit

Permalink
Add docs
Browse files Browse the repository at this point in the history
  • Loading branch information
lucasmazza committed May 30, 2012
1 parent 2666c7f commit 8704849
Showing 1 changed file with 21 additions and 0 deletions.
21 changes: 21 additions & 0 deletions README.md
Expand Up @@ -109,6 +109,18 @@ end

If the method has a writer method, in this case `total=`, that'd get a parsed version for input values as well.

With `localize_methods` is possible to localize objects that aren't inheriting from `ActiveRecord::Base`, as long that
your class have both reader and writer methods available:

```ruby
class Product
include I18n::Alchemy
localize_methods :released_at => :date

attr_accessor :released_at
end
```

### Custom Parsers

If you want to customize the way an attribute is parsed/localized, you can create a custom parser that looks like this:
Expand Down Expand Up @@ -141,6 +153,15 @@ end

By doing this, **I18n::Alchemy** will be set up to use your custom parser for that particular attribute, which in this case will make use of the `:custom` date format in your i18n locale.

If you are using `localize_methods`, you can mix the custom parsers with your existing configuration:

```ruby
class Product < ActiveRecord::Base
include I18n::Alchemy
localize_methods :total => MyCustomNumberParser
end
```

## I18n configuration

Right now the lib uses the same configuration for numeric, date and time values from Rails:
Expand Down

0 comments on commit 8704849

Please sign in to comment.