adzap / validates_timeliness

Date and time validation plugin for ActiveModel and Rails. Supports multiple ORMs and allows custom date/time formats.
MIT License
1.59k stars 227 forks source link

Localize dates in error messages #150

Open florent opened 7 years ago

florent commented 7 years ago

Hi, Simple change to take advantage of I18n when displaying dates in error messages. I need months in French :)

adzap commented 7 years ago

Thanks for this.

One issue is that most of the translations do not belong in this gem. Month names etc. are handled by Rails. Please look a the English i18n yml file, those are the only keys controlled by this gem.

If you can reduce the yml file to just those keys this will make a great addition.

florent commented 7 years ago

The keys in the existing English i18n yml file don't provide any translation for days/months names. Therefore it's impossible to localize dates using any other thing than numbers.

I understand that you want to be framework/lib agnostic but I still believe that the gem must provide a way to localize dates properly.

Most users will use it with Rails, so why not provide support for rails i18n translations and fallback to #strftime if the i18n keys are missing? Rails I18n keys for this are kind of a de-facto standard after all.

If you still don't want to do this, you could always add your own I18n keys for days/month names. You'd remain independent from other libs and allow dates localizations.

What do you think?