0
irb(main):023:0> article.impressions_count
=> 26

In the article show view I have:

<%= t(".impressions", :impressions => @article.impressions_count) %>

I would like pluralize with something like this on my es.yml file:

impressions:
 one: "%{impressions} visualización"
 other: "%{impressions} visualizaciones"

However I get:

{:one=>"%{impressions} visualización", :other=>"%{impressions} visualizaciones"}

How can I pluralize the article impressions_count attribute?

Thanks!

hyperrjas
  • 10,666
  • 25
  • 99
  • 198

1 Answers1

0

Instead :impressions, pass :count as a key

<%= t(".impressions", count: @article.impressions_count) %>

one: "%{count} visualización"
other: "%{count} visualizaciones"
klaffenboeck
  • 6,297
  • 3
  • 23
  • 33
  • This code does works if reload page 1 or more times. Immediately after creating the object I get the same result: `{:one=>"%{count} visualización", :other=>"%{count} visualizaciones"}` Thanks! – hyperrjas Oct 04 '13 at 15:41
  • do you use ajax or something alike? – klaffenboeck Oct 04 '13 at 22:10
  • No. I use redirect_to after of create the object :). Thanks!. I have added a `unless` condition in `@article.impressions_count` is nil don't show `@article.impressions_count` to remove the error the first time. – hyperrjas Oct 05 '13 at 09:55