0

How can we change the pluralize rules for translations in Rails 4? I tried to modify the initialisers/inflections.rb as follows:

ActiveSupport::Inflector.inflections(:fr) do |inflect|
   inflect.irregular 'Niveau', 'Niveaux'
end

ActiveSupport::Inflector.inflections(:fr) do |inflect|
  inflect.acronym 'RESTful'
end

and pass the translation in the page like that:

= link_to t('links.back_to', model: Level.model_name.human.pluralize), levels_path

but it is still translated by applying the default patterns. Any idea on how to fix that ? Thank you

belgoros
  • 3,590
  • 7
  • 38
  • 76
  • Did you restart the server after making the change? – Waynn Lue Nov 21 '15 at 02:04
  • Did you tried `'Niveau'.pluralize(:fr)` in the rails console? – Mareq Nov 21 '15 at 08:27
  • Sure, I restarted the server after the changes. When trying in console: [1] pry(main)> Level.model_name.human.pluralize => "Niveaus" [2] pry(main)> Level.model_name.human.pluralize(:fr) => "Niveaux". So passing the locale everywhere in the views is a little bit DRYless :) Any other solution ? – belgoros Nov 22 '15 at 09:03

0 Answers0