Module: I18n
- Defined in:
- lib/internashunalize-js/i18n.rb
Class Method Summary collapse
-
.javascript_translations ⇒ Object
TODO: implement localization?.
- .t ⇒ Object
- .translate(*args) ⇒ Object
- .translate_core ⇒ Object
Class Method Details
.javascript_translations ⇒ Object
TODO: implement localization?
27 28 29 |
# File 'lib/internashunalize-js/i18n.rb', line 27 def javascript_translations @javascript_translations end |
.t ⇒ Object
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 = args.last.is_a?(Hash) ? args.pop : {} javascript = .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_core ⇒ Object
5 |
# File 'lib/internashunalize-js/i18n.rb', line 5 alias :translate_core :translate |