Class: Lolita::I18n::Request::Translation
- Inherits:
-
Object
- Object
- Lolita::I18n::Request::Translation
- Defined in:
- lib/lolita-i18n/request.rb
Instance Method Summary collapse
- #for_store ⇒ Object
-
#initialize(key, translation) ⇒ Translation
constructor
A new instance of Translation.
- #key ⇒ Object
- #locale ⇒ Object
- #original ⇒ Object
- #value ⇒ Object
Constructor Details
#initialize(key, translation) ⇒ Translation
Returns a new instance of Translation.
69 70 71 72 |
# File 'lib/lolita-i18n/request.rb', line 69 def initialize(key,translation) @key,@translation = key, translation @key_parts = @key.to_s.split(".") end |
Instance Method Details
#for_store ⇒ Object
82 83 84 |
# File 'lib/lolita-i18n/request.rb', line 82 def for_store [locale, { key => value }, :escape => false] end |
#key ⇒ Object
86 87 88 |
# File 'lib/lolita-i18n/request.rb', line 86 def key @key_parts[1..-1].join(".") end |
#locale ⇒ Object
78 79 80 |
# File 'lib/lolita-i18n/request.rb', line 78 def locale (locale_from_key || ::I18n.default_locale).to_sym end |
#original ⇒ Object
90 91 92 |
# File 'lib/lolita-i18n/request.rb', line 90 def original @original ||= ::I18n.t(self.key, :locale => ::I18n.default_locale) end |
#value ⇒ Object
74 75 76 |
# File 'lib/lolita-i18n/request.rb', line 74 def value Yajl::Parser.parse(@translation.to_json) end |