Sha256: 86ea56de2201f4e3510479d01255728083516f4fd6c986e39ca07452f180546d
Contents?: true
Size: 1.25 KB
Versions: 18
Compression:
Stored size: 1.25 KB
Contents
require 'fast_gettext' require 'locale' include FastGettext::Translation FastGettext.add_text_domain('spider', :path => File.join($SPIDER_PATH, 'data', 'locale')) FastGettext.text_domain = 'spider' FastGettext.default_text_domain = 'spider' l = Locale.current[0].to_s l = $1 if l =~ /(\w\w)_+/ FastGettext.locale = l module Spider module GetText # Executes a block of code in the given text_domain 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 # Sets the current text_domain; return the previous domain def self.set_domain(domain) prev_text_domain = FastGettext.text_domain FastGettext.text_domain = domain if FastGettext.translation_repositories.key?(domain) prev_text_domain end # Sets the current text_domain; assumes the domain was already set before, so skips any # check for domain validity def self.restore_domain(domain) FastGettext.text_domain = domain end end end
Version data entries
18 entries across 18 versions & 1 rubygems