Where are the English pluralization rules for ActiveSupport defined?
-
09-10-2019 - |
Question
I found the ActiveSupport inflector class. Where can I find the code that initializes the inflector for English?
Solution
The English rules are in ActiveSupport (specifically in lib/active_support/inflections.rb).
OTHER TIPS
The ActiveSupport inflector.rb file includes all the inflection libraries and modules.
If you want to customize it, there's a file called inflections.rb
in your Rails config/initializers
path.
By default it contains
# Be sure to restart your server when you modify this file.
# Add new inflection rules using the following format
# (all these examples are active by default):
# ActiveSupport::Inflector.inflections do |inflect|
# inflect.plural /^(ox)$/i, '\1en'
# inflect.singular /^(ox)en/i, '\1'
# inflect.irregular 'person', 'people'
# inflect.uncountable %w( fish sheep )
# end
You can edit it to customize the Inflector
behavior.
Licensed under: CC-BY-SA with attribution
Not affiliated with StackOverflow