From 37da5ba18776a7a1e4549e7bc2af48d87d67234a Mon Sep 17 00:00:00 2001 From: Jean-Philippe Lang Date: Sun, 15 Mar 2009 10:10:39 +0000 Subject: [PATCH] Backported r2573, r2591 and r2592 from trunk. git-svn-id: svn+ssh://rubyforge.org/var/svn/redmine/branches/0.8-stable@2593 e93f8b46-1217-0410-a6f0-8f06a7374b81 --- doc/CHANGELOG | 7 +++++++ lib/tasks/load_default_data.rake | 30 ++++++++++++++++++------------ 2 files changed, 25 insertions(+), 12 deletions(-) diff --git a/doc/CHANGELOG b/doc/CHANGELOG index 87da37818..cabd5f9bf 100644 --- a/doc/CHANGELOG +++ b/doc/CHANGELOG @@ -5,6 +5,13 @@ Copyright (C) 2006-2009 Jean-Philippe Lang http://www.redmine.org/ +== 2009-xx-xx v0.8.3 + +* Ability to set language for redmine:load_default_data task using REDMINE_LANG environment variable +* Rescue Redmine::DefaultData::DataAlreadyLoaded in redmine:load_default_data task +* Flush buffer when asking for language in redmine:load_default_data task + + == 2009-03-07 v0.8.2 * Send an email to the user when an administrator activates a registered user diff --git a/lib/tasks/load_default_data.rake b/lib/tasks/load_default_data.rake index 6ddd1fb97..13c7bca64 100644 --- a/lib/tasks/load_default_data.rake +++ b/lib/tasks/load_default_data.rake @@ -1,26 +1,32 @@ -desc 'Load Redmine default configuration data' +desc 'Load Redmine default configuration data. Language is chosen interactively or by setting REDMINE_LANG environment variable.' namespace :redmine do task :load_default_data => :environment do include GLoc set_language_if_valid('en') - puts - while true - print "Select language: " - print GLoc.valid_languages.sort {|x,y| x.to_s <=> y.to_s }.join(", ") - print " [#{GLoc.current_language}] " - lang = STDIN.gets.chomp! - break if lang.empty? - break if set_language_if_valid(lang) - puts "Unknown language!" + envlang = ENV['REDMINE_LANG'] + if !envlang || !set_language_if_valid(envlang) + puts + while true + print "Select language: " + print GLoc.valid_languages.sort {|x,y| x.to_s <=> y.to_s }.join(", ") + print " [#{GLoc.current_language}] " + STDOUT.flush + lang = STDIN.gets.chomp! + break if lang.empty? + break if set_language_if_valid(lang) + puts "Unknown language!" + end + STDOUT.flush + puts "====================================" end - puts "====================================" - begin Redmine::DefaultData::Loader.load(current_language) puts "Default configuration data loaded." + rescue Redmine::DefaultData::DataAlreadyLoaded => error + puts error rescue => error puts "Error: " + error puts "Default configuration data was not loaded." -- 2.39.5