lib/spiderfw/i18n/gettext.rb in spiderfw-0.6.8 vs lib/spiderfw/i18n/gettext.rb in spiderfw-0.6.9

- old
+ new

@@ -1,8 +1,24 @@ -# def _(s) -# s -# end +require 'fast_gettext' +require 'locale' +include FastGettext::Translation +FastGettext.add_text_domain('spider', :path => File.join($SPIDER_PATH, 'data', 'locale')) +FastGettext.text_domain = 'spider' +l = Locale.current[0].to_s +l = $1 if l =~ /(\w\w)_+/ +FastGettext.locale = l -require 'gettext' -include GetText -bindtextdomain('spider') -GetText.set_output_charset('utf-8') +module Spider + + module GetText + + def self.in_domain(domain, &block) + prev_text_domain = FastGettext.text_domain + FastGettext.text_domain = domain if FastGettext.translation_repositories.key?(domain) + v = yield + FastGettext.text_domain = prev_text_domain + v + end + + end + +end \ No newline at end of file