Method: I18n::Inflector::InflectionOptions#excluded_defaults

Defined in:
lib/i18n-inflector/options.rb

#excluded_defaultsBoolean

Note:

Local option :inflector_excluded_defaults passed to the Backend::Inflector#translate overrides this setting.

When this switch is set to true then inflector falls back to the default token for a kind if the given inflection option is correct but doesn’t exist in a pattern.

There might happen that the inflection option given to #translate method will contain some proper token, but that token will not be present in a processed pattern. Normally an empty string will be generated from such a pattern or a free text (if a local fallback is present in a pattern). You can change that behavior and tell interpolating routine to use the default token for a processed kind in such cases.

This switch is by default set to false.

Examples:

YAML:

en:
  i18n:
    inflections:
      gender:
        o:      "other"
        m:      "male"
        n:      "neuter"
        default: n

  welcome:  'Dear @{n:You|m:Sir}'

Usage of :inflector_excluded_defaults option

I18n.t('welcome', :gender => :o)
# => "Dear "

I18n.t('welcome', :gender => :o, :inflector_excluded_defaults => true)
# => "Dear You"

Parameters:

  • state (Boolean)

    true enables, false disables this switch

Returns:

  • (Boolean)

    state of the switch

[View source]

275
276
277
# File 'lib/i18n-inflector/options.rb', line 275

def excluded_defaults
  @excluded_defaults
end