开发者

Where are the English pluralization rules for ActiveSupport defined?

开发者 https://www.devze.com 2023-01-30 06:36 出处:网络
I found the ActiveSupport infl开发者_运维知识库ector class. Where can I find the code that initializes the inflector for English?The ActiveSupport inflector.rb file includes all the inflection librari

I found the ActiveSupport infl开发者_运维知识库ector class. Where can I find the code that initializes the inflector for English?


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.


The English rules are in ActiveSupport (specifically in lib/active_support/inflections.rb).

0

精彩评论

暂无评论...
验证码 换一张
取 消