]> git.netwichtig.de Git - user/henk/code/ruby/rbot.git/commitdiff
Only use locale functions when GetText was loaded
authorGiuseppe Bilotta <giuseppe.bilotta@gmail.com>
Sun, 26 Aug 2007 16:38:34 +0000 (16:38 +0000)
committerGiuseppe Bilotta <giuseppe.bilotta@gmail.com>
Sun, 26 Aug 2007 16:38:34 +0000 (16:38 +0000)
lib/rbot/language.rb

index c9130ee0acc54c7b6c7904b167acc2ca3ea05814..5fbbfefdec97d65f1075443bda72c544398a3df0 100644 (file)
@@ -30,6 +30,7 @@ module Language
   # Return the shortest language for the current
   # GetText locale
   def Language.from_locale
+    return 'english' unless defined?(GetText)
     lang = locale.language
     if locale.country
       str = lang + "_#{locale.country}"
@@ -67,7 +68,7 @@ module Language
     def set_language(language)
       lang_str = language.to_s.downcase.gsub(/\s+/,'_')
       lang_sym = lang_str.intern
-      if Lang2Locale.key?(lang_sym)
+      if defined?(GetText) and Lang2Locale.key?(lang_sym)
         setlocale(Lang2Locale[lang_sym])
         debug "locale set to #{locale}"
         rbot_gettext_debug