【问题标题】:Where are the English pluralization rules for ActiveSupport defined?ActiveSupport 的英文复数规则在哪里定义?
【发布时间】:2011-05-25 07:15:30
【问题描述】:

我找到了 ActiveSupport 变形器类。在哪里可以找到初始化英语变形器的代码?

【问题讨论】:

    标签: ruby activesupport pluralize


    【解决方案1】:

    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 行为。

    【讨论】:

      【解决方案2】:

      英文规则在 ActiveSupport 中(特别是在 lib/active_support/inflections.rb 中)。

      【讨论】:

        猜你喜欢
        • 1970-01-01
        • 2016-01-14
        • 2012-07-11
        • 1970-01-01
        • 2012-10-13
        • 1970-01-01
        • 1970-01-01
        • 1970-01-01
        • 1970-01-01
        相关资源
        最近更新 更多