codegram / date_validator

A simple, ORM agnostic, Ruby >=2.2 compatible date validator for Rails, based on ActiveModel.
http://thoughts.codegram.com/date-validation-with-rails-3
MIT License
495 stars 82 forks source link

Overridable default locale YAML #71

Closed ppworks closed 7 years ago

ppworks commented 8 years ago

I changed the path of locale files from locale/*.yml to config/locale/*.yml(It's Rails Engine default).

Before

I18n.load_path
=> ["/Users/koshikawa/tmp/fugo/vendor/bundle/gems/activesupport-4.2.5/lib/active_support/locale/en.yml",
 "/Users/koshikawa/tmp/fugo/vendor/bundle/gems/activemodel-4.2.5/lib/active_model/locale/en.yml",
 "/Users/koshikawa/tmp/fugo/vendor/bundle/gems/activerecord-4.2.5/lib/active_record/locale/en.yml",
 "/Users/koshikawa/tmp/fugo/vendor/bundle/gems/actionview-4.2.5/lib/action_view/locale/en.yml",
 "/Users/koshikawa/app/config/locales/en.yml,
 "/Users/koshikawa/repository/github.com/codegram/date_validator/config/locales/af.yml",
 "/Users/koshikawa/repository/github.com/codegram/date_validator/config/locales/ca.yml",
 "/Users/koshikawa/repository/github.com/codegram/date_validator/config/locales/de.yml",
 "/Users/koshikawa/repository/github.com/codegram/date_validator/config/locales/en.yml",
 "/Users/koshikawa/repository/github.com/codegram/date_validator/config/locales/es.yml",
 "/Users/koshikawa/repository/github.com/codegram/date_validator/config/locales/fr.yml",
 "/Users/koshikawa/repository/github.com/codegram/date_validator/config/locales/it.yml",
 "/Users/koshikawa/repository/github.com/codegram/date_validator/config/locales/ja.yml",
 "/Users/koshikawa/repository/github.com/codegram/date_validator/config/locales/nl.yml",
 "/Users/koshikawa/repository/github.com/codegram/date_validator/config/locales/pl.yml",
 "/Users/koshikawa/repository/github.com/codegram/date_validator/config/locales/pt-BR.yml",
 "/Users/koshikawa/repository/github.com/codegram/date_validator/config/locales/ru.yml",
 "/Users/koshikawa/repository/github.com/codegram/date_validator/config/locales/tr.yml"]

After

I18n.load_path
=> ["/Users/koshikawa/tmp/fugo/vendor/bundle/gems/activesupport-4.2.5/lib/active_support/locale/en.yml",
 "/Users/koshikawa/tmp/fugo/vendor/bundle/gems/activemodel-4.2.5/lib/active_model/locale/en.yml",
 "/Users/koshikawa/tmp/fugo/vendor/bundle/gems/activerecord-4.2.5/lib/active_record/locale/en.yml",
 "/Users/koshikawa/tmp/fugo/vendor/bundle/gems/actionview-4.2.5/lib/action_view/locale/en.yml",
 "/Users/koshikawa/repository/github.com/codegram/date_validator/config/locales/af.yml",
 "/Users/koshikawa/repository/github.com/codegram/date_validator/config/locales/ca.yml",
 "/Users/koshikawa/repository/github.com/codegram/date_validator/config/locales/de.yml",
 "/Users/koshikawa/repository/github.com/codegram/date_validator/config/locales/en.yml",
 "/Users/koshikawa/repository/github.com/codegram/date_validator/config/locales/es.yml",
 "/Users/koshikawa/repository/github.com/codegram/date_validator/config/locales/fr.yml",
 "/Users/koshikawa/repository/github.com/codegram/date_validator/config/locales/it.yml",
 "/Users/koshikawa/repository/github.com/codegram/date_validator/config/locales/ja.yml",
 "/Users/koshikawa/repository/github.com/codegram/date_validator/config/locales/nl.yml",
 "/Users/koshikawa/repository/github.com/codegram/date_validator/config/locales/pl.yml",
 "/Users/koshikawa/repository/github.com/codegram/date_validator/config/locales/pt-BR.yml",
 "/Users/koshikawa/repository/github.com/codegram/date_validator/config/locales/ru.yml",
 "/Users/koshikawa/repository/github.com/codegram/date_validator/config/locales/tr.yml",
 "/Users/koshikawa/app/config/locales/en.yml"]

This change makes us be able to override default locale setting as below.

*path_to_your_app_root/config/locale/.yml**

en:
  errors:
    messages:
      not_a_date: "is not a DATE!!!" 
ppworks commented 8 years ago

Could you check this? @codegram