summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorGiuseppe Bilotta <giuseppe.bilotta@gmail.com>2007-08-26 00:26:46 +0000
committerGiuseppe Bilotta <giuseppe.bilotta@gmail.com>2007-08-26 00:26:46 +0000
commit71cf0b54a34bd746276c0d0ec13d4baafa0cccaa (patch)
tree4712d4e3d2a91bbea5f1db1c74ab1f10748f6504
parente6d03d684ea66a6157c159cf1c233bef27e49407 (diff)
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'
-rw-r--r--lib/rbot/language.rb18
1 files changed, 9 insertions, 9 deletions
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?