Class: Alephant::Renderer::I18n::LocaleComponentYaml

Inherits:
Object
  • Object
show all
Defined in:
lib/alephant/renderer/i18n/locale_component_yaml.rb

Direct Known Subclasses

Json

Instance Method Summary collapse

Constructor Details

#initialize(locale, namespace, translations_path = nil) ⇒ LocaleComponentYaml

Returns a new instance of LocaleComponentYaml.



7
8
9
10
11
12
13
# File 'lib/alephant/renderer/i18n/locale_component_yaml.rb', line 7

def initialize(locale, namespace, translations_path = nil)
  @translations_path = translations_path
  @locale = locale
  @namespace = namespace

  load_translations
end

Instance Method Details

#t(key, params = {}) ⇒ Object



15
16
17
18
19
20
# File 'lib/alephant/renderer/i18n/locale_component_yaml.rb', line 15

def t(key, params = {})
  i18n_lib.locale = @locale
  params[:default] = key unless params[:default]
  params[:scope] = @namespace unless params[:scope]
  i18n_lib.translate(key, params)
end