5 my $progname=$0; $progname = $& if $progname =~ m
,[^/]+$,;
7 my %PREFIX; # used to search for prefix numbers
8 my %ISOCODE; # used to search for iso codes
9 my %LANGUAGE; # used to search for language names
11 #=======================================================================
12 # initialisation code - stuff the DATA into the CODES hash
13 #=======================================================================
25 ($prefix, $code, $name ) = split(/:/, $_, 3);
26 $PREFIX{$prefix} = $prefix;
27 $PREFIX{$code} = $prefix;
28 $PREFIX{$name} = $prefix;
30 $ISOCODE{$prefix} = $code;
31 $ISOCODE{$code} = $code;
32 $ISOCODE{$name} = $code;
34 $LANGUAGE{$prefix} = $name;
35 $LANGUAGE{$code} = $name;
36 $LANGUAGE{$name} = $name;
41 #=======================================================================
42 # usage - error message
43 #=======================================================================
47 print STDERR
"$progname: $errmsg\n" if $errmsg;
48 print STDERR
"$progname: Converts between prefix codes, iso codes and langnames\n";
49 print STDERR
" Usage: $progname (-i|-l|-p|-h) <code>|all\n";
50 print STDERR
" -i <code>: convert prefix to iso code (ex: 03 -> pt)\n";
51 print STDERR
" -l <code>: convert iso code to language name (ex: pt -> portuguese)\n";
52 print STDERR
" -p <code>: convert iso code to prefix (ex: pt -> 03)\n";
53 print STDERR
" the code can either be an iso code, a prefix or even a language name\n";
54 print STDERR
" The special code \"all\" asks for all possible values.\n\n";
55 print STDERR
" -h : print this help\n";
59 #=======================================================================
61 #=======================================================================
64 my ($LanguageCode, $LanguageMap);
66 while ($ARGV[0] =~ /^-/) {
69 $LanguageMap = \
%ISOCODE;
72 $LanguageMap = \
%LANGUAGE;
75 $LanguageMap = \
%PREFIX;
81 usage
("unknown option $_",1);
85 usage
("no operation specified on command line",1)
88 usage
("no language code specified on command line",1)
89 if (!($LanguageCode = shift));
91 if ($LanguageCode =~ (m/^all$/)) {
94 foreach my $key (sort values %$LanguageMap) {
104 usage
("no mapping found for $LanguageCode\n",1)
105 if (!($LanguageMap->{$LanguageCode}));
107 print $LanguageMap->{$LanguageCode}, "\n";
111 # keep third column names here with openoffice-dir/share/*/<long lang name>/
118 :en
-GB
:english_british
142 :en
-ZA
:english_southafrican
180 01:en
-US
:english_american
198 47:nb
:norwegian_bokmal
203 55:pt
-BR
:portuguese_brazilian
205 79:nn
:norwegian_nynorsk
208 86:zh
-CN
:chinese_simplified
209 88:zh
-TW
:chinese_traditional