In Rails we can’t have a class called Class as it is a protected word. I am currently making a site where I need to have a class called Class as the site is dealing with education. I could’ve used Course or something similar but as this is going to be a multilingual site for an Irish organisation and as a developer with an intermediate level of Irish I decided to use the Irish word for class, Rang. Irish unlike most pluralisations in English doesn’t use S and will pluralise differently depending on the word. So, the plural of Rang is not Rangs but Ranganna.
Irish is classed as Definately endangered by the UNESCO’s Atlas of the World’s Languages in Danger and as such doesn’t have the support that some other world languages do in Rails (something I hope to change when I eventually achieve a degree of fluency!). Due to this it doesn’t support pluralisation of the Irish language so I will have to use inflections to let my site know how to do the pluralisation.
I ran into an issue as I wanted to use the same plural for English and Irish and wasn’t sure how to structure the file and settled on this as a solution:
ActiveSupport::Inflector.inflections(:en) do |inflect|
inflect.irregular 'rang', 'ranganna'
end
ActiveSupport::Inflector.inflections(:ga) do |inflect|
inflect.irregular 'rang', 'ranganna'
end
To test if your inflections are set up run a rails console (rails console) and run either of these commands for the locales:
my_site(dev):001> 'Rang'.pluralize(locale = :ga)
=> "Ranganna"
my_site(dev):002> 'Rang'.pluralize(locale = :en)
=> "Ranganna"