~ubuntu-branches/ubuntu/jaunty/beagle/jaunty-security

« back to all changes in this revision

Viewing changes to intltool-merge.in

  • Committer: Bazaar Package Importer
  • Author(s): Stefan Ebner
  • Date: 2008-05-04 00:31:32 UTC
  • mfrom: (1.1.21 upstream)
  • Revision ID: james.westby@ubuntu.com-20080504003132-2tkm5o8moo5952ri
Tags: 0.3.7-2ubuntu1
 * Merge from Debian unstable. (LP: #225746) Remaining Ubuntu changes:
  - debian/control:
    + Rename ice{weasel,dove}-beagle to {mozilla,thunderbird}-beagle and
      and update the dependencies accordingly.
    + Change Maintainer to Ubuntu Mono Team.
  - debian/rules:
    + Install the mozilla-beagle and thunderbird-beagle extensions.
  - ice{dove,weasel}.dirs:
    + Renamed to {mozilla,thunderbird}-beagle.dirs.
    + Fixed paths to point to usr/lib/{firefox,thunderbird}

Show diffs side-by-side

added added

removed removed

Lines of Context:
35
35
## Release information
36
36
my $PROGRAM = "intltool-merge";
37
37
my $PACKAGE = "intltool";
38
 
my $VERSION = "0.36.2";
 
38
my $VERSION = "0.37.1";
39
39
 
40
40
## Loaded modules
41
41
use strict; 
61
61
my $SCHEMAS_STYLE_ARG = 0;
62
62
my $RFC822DEB_STYLE_ARG = 0;
63
63
my $QUOTED_STYLE_ARG = 0;
 
64
my $QUOTEDXML_STYLE_ARG = 0;
64
65
my $QUIET_ARG = 0;
65
66
my $PASS_THROUGH_ARG = 0;
66
67
my $UTF8_ARG = 0;
81
82
 "schemas-style|s" => \$SCHEMAS_STYLE_ARG,
82
83
 "rfc822deb-style|r" => \$RFC822DEB_STYLE_ARG,
83
84
 "quoted-style" => \$QUOTED_STYLE_ARG,
 
85
 "quotedxml-style" => \$QUOTEDXML_STYLE_ARG,
84
86
 "pass-through|p" => \$PASS_THROUGH_ARG,
85
87
 "utf8|u" => \$UTF8_ARG,
86
88
 "multiple-output|m" => \$MULTIPLE_OUTPUT,
148
150
        &utf8_sanity_check;
149
151
        &preparation;
150
152
        &print_message;
151
 
        &keys_merge_translations;
 
153
        &keys_merge_translations;
152
154
        &finalize;
153
155
154
156
elsif ($DESKTOP_STYLE_ARG && @ARGV > 2) 
174
176
        &rfc822deb_merge_translations;
175
177
        &finalize;
176
178
177
 
elsif ($QUOTED_STYLE_ARG && @ARGV > 2) 
 
179
elsif (($QUOTED_STYLE_ARG || $QUOTEDXML_STYLE_ARG) && @ARGV > 2)
178
180
{
179
181
        &utf8_sanity_check;
180
182
        &preparation;
181
183
        &print_message;
182
 
        &quoted_merge_translations;
 
184
        &quoted_merge_translations($QUOTEDXML_STYLE_ARG);
183
185
        &finalize;
184
186
185
187
else 
219
221
  -s, --schemas-style    includes translations in the schemas style
220
222
  -r, --rfc822deb-style  includes translations in the RFC822 style
221
223
      --quoted-style     includes translations in the quoted string style
 
224
      --quotedxml-style  includes translations in the quoted xml string style
222
225
  -x, --xml-style        includes translations in the standard xml style
223
226
 
224
227
Other options:
292
295
            {
293
296
                next if /^#/;
294
297
 
295
 
                if (/([-a-zA-Z_@.]+)\n/)
 
298
                for my $lang (split)
296
299
                {
297
 
                    my $lang = $1;
298
 
 
 
300
                    chomp ($lang);
299
301
                    my $po_file = $PO_DIR . "/" . $lang . ".po";
300
302
                    if (-e $po_file) {
301
303
                        $po_files_by_lang{$lang} = $po_file;
576
578
    return "&" if $_ == 38;
577
579
    return "'" if $_ == 39;
578
580
    return "<" if $_ == 60;
 
581
    return ">" if $_ == 62;
579
582
    return chr $_;
580
583
}
581
584
 
1076
1079
            close OUTPUT;
1077
1080
            print "CREATED $lang/$OUTFILE\n" unless $QUIET_ARG;
1078
1081
        }
1079
 
    } 
1080
 
    open OUTPUT, ">$OUTFILE" or die "Cannot open $OUTFILE: $!\n";
 
1082
        if ( ! -d "C" ) {
 
1083
            mkdir "C" or -d "C" or die "Cannot create subdirectory C: $!\n";
 
1084
        }
 
1085
        open OUTPUT, ">C/$OUTFILE" or die "Cannot open C/$OUTFILE: $!\n";
 
1086
        binmode (OUTPUT) if $^O eq 'MSWin32';
 
1087
        my $tree = readXml($FILE);
 
1088
        print_header($FILE, \*OUTPUT);
 
1089
        parseTree(\*OUTPUT, $tree);
 
1090
        close OUTPUT;
 
1091
        print "CREATED C/$OUTFILE\n" unless $QUIET_ARG;
 
1092
    } else {
 
1093
        open OUTPUT, ">$OUTFILE" or die "Cannot open $OUTFILE: $!\n";
 
1094
        binmode (OUTPUT) if $^O eq 'MSWin32';
 
1095
        my $tree = readXml($FILE);
 
1096
        print_header($FILE, \*OUTPUT);
 
1097
        parseTree(\*OUTPUT, $tree);
 
1098
        close OUTPUT;
 
1099
        print "CREATED $OUTFILE\n" unless $QUIET_ARG;
 
1100
    }
 
1101
}
 
1102
 
 
1103
sub keys_merge_translation
 
1104
{
 
1105
    my ($lang) = @_;
 
1106
 
 
1107
    if ( ! -d $lang && $MULTIPLE_OUTPUT)
 
1108
    {
 
1109
        mkdir $lang or -d $lang or die "Cannot create subdirectory $lang: $!\n";
 
1110
    }
 
1111
 
 
1112
    open INPUT, "<${FILE}" or die "Cannot open ${FILE}: $!\n";
 
1113
    open OUTPUT, ">$lang/$OUTFILE" or die "Cannot open $lang/$OUTFILE: $!\n";
1081
1114
    binmode (OUTPUT) if $^O eq 'MSWin32';
1082
 
    my $tree = readXml($FILE);
1083
 
    print_header($FILE, \*OUTPUT);
1084
 
    parseTree(\*OUTPUT, $tree);
 
1115
 
 
1116
    while (<INPUT>)
 
1117
    {
 
1118
        if (s/^(\s*)_(\w+=(.*))/$1$2/)
 
1119
        {
 
1120
            my $string = $3;
 
1121
 
 
1122
            if (!$MULTIPLE_OUTPUT)
 
1123
            {
 
1124
                print OUTPUT;
 
1125
 
 
1126
                my $non_translated_line = $_;
 
1127
 
 
1128
                for my $lang (sort keys %po_files_by_lang)
 
1129
                {
 
1130
                    my $translation = $translations{$lang, $string};
 
1131
                    next if !$translation;
 
1132
 
 
1133
                    $_ = $non_translated_line;
 
1134
                    s/(\w+)=.*/[$lang]$1=$translation/;
 
1135
                    print OUTPUT;
 
1136
                }
 
1137
            }
 
1138
            else
 
1139
            {
 
1140
                my $non_translated_line = $_;
 
1141
                my $translation = $translations{$lang, $string};
 
1142
                $translation = $string if !$translation;
 
1143
 
 
1144
                $_ = $non_translated_line;
 
1145
                s/(\w+)=.*/$1=$translation/;
 
1146
                print OUTPUT;
 
1147
            }
 
1148
        }
 
1149
        else
 
1150
        {
 
1151
            print OUTPUT;
 
1152
        }
 
1153
    }
 
1154
 
1085
1155
    close OUTPUT;
1086
 
    print "CREATED $OUTFILE\n" unless $QUIET_ARG;
 
1156
    close INPUT;
 
1157
 
 
1158
    print "CREATED $lang/$OUTFILE\n" unless $QUIET_ARG;
1087
1159
}
1088
1160
 
1089
1161
sub keys_merge_translations
1090
1162
{
1091
 
    open INPUT, "<${FILE}" or die;
1092
 
    open OUTPUT, ">${OUTFILE}" or die;
1093
 
    binmode (OUTPUT) if $^O eq 'MSWin32';
1094
 
 
1095
 
    while (<INPUT>) 
 
1163
    if ($MULTIPLE_OUTPUT)
1096
1164
    {
1097
 
        if (s/^(\s*)_(\w+=(.*))/$1$2/)  
1098
 
        {
1099
 
            my $string = $3;
1100
 
 
1101
 
            print OUTPUT;
1102
 
 
1103
 
            my $non_translated_line = $_;
1104
 
 
1105
 
            for my $lang (sort keys %po_files_by_lang) 
1106
 
            {
1107
 
                my $translation = $translations{$lang, $string};
1108
 
                next if !$translation;
1109
 
 
1110
 
                $_ = $non_translated_line;
1111
 
                s/(\w+)=.*/[$lang]$1=$translation/;
1112
 
                print OUTPUT;
1113
 
            }
1114
 
        } 
1115
 
        else 
1116
 
        {
1117
 
            print OUTPUT;
 
1165
        for my $lang (sort keys %po_files_by_lang)
 
1166
        {
 
1167
            keys_merge_translation ($lang);
1118
1168
        }
1119
 
    }
1120
 
 
1121
 
    close OUTPUT;
1122
 
    close INPUT;
 
1169
        keys_merge_translation ("C");
 
1170
    }
 
1171
    else
 
1172
    {
 
1173
        keys_merge_translation (".");
 
1174
    }
1123
1175
}
1124
1176
 
1125
1177
sub desktop_merge_translations
1415
1467
 
1416
1468
sub quoted_translation
1417
1469
{
1418
 
    my ($lang, $string) = @_;
 
1470
    my ($xml_mode, $lang, $string) = @_;
1419
1471
 
 
1472
    $string = entity_decode($string) if $xml_mode;
1420
1473
    $string =~ s/\\\"/\"/g;
1421
1474
 
1422
1475
    my $translation = $translations{$lang, $string};
1423
1476
    $translation = $string if !$translation;
1424
 
 
 
1477
    $translation = entity_encode($translation) if $xml_mode;
1425
1478
    $translation =~ s/\"/\\\"/g;
1426
1479
    return $translation
1427
1480
}
1428
1481
 
1429
1482
sub quoted_merge_translations
1430
1483
{
 
1484
    my ($xml_mode) = @_;
 
1485
 
1431
1486
    if (!$MULTIPLE_OUTPUT) {
1432
1487
        print "Quoted only supports Multiple Output.\n";
1433
1488
        exit(1);
1442
1497
        binmode (OUTPUT) if $^O eq 'MSWin32';
1443
1498
        while (<INPUT>) 
1444
1499
        {
1445
 
            s/\"(([^\"]|\\\")*[^\\\"])\"/"\"" . &quoted_translation($lang, $1) . "\""/ge;
 
1500
            s/\"(([^\"]|\\\")*[^\\\"])\"/"\"" . &quoted_translation($xml_mode, $lang, $1) . "\""/ge;
1446
1501
            print OUTPUT;
1447
1502
        }
1448
1503
        close OUTPUT;