Module: Komponent::Translation
- Defined in:
- lib/komponent/translation.rb
Instance Method Summary collapse
- #translate(key, options = {}) ⇒ Object (also: #t)
Instance Method Details
#translate(key, options = {}) ⇒ Object Also known as: t
5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 |
# File 'lib/komponent/translation.rb', line 5 def translate(key, = {}) virtual_path = @virtual_path is_component = key.to_s.first == "." and virtual_path =~ /^components/ if is_component path = virtual_path.match(/^components\/.+\/_(.+)/)[1] path += "_component" defaults = [:"#{path}#{key}"] defaults << [:default] if [:default] [:default] = defaults.flatten key = "#{path}.#{key}" end super(key, ) end |