Module: Gaigo::I18nExtend::TryTranslate::ClassMethods

Defined in:
lib/gaigo/i18n_extend/try_translate.rb

Instance Method Summary collapse

Instance Method Details

#try_translate(*args, &block) ⇒ Object



8
9
10
11
12
13
14
15
16
17
18
19
# File 'lib/gaigo/i18n_extend/try_translate.rb', line 8

def try_translate(*args, &block)
 options = args.last.is_a?(Hash) ? args.pop : {}
 locale = options.delete(:locale) || config.locale
 begin
   translate!(*args, options.merge(:locale => locale))
 rescue Exception
   if block_given?
     yield args, options
   end
   translate(*args, options)
 end
end