Class: Globalize::Backend::Static

Inherits:
Pluralizing
  • Object
show all
Defined in:
lib/globalize/backend/static.rb

Instance Method Summary collapse

Methods inherited from Pluralizing

#add_pluralizer, #pluralize, #pluralizer

Constructor Details

#initialize(*args) ⇒ Static

Returns a new instance of Static.



8
9
10
# File 'lib/globalize/backend/static.rb', line 8

def initialize(*args)
  add(*args) unless args.empty?
end

Instance Method Details

#orig_interpolateObject



28
# File 'lib/globalize/backend/static.rb', line 28

alias :orig_interpolate :interpolate

#translate(locale, key, options = {}) ⇒ Object



12
13
14
15
16
17
18
19
20
21
22
23
24
# File 'lib/globalize/backend/static.rb', line 12

def translate(locale, key, options = {})
  result, default, fallback = nil, options.delete(:default), nil
  I18n.fallbacks[locale].each do |fallback|
    begin
      result = super(fallback, key, options) and break
    rescue I18n::MissingTranslationData
    end
  end
  result ||= default locale, default, options

  attrs = {:requested_locale => locale, :locale => fallback, :key => key, :options => options}
  translation(result, attrs) || raise(I18n::MissingTranslationData.new(locale, key, options))
end