13

I have got a model, that is called vehicle.

In my translation the model must be: vehicle => Fahrzeug vehicles => Fahrzeuge

I tried to set this in the locales file, but it did not work:

  activerecord:
    models:
      vehicle: Fahrzeug
      vehicles: Fahrzeuge
Mark
  • 7,507
  • 12
  • 52
  • 88

3 Answers3

31

ActiveRecord first translates the model name using I18n.translate with default

:count => 1

Pluralizing this string afterwards dosn't know about model translations.

But, human accepts options so

Vehicle.model_name.human(:count => 2)

does the trick together with pluralized translations:

de:
  activerecord:
    models:
      vehicle:
        one: 'Fahrzeug'
        other: 'Fahrzeuge'
Waiting for Dev...
  • 12,629
  • 5
  • 47
  • 57
Martin M
  • 8,430
  • 2
  • 35
  • 53
  • 1
    Since different languages have different plural rules, a look at [this table](http://unicode.org/repos/cldr-tmp/trunk/diff/supplemental/language_plural_rules.html) might be interesting. – martin Sep 09 '13 at 12:16
  • so what would arabian poeple use in the header of an index? `few` or `many`? I don't know. But of cause you can use `:count=>8` for `few` or `:count => 70` for many. If you know the amount, you can pass it to `human`. – Martin M Sep 09 '13 at 17:02
  • There should be a version that's more pleasant to the eye – mzrnsh Feb 01 '20 at 16:22
0

you are just one step away: http://guides.rubyonrails.org/i18n.html#pluralization

 activerecord:
    models:
      vehicle:
        one: Fahrzeug
        many: Fahrzeuge

in rails 4 this seems to be changed from many to other

en:
  activerecord:
    models:
      user:
        one: Dude
        other: Dudes
phoet
  • 18,688
  • 4
  • 46
  • 74
-1

Have you tried other instead of many? That worked for me at least. I am on Rails 3.2.3.

Tintin81
  • 9,821
  • 20
  • 85
  • 178