#!/usr/bin/perl

use lib qw(/usr/lib/libDrakX);

use standalone;     #- warning, standalone must be loaded very first, for 'explanations'

use interactive;
use lang;
use any;


if ($ARGV[0] =~ /--kde_country=(.*)/) {
    my $lang = lang::country2lang($1);
    lang::write('', $lang, $>);

    #- help KDE defaulting to the right charset
    print lang::charset2kde_charset(lang::lang2charset($lang)), "\n";
} else {
    my ($lang, $langs) = lang::read('', $>);

    my $in = 'interactive'->vnew;
    if ($lang = any::selectLanguage($in, $lang, $langs)) {
	lang::write('', $lang, $>);
	lang::write_langs('', $langs) if $langs;
	if ($>) {
	    if (my $wm = any::running_window_manager()) {
		$in->ask_warn('', _("Please relog into %s to activate the changes", ucfirst (lc $wm)), 1);
		any::ask_window_manager_to_logout($wm);
	    }
	}
    }
    $in->exit(0);
}