Method: R18n::Translation#method_missing

Defined in:
lib/r18n-core/translation.rb

#method_missingObject

Return translation with special name.

Translation can contain variable part. Just set is as ‘%1`, `%2`, etc in translations file and set values in next params.



166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
# File 'lib/r18n-core/translation.rb', line 166

def [](name, *params)
  unless [String, Integer, TrueClass, FalseClass]
      .any? { |klass| name.is_a?(klass) }
    name = name.to_s
  end
  value = @data[name]
  case value
  when TranslatedString
    path = @path.empty? ? name : "#{@path}.#{name}"
    @filters.process_string(:active, value, path, params)
  when Typed
    @filters.process_typed(:active, value, params)
  when nil
    translated = @path.empty? ? '' : "#{@path}."
    Untranslated.new(translated, name, @locale, @filters)
  else
    value
  end
end