summaryrefslogtreecommitdiffstats
path: root/perl-install/standalone/localedrake
blob: 22385c027c8b3fc21af093cf713a9de64011bb0c (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
#!/usr/bin/perl

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

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

use interactive;
use common;
use lang;
use any;

my ($klang, $kcountry, $apply);

foreach (@ARGV) {
    $apply = /--apply/;
    $klang = $1 if /--kde_lang=(.*)/;
    $kcountry = uc($1) if /--kde_country=(.*)/;
}

if (defined $klang) {
    $klang or exit(-1);
    my $lang = member($klang, lang::list_langs()) ? $klang : 'en_US';
    my $country = member($kcountry, lang::list_countries()) ? $kcountry : 'US';
    my $locale = lang::read($>);
    $klang and $locale->{lang} = $lang;
    $kcountry and $locale->{country} = $country;
    lang::write($locale, $>, 'dont_touch_kde_files') if $apply;

    #- help KDE defaulting to the right charset
    print lang::charset2kde_charset(lang::l2charset($lang)), "\n";
    exit(0);
}

my $locale = lang::read($>);
my $in = 'interactive'->vnew;

$ugtk2::wm_icon = "localedrake";
$::Wizard_title = N("LocaleDrake");

sub select_country() {
    any::selectCountry($in, $locale);  
}

eval {
    local $::isWizard = 1;
    local $::Wizard_no_previous = 1;
  language:
    my $old_lang = $locale->{lang};
    $locale->{lang} = any::selectLanguage($in, $locale->{lang});
    $locale->{IM} ||= lang::get_default_im($locale->{lang}) if $old_lang ne $locale->{lang};
    undef $::Wizard_no_previous;
    select_country() or goto language;
};
if ($@) {
    if ($@ =~ /^one lang only/) {
	select_country() or $in->exit(0);
    } elsif ($@ !~ /wizcancel/) {
	die;
    } else {
        $in->exit(0);
    }
}

lang::write($locale, $>);
if ($>) {
    if (my $wm = any::running_window_manager()) {
	$in->ask_okcancel('', N("The change is done, but to be effective you must logout"), 1)
	  and any::ask_window_manager_to_logout($wm);
    }
}