Module: JactiveSupport::Localize

Extended by:
ActiveSupport::Concern
Included in:
javajava::util::Date
Defined in:
lib/jactive_support/localize.rb

Overview

Makes a class support localize and class parse method It expects class 3 methods be implemented on the class.

i18n_scope - The scope to use for translations
pattern_formatter(format, locale) - returns a formatter based on a pattern
default_formatter(locale) - returns a default formatter when the format is blank

Defined Under Namespace

Modules: ClassMethods

Instance Method Summary collapse

Instance Method Details

#localize(options = {}) ⇒ Object



56
57
58
59
60
61
62
63
64
65
66
67
68
# File 'lib/jactive_support/localize.rb', line 56

def localize(options = {})
  unless options[:format]
    defaults = [
      :"#{self.class.i18n_scope}.formats.default", 
      options.delete(:default)]
    defaults.compact!
    defaults.flatten!
    options[:default] = defaults unless defaults.empty?
    options[:format] = :output
  end
  formatter = self.class.i18n_formatter(options)
  formatter.format(self)
end