【发布时间】:2011-05-25 07:15:30
【问题描述】:
我找到了 ActiveSupport 变形器类。在哪里可以找到初始化英语变形器的代码?
【问题讨论】:
标签: ruby activesupport pluralize
我找到了 ActiveSupport 变形器类。在哪里可以找到初始化英语变形器的代码?
【问题讨论】:
标签: ruby activesupport pluralize
ActiveSupport inflector.rb 文件包括所有变形库和模块。
如果你想自定义它,在你的 Rails config/initializers 路径中有一个名为 inflections.rb 的文件。
默认包含
# 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
您可以对其进行编辑以自定义 Inflector 行为。
【讨论】:
英文规则在 ActiveSupport 中(特别是在 lib/active_support/inflections.rb 中)。
【讨论】: