    # File lib/rbot/language.rb, line 35
        def Language.from_locale
          return 'english' unless defined?(GetText)
          lang = locale.language
          if locale.country
            str = lang + "_#{locale.country}"
            if Lang2Locale.value?(str)
              # Get the shortest key in Lang2Locale which maps to the given lang_country
              lang_str = Lang2Locale.select { |k, v| v == str }.transpose.first.map { |v| v.to_s }.sort { |a, b| a.length <=> b.length }.first
              if File.exist?(File.join(Config::datadir, "languages/#{lang_str}.lang"))
                return lang_str
              end
            end
          end
          # lang_country didn't work, let's try lan
          if Lang2Locale.value?(lang)
            # Get the shortest key in Lang2Locale which maps to the given lang
            lang_str = Lang2Locale.select { |k, v| v == lang }.transpose.first.map { |v| v.to_s }.sort { |a, b| a.length <=> b.length }.first
            if File.exist?(File.join(Config::datadir, "/languages/#{lang_str}.lang"))
              return lang_str
            end
          end
          # all else fail, return 'english'
          return 'english'
        end