Feature #2847

ability to give redmine::load_default_data a default value using environment variable

Added by Jérémy Lal almost 9 years ago. Updated about 6 years ago.

Status:ClosedStart date:2009-02-26
Priority:NormalDue date:
Assignee:-% Done:

0%

Category:-
Target version:0.8.3
Resolution:Fixed

Description

The idea would be :
rake redmine:load_default_data RAILS_ENV="production" REDMINE_LANG="fr"

if $REDMINE_LANG is defined, no question would be asked.

I ask this for a reason : debian packaging is not happy with direct user input.

Here's some suggestion, changing behavior only when REDMINE_LANG is defined, in
lib/tasks/load_default_data.rake :

desc 'Load Redmine default configuration data'

namespace :redmine do

  task :load_default_data => :environment do

    include Redmine::I18n

    set_language_if_valid('en')
    envlang = ENV['REDMINE_LANG']
    if !envlang || !set_language_if_valid(envlang)

      puts

      while true

        print "Select language: " 

        print valid_languages.collect(&:to_s).sort.join(", ")

        print " [#{current_language}] " 

        lang = STDIN.gets.chomp!

        break if lang.empty?

        break if set_language_if_valid(lang)

        puts "Unknown language!" 

      end

      puts "====================================" 

    else
      lang = envlang
    end

    begin

      Redmine::DefaultData::Loader.load(current_language)

      puts "Default configuration data loaded." 

    rescue => error

      puts "Error: " + error

      puts "Default configuration data was not loaded." 

    end

  end

end

Associated revisions

Revision 2591
Added by Jean-Philippe Lang almost 9 years ago

Ability to set language for redmine:load_default_data task using REDMINE_LANG environment variable (#2847).

History

#1 Updated by Jean-Philippe Lang almost 9 years ago

  • Status changed from New to Resolved
  • Target version set to 0.8.3
  • Resolution set to Fixed

Feature added in r2591.

#2 Updated by Jean-Philippe Lang almost 9 years ago

  • Status changed from Resolved to Closed

Merged in 0.8-stable in r2593.

Also available in: Atom PDF