~ubuntu-branches/ubuntu/jaunty/localechooser/jaunty

« back to all changes in this revision

Viewing changes to mklanguagelist.data

  • Committer: Bazaar Package Importer
  • Author(s): Colin Watson
  • Date: 2008-06-16 15:52:37 UTC
  • Revision ID: james.westby@ubuntu.com-20080616155237-61s20bms9m4rbyy8
Tags: 2.03ubuntu1
* Resynchronise with Debian. Remaining changes:
  - Add a localechooser-data package containing lists useful for packages
    that create automatic installation scripts.
  - Always support English, unless preseeded otherwise.
  - Drop fallbacks for Norwegian Bokmål and Nynorsk.
  - Simplify use of locale-gen using the new command-line argument
    facility in Ubuntu's locales package.
  - Add encoding field to languagelist file and use the full SUPPORTED
    file rather than SUPPORTED-short.
  - If the language question was already marked as seen and the answer
    didn't change, then don't recalculate the locale.
  - If OVERRIDE_SHOW_ALL_LANGUAGES is set in the environment, display all
    languages regardless of frontend.
  - Allow preseeding of debian-installer/language.
* localechooser-data Breaks: system-config-kickstart (<< 2.5.20-0ubuntu17)
  due to languagelist format changes.

Show diffs side-by-side

added added

removed removed

Lines of Context:
 
1
#!/usr/bin/perl
 
2
#
 
3
# Authors: Petter Reinholdtsen (2003)
 
4
#          Christian Perrier (2004)
 
5
#          Frans Pop (2008)
 
6
#
 
7
# Extract language options for debian-installer
 
8
 
 
9
use strict;
 
10
use warnings;
 
11
 
 
12
my $list       = shift;
 
13
my $outfile    = shift;
 
14
 
 
15
my $debug = 0;
 
16
 
 
17
my %codes;
 
18
my %levels;
 
19
my %translations;
 
20
 
 
21
sub get_language_names {
 
22
    my $list = shift;
 
23
    my @names;
 
24
    print "Loading $list\n" if ($debug);
 
25
    open(L, "< $list") || die "Unable to read $list";
 
26
    while (<L>) {
 
27
        print if ($debug);
 
28
        chomp;
 
29
        next if m/^\#/;
 
30
        my ($code, $name, $translation, $level, ) = split(/;/);
 
31
        push(@names, $name);
 
32
 
 
33
        $codes{$name} = $code;
 
34
        $levels{$name} = $level;
 
35
        $translations{$name} = $translation;
 
36
    }
 
37
    close(L);
 
38
    return @names;
 
39
}
 
40
 
 
41
my @languagenames = get_language_names($list);
 
42
 
 
43
sub order_trans {
 
44
    return $a cmp $b;
 
45
}
 
46
 
 
47
#Sorts languages, making sure that the C locale is listed first
 
48
sub sort_C_first {
 
49
    my @full_list = @_;
 
50
    my @C_locale = grep /^C$/, @full_list;
 
51
    my @languages = grep !/^C$/, @full_list;
 
52
    my @new_list = sort order_trans @languages;
 
53
    unshift @new_list, @C_locale;
 
54
    return @new_list;
 
55
}
 
56
 
 
57
open(TOUT, "> $outfile") || die "Unable to write $outfile";
 
58
for my $name (sort_C_first @languagenames) {
 
59
    my $line;
 
60
    if (exists $translations{$name}) {
 
61
        $line = $levels{$name}.
 
62
                ":".
 
63
                $codes{$name}.
 
64
                ":".
 
65
                $name.
 
66
                ":".
 
67
                $translations{$name};
 
68
        print TOUT $line, "\n";
 
69
    }
 
70
}
 
71
close(TOUT) || warn;