From 71cf0b54a34bd746276c0d0ec13d4baafa0cccaa Mon Sep 17 00:00:00 2001 From: Giuseppe Bilotta Date: Sun, 26 Aug 2007 00:26:46 +0000 Subject: Sanitize language string by downcasing, and use the sanitized string both for gettext locale and rbot language files. This allows language names such as 'traditional_chinese' to be input as 'Traditional Chinese' --- lib/rbot/language.rb | 18 +++++++++--------- 1 file changed, 9 insertions(+), 9 deletions(-) (limited to 'lib/rbot/language.rb') diff --git a/lib/rbot/language.rb b/lib/rbot/language.rb index 7c472303..d40fdecc 100644 --- a/lib/rbot/language.rb +++ b/lib/rbot/language.rb @@ -62,23 +62,23 @@ module Language @bot = bot set_language language end - attr_reader :language, :locale + attr_reader :language def set_language(language) - l = language.to_s.gsub(/\s+/,'_').intern - if Lang2Locale.key?(l) - @locale = Lang2Locale[l] - setlocale(@locale) + lang_str = language.to_s.downcase.gsub(/\s+/,'_') + lang_sym = lang_str.intern + if Lang2Locale.key?(lang_sym) + setlocale(Lang2Locale[lang_sym]) debug "locale set to #{locale}" else - warn "Unable to set locale, unknown language #{l}" + warn "Unable to set locale, unknown language #{language} (#{lang_str})" end - file = Config::datadir + "/languages/#{language}.lang" + file = Config::datadir + "/languages/#{lang_str}.lang" unless(FileTest.exist?(file)) - raise "no such language: #{language} (no such file #{file})" + raise "no such language: #{lang_str} (no such file #{file})" end - @language = language + @language = lang_str @file = file scan return if @bot.plugins.nil? -- cgit v1.2.3