I18n :: InvalidPluralizationData错误

时间:2011-04-12 19:27:59

标签: ruby-on-rails

根据本网站的帮助,我能够为这个人的年龄设置一个显示器。但是,当我执行<%= distance_of_time_in_words(DateTime.now, p.dob) %>之类的操作时,我会得到一个invalidPliralizationData error, "translation data {:one=>"1 an", :many=>"{{count}} ans"} can not be used with :count => 30" 我的yml文件包含datetime的所有翻译:distance_in_words _... where ...定义所有可能的各种事件。

再次提供帮助将受到高度赞赏。之前的所有Google搜索都没有取得丰硕成果

3 个答案:

答案 0 :(得分:11)

我认为哈希键是:one:other(不是:many)。我怀疑他们选择了这个措辞,因为:other还包括零个案(?)。

无论如何,希望有所帮助!

答案 1 :(得分:8)

您似乎没有在本地化文件中定义:很多。

英语只有:一个和多个

如果你正在使用:en那么你应该替换:many by:other。

否则,如果您使用其他语言,则需要在config/locales/plurals.rb中检查30的映射键,并在本地化文件中对其进行定义。

例如,30应该是:many in:ar Arabic

答案 2 :(得分:1)

帮助我使用这样的本地化文件

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"

如您所见,:其他密钥更改为:许多