2

これが私のen.yml ロケールです

en:
  datetime:
    distance_in_words:
      less_than_x_seconds:
        one: "1 sec"
        other: "%{count} secs"
      x_seconds:
        one: "1 sec"
        other: "%{count} secs"
      less_than_x_minutes:
        one: "1 min"
        other: "%{count} mins"
      x_minutes:
        one: "1 min"
        other: "%{count} mins"
      about_x_hours:
        one: "1 hour"
        other: "%{count} hours"
      x_days:
        one: "1 day"
        other: "%{count} days"
      about_x_months:
        one: "1 month"
        other: "%{count} months"
      x_months:
        one: "1 month"
        other: "%{count} months"
      about_x_years:
        one: "1 year"
        other: "%{count} years"
      over_x_years:
        one: "1 year"
        other: "%{count} years"
      almost_x_years:
        one: "1 year"
        other: "%{count} years"

私が何かを投稿するたびに、私は使用します

<%= link_to time_ago_in_words(post.created_at), post_path(post) %>

投稿が作成されてからの時間を表示しますが、1 sec2 secsなどを表示する代わりに... 1 minを表示し、で続行します

4

1 に答える 1

4

のパラメータtrueに渡す必要があります。time_ago_in_wordsinclude_seconds

time_ago_in_words(post.created_at, true)

詳細については、 で使用されている のドキュメントをdistance_of_time_in_wordstime_ago_in_words参照してください。

于 2012-09-10T07:36:34.000 に答える