X-Git-Url: https://git.netwichtig.de/gitweb/?a=blobdiff_plain;f=lib%2Frbot%2Fload-gettext.rb;h=5738f19726fd069293cb8a970d4477f4f1b0f607;hb=fdf1bc954352f19818f5f9f1c86643a2f8ef40c6;hp=e6c605d92c60f9aa71a21dc6e247e38859d3b446;hpb=02c79244569748ebc41a8d6548314a802d8375d0;p=user%2Fhenk%2Fcode%2Fruby%2Frbot.git diff --git a/lib/rbot/load-gettext.rb b/lib/rbot/load-gettext.rb index e6c605d9..5738f197 100644 --- a/lib/rbot/load-gettext.rb +++ b/lib/rbot/load-gettext.rb @@ -13,15 +13,17 @@ begin require 'gettext/version' gettext_version = GetText::VERSION.split('.').map {|n| n.to_i} - include Comparable # required for Array#between? - unless gettext_version.between? [1, 8, 0], [1, 10, 0] - raise GetTextVersionError, "Unsupported ruby-gettext version installed: #{gettext_version.join '.'}; supported versions are 1.8.0-1.10.0" + include Comparable # for Array#>= + 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 require 'gettext' include GetText + add_default_locale_path(File.join(Irc::Bot::Config.datadir, "../locale/%{locale}/LC_MESSAGES/%{name}.mo")) + bindtextdomain 'rbot' module GetText @@ -57,6 +59,12 @@ begin rescue LoadError, GetTextVersionError warn "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) s