]> git.netwichtig.de Git - user/henk/code/ruby/rbot.git/commitdiff
* (gettext) make us somewhat less dependent on gettext internals
authorDmitry Kim <dmitry point kim at gmail point com>
Thu, 12 Jul 2007 16:23:58 +0000 (16:23 +0000)
committerDmitry Kim <dmitry point kim at gmail point com>
Thu, 12 Jul 2007 16:23:58 +0000 (16:23 +0000)
lib/rbot/load-gettext.rb

index 4c18892d9a9e131e15a7708b757dec27ae7c38ef..165a81c581bbba5d4fe9fa26f7808deb3fc1b32a 100644 (file)
@@ -12,20 +12,11 @@ begin
     # patch for ruby-gettext 1.9.0 to cope with anonymous modules used by rbot
     # FIXME remove the patch when ruby-gettext is fixed, or rbot switches to named modules
   # fix for module names that are not constant names
-    def bound_targets(klass)  # :nodoc:
-      ret = []
-      ary = klass.name.split(/::/)
-      while(v = ary.shift)
-        begin
-          ret.unshift(((ret.size == 0) ?
-            Object.const_get(v) : ret[0].const_get(v)))
-        rescue NameError
-          # when an anonymous module is encountered, only the previous modules
-          # are returned
-          break
-        end
-      end
-      ((ret + klass.ancestors + [GetText]) & @@__textdomainmanagers.keys).uniq
+    if !instance_methods.include?('orig_bound_targets')
+      alias :orig_bound_targets :bound_targets
+    end
+    def bound_targets(*a)  # :nodoc:
+      orig_bound_targets(*a) rescue orig_bound_targets(Object)
     end
   end