Skip to content
This repository has been archived by the owner on Jun 30, 2022. It is now read-only.

Commit

Permalink
Add config.robot.default_locale.
Browse files Browse the repository at this point in the history
  • Loading branch information
jimmycuadra committed Sep 25, 2020
1 parent 8f669f0 commit 8ef38e0
Show file tree
Hide file tree
Showing 4 changed files with 13 additions and 0 deletions.
1 change: 1 addition & 0 deletions lib/lita/common.rb
Original file line number Diff line number Diff line change
Expand Up @@ -48,3 +48,4 @@ def template_root
Lita.load_locales(Dir[File.join(Lita.template_root, "locales", "*.yml")])
I18n.enforce_available_locales = false
Lita.locale = ENV["LANG"] unless ENV["LANG"].nil?
Lita.default_locale = ENV["LANG"] unless ENV["LANG"].nil?
1 change: 1 addition & 0 deletions lib/lita/config.rb
Original file line number Diff line number Diff line change
Expand Up @@ -43,6 +43,7 @@ def load_robot_configs(config)
config.robot.name = "Lita"
config.robot.adapter = :shell
config.robot.locale = I18n.locale
config.robot.default_locale = I18n.default_locale
config.robot.log_level = :info
config.robot.admins = nil
config.robot.log_formatter = nil
Expand Down
1 change: 1 addition & 0 deletions lib/lita/default_configuration.rb
Original file line number Diff line number Diff line change
Expand Up @@ -131,6 +131,7 @@ def robot_config
config :alias, type: String
config :adapter, types: [String, Symbol], default: :shell
config :locale, types: [String, Symbol], default: I18n.locale
config :default_locale, types: [String, Symbol], default: I18n.default_locale
config :log_level, types: [String, Symbol], default: :info do
validate do |value|
unless LOG_LEVELS.include?(value.to_s.downcase.strip)
Expand Down
10 changes: 10 additions & 0 deletions spec/lita/default_configuration_spec.rb
Original file line number Diff line number Diff line change
Expand Up @@ -233,6 +233,16 @@ def self.default_config(old_config)
expect(config.robot.locale).to eq(:es)
end

it "has a default default locale" do
expect(config.robot.default_locale).to eq(I18n.default_locale)
end

it "can set a default locale" do
config.robot.default_locale = :es

expect(config.robot.default_locale).to eq(:es)
end

it "has a default log level" do
expect(config.robot.log_level).to eq(:info)
end
Expand Down

0 comments on commit 8ef38e0

Please sign in to comment.