Module: I18n::Backend::Tml::Implementation

Includes:
Base, Flatten
Included in:
I18n::Backend::Tml
Defined in:
lib/i18n/backend/tml.rb

Instance Method Summary collapse

Instance Method Details

#applicationObject



43
44
45
# File 'lib/i18n/backend/tml.rb', line 43

def application
  ::Tml.session.application
end

#available_localesObject



47
48
49
# File 'lib/i18n/backend/tml.rb', line 47

def available_locales
  application.locales
end

#lookup(locale, key, scope = [], options = {}) ⇒ Object



55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
# File 'lib/i18n/backend/tml.rb', line 55

def lookup(locale, key, scope = [], options = {})
  #pp ''
  #pp [locale, key, scope, options]

  default_key = super(application.default_locale, key, scope, options)

  #pp default_key

  default_key ||= key
  if default_key.is_a?(String)
    translated_key = default_key.gsub('%{', '{')
    translated_key = application.language(locale.to_s).translate(translated_key, options, options)
  elsif default_key.is_a?(Hash)
    translated_key = {}
    default_key.each do |key, value|
      value = value.gsub('%{', '{')
      translated_key[key] =  application.language(locale.to_s).translate(value, options, options)
    end
  end

  #pp translated_key
  translated_key
end

#translate(locale, key, options = {}) ⇒ Object



51
52
53
# File 'lib/i18n/backend/tml.rb', line 51

def translate(locale, key, options = {})
  super(locale, key, options).html_safe
end