Module: I18n

Defined in:
lib/internashunalize-js/i18n.rb

Class Method Summary collapse

Class Method Details

.javascript_translationsObject

TODO: implement localization?



27
28
29
# File 'lib/internashunalize-js/i18n.rb', line 27

def javascript_translations
  @javascript_translations
end

.tObject



6
# File 'lib/internashunalize-js/i18n.rb', line 6

alias :t :translate

.translate(*args) ⇒ Object



8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
# File 'lib/internashunalize-js/i18n.rb', line 8

def translate(*args)
  args_core = args.dup
  options = args.last.is_a?(Hash) ? args.pop : {}
  javascript = options.delete(:javascript)
  key = args.shift        

  translation = self.translate_core(*args_core)

  if javascript
    @javascript_translations ||= {}
    translation.gsub!(/%\{(\w*)\}/, "{{\\1}}") if translation.is_a? String # TODO: translate can return a hash, eg. when interpolating %{count}
    @javascript_translations[key] = translation
  end

  return translation
end

.translate_coreObject



5
# File 'lib/internashunalize-js/i18n.rb', line 5

alias :translate_core :translate