Rails distance_of_time_in_words returns “en, about_x_hours”

后端 未结 3 1291
隐瞒了意图╮
隐瞒了意图╮ 2021-02-04 17:12

I\'m having a weird problem, hoping someone knows what the issue is...

Using distance_of_time_in_words (and consequently time_ago_in_words) is not returning the actual t

3条回答
  •  庸人自扰
    2021-02-04 17:44

    So I finally got it to work!! Hope this helps anyone who might have the same problem...

    Basically half of what Lichtamberg first said was correct. The en.yml had to be as follows:

    en:
      x_minutes:
        one:   "1 minute"
        other: "%{count} minutes"
    

    Note that x_minutes is not under datetime and that it has one and other. Further, there is no need for I18n.l as I18n is already implemented in the distance_of_time_in_words method.

    So with the above (plus all the other about_x_hours, x_days, etc patterns that you can find on the file Lichtamberg included), just do:

    time_ago_in_words(3.minutes.ago)
    

    And... voila!

提交回复
热议问题