Project

General

Profile

Actions

Feature #2847

closed

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

Added by Jérémy Lal over 15 years ago. Updated about 13 years ago.

Status:
Closed
Priority:
Normal
Assignee:
-
Category:
-
Target version:
Start date:
2009-02-26
Due date:
% Done:

0%

Estimated time:
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
Actions

Also available in: Atom PDF