Module: Locomotive::Liquid::Filters::Translate
- Defined in:
- lib/locomotive/liquid/filters/translate.rb
Instance Method Summary collapse
-
#translate(input, locale = nil, scope = nil) ⇒ String
Return the translation described by a key.
Instance Method Details
#translate(input, locale = nil, scope = nil) ⇒ String
Return the translation described by a key.
14 15 16 17 18 19 20 21 22 23 24 25 26 27 |
# File 'lib/locomotive/liquid/filters/translate.rb', line 14 def translate(input, locale = nil, scope = nil) locale ||= I18n.locale.to_s if scope.blank? translation = Locomotive::Translation.where(key: input).first if translation.values[locale].present? translation.values[locale] else translation.values[I18n.default_locale.to_s] end else I18n.t(input, scope: scope.split('.'), locale: locale) end end |