Class: Translatomatic::I18n

Inherits:
Object
  • Object
show all
Defined in:
lib/translatomatic/i18n.rb

Overview

I18n initialisation and translation fallback handling

Class Method Summary collapse

Class Method Details

.l(object, options = {}) ⇒ Object

Localises dates and numbers to local formatting

Parameters:

  • object (Object)

    Object to localise



19
20
21
# File 'lib/translatomatic/i18n.rb', line 19

def l(object, options = {})
  ::I18n.l(object, options)
end

.t(key, options = {}) ⇒ Object

Get string translation

Parameters:

  • key

    translation key



10
11
12
13
14
15
# File 'lib/translatomatic/i18n.rb', line 10

def t(key, options = {})
  tkey = "translatomatic.#{key}"
  raise "missing translation: #{tkey}" unless ::I18n.exists?(tkey)

  ::I18n.t(tkey, options.merge(locale: t_locale(options)))
end