X-Git-Url: https://git.netwichtig.de/gitweb/?a=blobdiff_plain;f=lib%2Frbot%2Fload-gettext.rb;h=252e1e344f1830d8aa5e41f461778ed6215ce61d;hb=3342d4b9a510655d320590f7333f616355d0201d;hp=5e2ec1860450306b4e8311ec37038449f271b4d9;hpb=b3aa806886587e5736f9cc338cc1c464e8d113ed;p=user%2Fhenk%2Fcode%2Fruby%2Frbot.git diff --git a/lib/rbot/load-gettext.rb b/lib/rbot/load-gettext.rb index 5e2ec186..252e1e34 100644 --- a/lib/rbot/load-gettext.rb +++ b/lib/rbot/load-gettext.rb @@ -18,7 +18,9 @@ end require 'gettext/version' gettext_version = GetText::VERSION.split('.').map {|n| n.to_i} - include Comparable # for Array#>= + class ::Array + include Comparable # for Array#>= + end unless gettext_version >= [1, 8, 0] raise GetTextVersionError, "Unsupported ruby-gettext version installed: #{gettext_version.join '.'}; supported versions are 1.8.0 and above" end @@ -27,7 +29,11 @@ end include GetText - rbot_locale_path = File.join(Irc::Bot::Config.datadir, "../locale/%{locale}/LC_MESSAGES/%{name}.mo") + rbot_locale_path = File.join(Irc::Bot::Config.datadir, + gettext_version < [2, 2, 0] ? + "../locale/%{locale}/LC_MESSAGES/%{name}.mo" : + "../locale/%{lang}/LC_MESSAGES/%{name}.mo") + if gettext_version < [2, 0, 0] add_default_locale_path(rbot_locale_path) else @@ -41,7 +47,29 @@ end else warning 'This version of ruby-gettext does not support non-cached mode; mo files are not reloaded when setting language' end - bindtextdomain 'rbot' + + begin + bindtextdomain 'rbot' + rescue NoMethodError => e + error e + warning 'Trying to work around RubyGems/GetText incompatibility' + module ::Gem + def self.all_load_paths + result = [] + + Gem.path.each do |gemdir| + each_load_path all_partials(gemdir) do |load_path| + result << load_path + end + end + + result + end + end + retry + end + + module GetText # patch for ruby-gettext 1.x to cope with anonymous modules used by rbot.