I18n::InvalidPluralizationData error
Based on help from this site, I was able to set up a display for the person's age. But when I do something like <%= distance_of_time_in_words(DateTime.now, p.dob) %>
, I get an invalidPliralizationData error, "translation data {:one=>"1 an", :many=>"{{count}} ans"} can not be used with :count => 30"
My yml file has all the translations for datetime:distance_开发者_如何学JAVAin_words_... where ... defines all the various possible occurrences.
Again help will be highly appreciated. All previous Google searches haven't been fruitful
I think the hash keys are :one
and :other
(not :many
). I suspect they chose this wording because :other
also includes the zero case (?).
Anyway, hope that helps!
It seems you didn't define :many in your localization file.
English has only :one and :many
If you are using :en then you should replace :many by :other.
Else if you are using another language you need to check the mapping key for 30 in config/locales/plurals.rb and define it in your localization file.
For example, 30 should be :many in :ar Arabic
Helped me with such localization file
en:
datetime:
distance_in_words:
less_than_x_seconds:
one: "1 second" # default was: "less than 1 second"
many: "%{count} seconds" # default was: "less than %{count} seconds"
x_seconds:
one: "1 second"
many: "%{count} seconds"
less_than_x_minutes:
one: "a minute" # default was: "less than a minute"
many: "less than %{count} minutes" # default was: "less than % {count} minutes"
x_minutes:
one: "1 minute"
many: "about %{count} minutes"
about_x_hours:
one: "1 hour" # default was: "about 1 hour"
many: "about %{count} hours" # default was: "about %{count} hours"
x_days:
one: "1 day"
many: "%{count} days"
about_x_months:
one: "1 month" # default was: "about 1 month"
many: "%{count} months" # default was: "about %{count} months"
x_months:
one: "1 month"
many: "%{count} months"
about_x_years:
one: "1 year" # default was: "about 1 year"
many: "%{count} years" # default was: "about %{count} years"
over_x_years:
one: "1 year" # default was: "over 1 year"
many: "%{count} years" # default was: "over %{count} years"
almost_x_years:
one: "1 year" # default was: "almost 1 year"
many: "%{count} years" # default was: "almost %{count} years"
As you can see, :other key changed to :many
精彩评论