add_default_locale_path(File.join(Irc::Bot::Config.datadir, "../locale/%{locale}/LC_MESSAGES/%{name}.mo"))
+ GetText.cached = false
bindtextdomain 'rbot'
module GetText
alias :orig_bound_targets :bound_targets
end
def bound_targets(*a) # :nodoc:
- orig_bound_targets(*a) rescue orig_bound_targets(Object)
+ bt = orig_bound_targets(*a) rescue []
+ bt.empty? ? orig_bound_targets(Object) : bt
end
require 'stringio'
log "gettext loaded"
rescue LoadError, GetTextVersionError
- warn "failed to load ruby-gettext package: #{$!}; translations are disabled"
+ warning "failed to load ruby-gettext package: #{$!}; translations are disabled"
+
+ # undefine GetText, in case it got defined because the error was caused by a
+ # wrong version
+ if defined?(GetText)
+ Object.module_eval { remove_const("GetText") }
+ end
# dummy functions that return msg_id without translation
def _(s)
args[0]
end
+ def bindtextdomain_to(*args)
+ end
+
# the following extension to String#% is from ruby-gettext's string.rb file.
# it needs to be included in the fallback since the source already use this form