X-Git-Url: https://git.netwichtig.de/gitweb/?a=blobdiff_plain;f=lib%2Frbot%2Flanguage.rb;h=ae750ad93868b6dc498c2a9b1d2fe1e7877f36ce;hb=53c82a94714e439c63a65fccdaf2512383cffb7a;hp=7cf1ceb994982b0d88491192751dfdf4fc03c6cd;hpb=05dfd4e1a0f4e17c23ae7bfeed776c943c9394fe;p=user%2Fhenk%2Fcode%2Fruby%2Frbot.git diff --git a/lib/rbot/language.rb b/lib/rbot/language.rb index 7cf1ceb9..ae750ad9 100644 --- a/lib/rbot/language.rb +++ b/lib/rbot/language.rb @@ -8,6 +8,7 @@ # .lang file etc. module Irc +class Bot class Language # This constant hash holds the mapping @@ -23,9 +24,12 @@ module Irc :dutch => 'nl', :japanese => 'ja', :russian => 'ru', + :finnish => 'fi', :traditional_chinese => 'zh_TW', :simplified_chinese => 'zh_CN' } + # On WIN32 it appears necessary to have ".UTF-8" explicitly for gettext to use UTF-8 + Lang2Locale.each_value {|v| v.replace(v + '.UTF-8')} # Return the shortest language for the current # GetText locale @@ -54,16 +58,16 @@ module Irc return 'english' end - BotConfig.register BotConfigEnumValue.new('core.language', - :default => Irc::Language.from_locale, :wizard => true, + Config.register Config::EnumValue.new('core.language', + :default => Irc::Bot::Language.from_locale, :wizard => true, :values => Proc.new{|bot| Dir.new(Config::datadir + "/languages").collect {|f| f =~ /\.lang$/ ? f.gsub(/\.lang$/, "") : nil }.compact - }, + }, :on_change => Proc.new {|bot, v| bot.lang.set_language v}, :desc => "Which language file the bot should use") - + def initialize(bot, language) @bot = bot set_language language @@ -141,3 +145,4 @@ module Irc end end +end