diff options
author | Tom Gilbert <tom@linuxbrit.co.uk> | 2005-07-30 21:35:57 +0000 |
---|---|---|
committer | Tom Gilbert <tom@linuxbrit.co.uk> | 2005-07-30 21:35:57 +0000 |
commit | d30940cb5ff75cf7eab81f6a588b3b5297a762ad (patch) | |
tree | b3f0a62c9255b2ecb8a4f2c927bd116e220b0594 /lib/rbot/language.rb | |
parent | 992ef2edbf3eed7cb1d7c4c22f72cd203aff2aa5 (diff) |
Sat Jul 30 22:33:36 BST 2005 Tom Gilbert <tom@linuxbrit.co.uk>
* Config items are now objects, various types are available.
* The config wizard will now use registered config items if :wizard is set
to true for those items. It will ask questions in the order they were
registered.
* The config module now works for doing runtime configuration.
* misc refactoring
Diffstat (limited to 'lib/rbot/language.rb')
-rw-r--r-- | lib/rbot/language.rb | 19 |
1 files changed, 11 insertions, 8 deletions
diff --git a/lib/rbot/language.rb b/lib/rbot/language.rb index ee6746d6..d48607b8 100644 --- a/lib/rbot/language.rb +++ b/lib/rbot/language.rb @@ -1,21 +1,24 @@ module Irc class Language - BotConfig.register('core.language', - :default => "english", :type => :enum, + BotConfig.register BotConfigEnumValue.new('core.language', + :default => "english", :wizard => true, :values => 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(language, file="") - @language = language - if file.empty? - file = Config::DATADIR + "/languages/#{@language}.lang" - end + def initialize(language) + set_language language + end + + def set_language(language) + file = Config::DATADIR + "/languages/#{language}.lang" unless(FileTest.exist?(file)) - raise "no such language: #{@language} (no such file #{file})" + raise "no such language: #{language} (no such file #{file})" end + @language = language @file = file scan end |