class Alephant::Renderer::I18n::LocaleComponentYaml
Public Class Methods
new(locale, namespace, translations_path = nil)
click to toggle source
# 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
Public Instance Methods
t(key, params = {})
click to toggle source
# 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
Private Instance Methods
i18n_lib()
click to toggle source
# File lib/alephant/renderer/i18n/locale_component_yaml.rb, line 43 def i18n_lib i18n_lib = ::I18n i18n_lib.enforce_available_locales = false i18n_lib end
load_translations()
click to toggle source
# File lib/alephant/renderer/i18n/locale_component_yaml.rb, line 24 def load_translations return unless i18n_lib.available_locales.empty? i18n_lib.backend.load_translations(translations_files) end
translation_filename()
click to toggle source
# File lib/alephant/renderer/i18n/locale_component_yaml.rb, line 35 def translation_filename File.join(translations_path, '*.yml') end
translations_files()
click to toggle source
# File lib/alephant/renderer/i18n/locale_component_yaml.rb, line 29 def translations_files Dir[translation_filename] .flatten .uniq end
translations_path()
click to toggle source
# File lib/alephant/renderer/i18n/locale_component_yaml.rb, line 39 def translations_path @translations_path || './components/lib/locale' end