Module: Dapp::Helper::I18n

Included in:
Application
Defined in:
lib/dapp/helper/i18n.rb

Overview

I18n

Class Method Summary collapse

Instance Method Summary collapse

Class Method Details

.initialize ⇒ Object



5
6
7
8
9
# File 'lib/dapp/helper/i18n.rb', line 5

def self.initialize
  ::I18n.load_path << Dir[File.join(Dapp.root, 'config', '**', '*')].select { |path| File.file?(path) }
  ::I18n.reload!
  ::I18n.locale = :en
end

Instance Method Details

#t(context: nil, **desc) ⇒ Object



11
12
13
14
15
16
17
# File 'lib/dapp/helper/i18n.rb', line 11

def t(context: nil, **desc)
  code = desc[:code]
  data = desc[:data] || {}
  ::I18n.t [:common, context, code].join('.'), [:common, code].join('.'), **data, raise: true
rescue ::I18n::MissingTranslationData => _e
  raise NetStatus::Exception, code: :missing_translation, data: { code: code }
end