Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Translate model's plural form

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
like image 353
Mark Avatar asked Jul 03 '12 17:07

Mark


1 Answers

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'
like image 79
Martin M Avatar answered Nov 07 '22 07:11

Martin M