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
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
280
281
282
283
284
285
286
287
288
289
290
291
292
293
294
295
296
297
298
299
300
301
302
303
304
305
306
307
308
309
310
311
312
313
314
315
316
317
318
319
320
321
322
323
324
325
326
327
328
329
330
331
332
333
334
335
336
337
338
339
340
341
342
343
344
345
346
347
348
349
350
351
352
353
354
355
356
357
358
359
360
361
362
363
364
365
366
367
368
369
370
371
372
373
374
375
376
377
378
379
380
381
382
383
384
385
386
387
388
389
390
391
392
393
394
395
396
397
398
399
400
401
402
403
404
405
406
407
408
409
410
411
412
413
414
415
416
417
418
419
420
421
422
423
424
425
426
427
428
429
430
431
432
433
434
435
436
437
438
439
440
441
442
443
444
445
446
447
448
449
450
451
452
453
454
455
456
457
458
459
460
461
462
463
464
465
466
467
468
469
470
471
472
473
474
475
476
477
478
479
480
481
482
483
484
485
486
487
488
489
490
491
492
493
494
495
496
497
498
499
500
501
502
503
504
505
506
507
508
509
510
511
512
513
514
515
516
517
518
519
520
521
522
523
524
525
526
527
528
529
530
531
532
533
534
535
536
537
538
539
540
541
542
543
544
545
546
547
548
549
550
551
552
553
554
555
556
557
558
559
560
561
562
563
564
565
566
567
568
569
570
571
572
573
574
575
576
577
578
579
580
581
582
583
584
585
586
587
588
589
590
591
592
593
594
595
596
597
598
599
600
601
602
603
604
605
606
607
|
--- intltool-extract.in 2007-02-04 02:52:50.000000000 +1100
+++ teatime-2.8.0-intl/intltool-extract.in 2007-08-17 18:02:38.000000000 +1000
@@ -32,7 +32,7 @@
## Release information
my $PROGRAM = "intltool-extract";
my $PACKAGE = "intltool";
-my $VERSION = "0.35.0";
+my $VERSION = "0.36.0";
## Loaded modules
use strict;
@@ -114,6 +114,11 @@
sub place_normal {
$FILE = $ARGV[0];
$OUTFILE = "$FILE.h";
+
+ my $dirname = dirname ($OUTFILE);
+ if (! -d "$dirname" && $dirname ne "") {
+ system ("mkdir -p $dirname");
+ }
}
sub place_local {
@@ -156,7 +161,7 @@
--type=TYPE Specify the file type of FILENAME. Currently supports:
"gettext/glade", "gettext/ini", "gettext/keys"
"gettext/rfc822deb", "gettext/schemas",
- "gettext/scheme", "gettext/xml"
+ "gettext/scheme", "gettext/xml", "gettext/quoted"
-l, --local Writes output into current working directory
(conflicts with --update)
--update Writes output into the same directory the source file
@@ -212,6 +217,7 @@
&type_scheme if $gettext_type eq "scheme";
&type_schemas if $gettext_type eq "schemas";
&type_rfc822deb if $gettext_type eq "rfc822deb";
+ &type_quoted if $gettext_type eq "quoted";
}
sub entity_decode_minimal
@@ -231,9 +237,9 @@
s/'/'/g; # '
s/"/"/g; # "
- s/&/&/g;
s/</</g;
s/>/>/g;
+ s/&/&/g;
return $_;
}
@@ -242,7 +248,7 @@
{
return '\"' if $_ eq '"';
return '\n' if $_ eq "\n";
- return '\\' if $_ eq '\\';
+ return '\\\\' if $_ eq '\\';
return $_;
}
@@ -255,8 +261,11 @@
sub type_ini {
### For generic translatable desktop files ###
- while ($input =~ /^_.*=(.*)$/mg) {
- $messages{$1} = [];
+ while ($input =~ /^(#(.+)\n)?^_.*=(.*)$/mg) {
+ if (defined($2)) {
+ $comments{$3} = $2;
+ }
+ $messages{$3} = [];
}
}
@@ -711,6 +720,17 @@
return @list;
}
+sub type_quoted {
+ while ($input =~ /\"(([^\"]|\\\")*[^\\\"])\"/g) {
+ my $message = $1;
+ my $before = $`;
+ $message =~ s/\\\"/\"/g;
+ $before =~ s/[^\n]//g;
+ $messages{$message} = [];
+ $loc{$message} = length ($before) + 2;
+ }
+}
+
sub type_glade {
### For translatable Glade XML files ###
--- intltool-merge.in 2007-02-04 02:52:50.000000000 +1100
+++ teatime-2.8.0-intl/intltool-merge.in 2007-08-17 18:02:47.000000000 +1000
@@ -35,7 +35,7 @@
## Release information
my $PROGRAM = "intltool-merge";
my $PACKAGE = "intltool";
-my $VERSION = "0.35.0";
+my $VERSION = "0.36.0";
## Loaded modules
use strict;
@@ -60,6 +60,7 @@
my $DESKTOP_STYLE_ARG = 0;
my $SCHEMAS_STYLE_ARG = 0;
my $RFC822DEB_STYLE_ARG = 0;
+my $QUOTED_STYLE_ARG = 0;
my $QUIET_ARG = 0;
my $PASS_THROUGH_ARG = 0;
my $UTF8_ARG = 0;
@@ -79,6 +80,7 @@
"desktop-style|d" => \$DESKTOP_STYLE_ARG,
"schemas-style|s" => \$SCHEMAS_STYLE_ARG,
"rfc822deb-style|r" => \$RFC822DEB_STYLE_ARG,
+ "quoted-style" => \$QUOTED_STYLE_ARG,
"pass-through|p" => \$PASS_THROUGH_ARG,
"utf8|u" => \$UTF8_ARG,
"multiple-output|m" => \$MULTIPLE_OUTPUT,
@@ -91,9 +93,35 @@
my %po_files_by_lang = ();
my %translations = ();
-my $iconv = $ENV{"ICONV"} || $ENV{"INTLTOOL_ICONV"} || "@INTLTOOL_ICONV@";
+my $iconv = $ENV{"ICONV"} || "iconv";
my $devnull = ($^O eq 'MSWin32' ? 'NUL:' : '/dev/null');
+sub isProgramInPath
+{
+ my ($file) = @_;
+ # If either a file exists, or when run it returns 0 exit status
+ return 1 if ((-x $file) or (system("$file --version >$devnull") == 0));
+ return 0;
+}
+
+sub isGNUGettextTool
+{
+ my ($file) = @_;
+ # Check that we are using GNU gettext tools
+ if (isProgramInPath ($file)) {
+ my $version = `$file --version`;
+ return 1 if ($version =~ m/.*\(GNU .*\).*/);
+ }
+ return 0;
+}
+
+if (! isGNUGettextTool ("$iconv"))
+{
+ print STDERR " *** GNU iconv is not found on this system!\n".
+ " *** Without it, intltool-merge can not convert encodings.\n";
+ exit;
+}
+
# Use this instead of \w for XML files to handle more possible characters.
my $w = "[-A-Za-z0-9._:]";
@@ -157,6 +185,14 @@
&rfc822deb_merge_translations;
&finalize;
}
+elsif ($QUOTED_STYLE_ARG && @ARGV > 2)
+{
+ &utf8_sanity_check;
+ &preparation;
+ &print_message;
+ "ed_merge_translations;
+ &finalize;
+}
else
{
&print_help;
@@ -193,6 +229,7 @@
-k, --keys-style includes translations in the keys style
-s, --schemas-style includes translations in the schemas style
-r, --rfc822deb-style includes translations in the RFC822 style
+ --quoted-style includes translations in the quoted string style
-x, --xml-style includes translations in the standard xml style
Other options:
@@ -415,7 +452,7 @@
{
$nextfuzzy = 1 if /^#, fuzzy/;
- if (/^msgid "((\\.|[^\\])*)"/ )
+ if (/^msgid "((\\.|[^\\]+)*)"/ )
{
$translations{$lang, $msgid} = $msgstr if $inmsgstr && $msgid && $msgstr;
$msgid = "";
@@ -431,14 +468,14 @@
$nextfuzzy = 0;
}
- if (/^msgstr "((\\.|[^\\])*)"/)
+ if (/^msgstr "((\\.|[^\\]+)*)"/)
{
$msgstr = unescape_po_string($1);
$inmsgstr = 1;
$inmsgid = 0;
}
- if (/^"((\\.|[^\\])*)"/)
+ if (/^"((\\.|[^\\]+)*)"/)
{
$msgid .= unescape_po_string($1) if $inmsgid;
$msgstr .= unescape_po_string($1) if $inmsgstr;
@@ -483,16 +520,15 @@
return $string;
}
-## NOTE: deal with < - < but not > - > because it seems its ok to have
-## > in the entity. For further info please look at #84738.
sub entity_decode
{
local ($_) = @_;
s/'/'/g; # '
s/"/"/g; # "
- s/&/&/g;
s/</</g;
+ s/>/>/g;
+ s/&/&/g;
return $_;
}
@@ -1006,8 +1042,8 @@
if ($MULTIPLE_OUTPUT) {
for my $lang (sort keys %po_files_by_lang) {
- if ( ! -e $lang ) {
- mkdir $lang or die "Cannot create subdirectory $lang: $!\n";
+ if ( ! -d $lang ) {
+ mkdir $lang or -d $lang or die "Cannot create subdirectory $lang: $!\n";
}
open OUTPUT, ">$lang/$OUTFILE" or die "Cannot open $lang/$OUTFILE: $!\n";
binmode (OUTPUT) if $^O eq 'MSWin32';
@@ -1354,3 +1390,39 @@
return @list;
}
+sub quoted_translation
+{
+ my ($lang, $string) = @_;
+
+ $string =~ s/\\\"/\"/g;
+
+ my $translation = $translations{$lang, $string};
+ $translation = $string if !$translation;
+
+ $translation =~ s/\"/\\\"/g;
+ return $translation
+}
+
+sub quoted_merge_translations
+{
+ if (!$MULTIPLE_OUTPUT) {
+ print "Quoted only supports Multiple Output.\n";
+ exit(1);
+ }
+
+ for my $lang (sort keys %po_files_by_lang) {
+ if ( ! -d $lang ) {
+ mkdir $lang or -d $lang or die "Cannot create subdirectory $lang: $!\n";
+ }
+ open INPUT, "<${FILE}" or die;
+ open OUTPUT, ">$lang/$OUTFILE" or die "Cannot open $lang/$OUTFILE: $!\n";
+ binmode (OUTPUT) if $^O eq 'MSWin32';
+ while (<INPUT>)
+ {
+ s/\"(([^\"]|\\\")*[^\\\"])\"/"\"" . "ed_translation($lang, $1) . "\""/ge;
+ print OUTPUT;
+ }
+ close OUTPUT;
+ close INPUT;
+ }
+}
--- intltool-update.in 2007-02-04 02:52:50.000000000 +1100
+++ teatime-2.8.0-intl/intltool-update.in 2007-08-17 18:02:54.000000000 +1000
@@ -30,7 +30,7 @@
## Release information
my $PROGRAM = "intltool-update";
-my $VERSION = "0.35.0";
+my $VERSION = "0.36.0";
my $PACKAGE = "intltool";
## Loaded modules
@@ -71,7 +71,8 @@
"sheet(?:\\.in)+|". # ?
"schemas(?:\\.in)+|". # GConf specific
"pong(?:\\.in)+|". # DEPRECATED: PONG is not used [by GNOME] any longer.
-"kbd(?:\\.in)+"; # GOK specific.
+"kbd(?:\\.in)+|". # GOK specific.
+"policy(?:\\.in)+"; # PolicyKit files
my $ini_support =
"icon(?:\\.in)+|". # http://www.freedesktop.org/Standards/icon-theme-spec
@@ -90,10 +91,9 @@
$| = 1;
## Sometimes the source tree will be rooted somewhere else.
-my $SRCDIR = ".";
+my $SRCDIR = $ENV{"srcdir"} || ".";
my $POTFILES_in;
-$SRCDIR = $ENV{"srcdir"} if $ENV{"srcdir"};
$POTFILES_in = "<$SRCDIR/POTFILES.in";
my $devnull = ($^O eq 'MSWin32' ? 'NUL:' : '/dev/null');
@@ -124,8 +124,10 @@
&Console_Write_IntltoolHelp if $arg_count > 1;
+my $PKGNAME = FindPackageName ();
+
# --version and --help don't require a module name
-my $MODULE = $GETTEXT_PACKAGE || &FindPackageName || "unknown";
+my $MODULE = $GETTEXT_PACKAGE || $PKGNAME || "unknown";
if ($POT_ARG)
{
@@ -316,7 +318,8 @@
@buf_potfiles_ignore,
@buf_allfiles,
@buf_allfiles_sorted,
- @buf_potfiles_sorted
+ @buf_potfiles_sorted,
+ @buf_potfiles_ignore_sorted
);
## Search and find all translatable files
@@ -326,7 +329,12 @@
push @buf_i18n_ini, "$File::Find::name" if /\.($ini_support)$/;
push @buf_i18n_xml_unmarked, "$File::Find::name" if /\.(schemas(\.in)+)$/;
}, "..";
-
+ find sub {
+ push @buf_i18n_plain, "$File::Find::name" if /\.($buildin_gettext_support)$/;
+ push @buf_i18n_xml, "$File::Find::name" if /\.($xml_support)$/;
+ push @buf_i18n_ini, "$File::Find::name" if /\.($ini_support)$/;
+ push @buf_i18n_xml_unmarked, "$File::Find::name" if /\.(schemas(\.in)+)$/;
+ }, "$SRCDIR/..";
open POTFILES, $POTFILES_in or die "$PROGRAM: there's no POTFILES.in!\n";
@buf_potfiles = grep !/^(#|\s*$)/, <POTFILES>;
@@ -342,7 +350,7 @@
## comparing with POTFILES.in
foreach my $ignore ("POTFILES.skip", "POTFILES.ignore")
{
- (-s $ignore) or next;
+ (-s "$SRCDIR/$ignore") or next;
if ("$ignore" eq "POTFILES.ignore")
{
@@ -351,7 +359,7 @@
}
print "Found $ignore: Ignoring files...\n" if $VERBOSE;
- open FILE, "<$ignore" or die "ERROR: Failed to open $ignore!\n";
+ open FILE, "<$SRCDIR/$ignore" or die "ERROR: Failed to open $SRCDIR/$ignore!\n";
while (<FILE>)
{
@@ -359,7 +367,7 @@
}
close FILE;
- @buf_potfiles = (@buf_potfiles_ignore, @buf_potfiles);
+ @buf_potfiles_ignore_sorted = sort (@buf_potfiles_ignore);
}
foreach my $file (@buf_i18n_plain)
@@ -417,7 +425,7 @@
}
}
- if (/\.GetString ?\(QUOTEDTEXT/)
+ if (/\w\.GetString *\(QUOTEDTEXT/)
{
if (defined isNotValidMissing (unpack("x3 A*", $file))) {
## Remove the first 3 chars and add newline
@@ -426,7 +434,8 @@
last;
}
- if (/_\(QUOTEDTEXT/)
+ ## N_ Q_ and _ are the three macros defined in gi8n.h
+ if (/[NQ]?_ *\(QUOTEDTEXT/)
{
if (defined isNotValidMissing (unpack("x3 A*", $file))) {
## Remove the first 3 chars and add newline
@@ -486,6 +495,15 @@
my %in2;
foreach (@buf_potfiles_sorted)
{
+ s#^$SRCDIR/../##;
+ s#^$SRCDIR/##;
+ $in2{$_} = 1;
+ }
+
+ foreach (@buf_potfiles_ignore_sorted)
+ {
+ s#^$SRCDIR/../##;
+ s#^$SRCDIR/##;
$in2{$_} = 1;
}
@@ -493,9 +511,16 @@
foreach (@buf_allfiles_sorted)
{
- if (!exists($in2{$_}))
+ my $dummy = $_;
+ my $srcdir = $SRCDIR;
+
+ $srcdir =~ s#^../##;
+ $dummy =~ s#^$srcdir/../##;
+ $dummy =~ s#^$srcdir/##;
+ $dummy =~ s#_build/##;
+ if (!exists($in2{$dummy}))
{
- push @result, $_
+ push @result, $dummy
}
}
@@ -504,7 +529,7 @@
foreach (@buf_potfiles_sorted)
{
chomp (my $dummy = $_);
- if ("$dummy" ne "" and ! -f "../$dummy")
+ if ("$dummy" ne "" and !(-f "$SRCDIR/../$dummy" or -f "../$dummy"))
{
push @buf_potfiles_notexist, $_;
}
@@ -537,7 +562,7 @@
warn "\n" if ($VERBOSE or @result);
warn "\e[1mThe following files do not exist anymore:\e[0m\n\n";
warn @buf_potfiles_notexist, "\n";
- warn "Please remove them from POTFILES.in or POTFILES.skip. A file \e[1m'notexist'\e[0m\n".
+ warn "Please remove them from POTFILES.in. A file \e[1m'notexist'\e[0m\n".
"containing this list of absent files has been written in the current directory.\n";
}
}
@@ -555,16 +580,33 @@
exit 1;
}
-sub GenerateHeaders
+sub isProgramInPath
{
- my $EXTRACT = "@INTLTOOL_EXTRACT@";
- chomp $EXTRACT;
+ my ($file) = @_;
+ # If either a file exists, or when run it returns 0 exit status
+ return 1 if ((-x $file) or (system("$file --version >$devnull") == 0));
+ return 0;
+}
- $EXTRACT = $ENV{"INTLTOOL_EXTRACT"} if $ENV{"INTLTOOL_EXTRACT"};
+sub isGNUGettextTool
+{
+ my ($file) = @_;
+ # Check that we are using GNU gettext tools
+ if (isProgramInPath ($file))
+ {
+ my $version = `$file --version`;
+ return 1 if ($version =~ m/.*\(GNU .*\).*/);
+ }
+ return 0;
+}
+
+sub GenerateHeaders
+{
+ my $EXTRACT = $ENV{"INTLTOOL_EXTRACT"} || "intltool-extract";
## Generate the .h header files, so we can allow glade and
## xml translation support
- if (! -x "$EXTRACT")
+ if (! isProgramInPath ("$EXTRACT"))
{
print STDERR "\n *** The intltool-extract script wasn't found!"
."\n *** Without it, intltool-update can not generate files.\n";
@@ -611,13 +653,13 @@
#
sub GeneratePOTemplate
{
- my $XGETTEXT = $ENV{"XGETTEXT"} || "@INTLTOOL_XGETTEXT@";
+ my $XGETTEXT = $ENV{"XGETTEXT"} || "xgettext";
my $XGETTEXT_ARGS = $ENV{"XGETTEXT_ARGS"} || '';
chomp $XGETTEXT;
- if (! -x $XGETTEXT)
+ if (! isGNUGettextTool ("$XGETTEXT"))
{
- print STDERR " *** xgettext is not found on this system!\n".
+ print STDERR " *** GNU xgettext is not found on this system!\n".
" *** Without it, intltool-update can not extract strings.\n";
exit;
}
@@ -671,12 +713,8 @@
}
else
{
- if ($SRCDIR eq ".") {
- print OUTFILE "../$_\n";
- } else {
- print OUTFILE "$SRCDIR/../$_\n";
- }
- $gettext_code = &TextFile_DetermineEncoding ("../$_") if ($gettext_support_nonascii and not defined $forced_gettext_code);
+ print OUTFILE "$SRCDIR/../$_\n";
+ $gettext_code = &TextFile_DetermineEncoding ("$SRCDIR/../$_") if ($gettext_support_nonascii and not defined $forced_gettext_code);
}
next if (! $gettext_support_nonascii);
@@ -717,7 +755,23 @@
unlink "$MODULE.pot";
my @xgettext_argument=("$XGETTEXT",
"--add-comments",
- "--directory\=\.",
+ "--directory\=.",
+ "--default-domain\=$MODULE",
+ "--flag\=g_strdup_printf:1:c-format",
+ "--flag\=g_string_printf:2:c-format",
+ "--flag\=g_string_append_printf:2:c-format",
+ "--flag\=g_error_new:3:c-format",
+ "--flag\=g_set_error:4:c-format",
+ "--flag\=g_markup_printf_escaped:1:c-format",
+ "--flag\=g_log:3:c-format",
+ "--flag\=g_print:1:c-format",
+ "--flag\=g_printerr:1:c-format",
+ "--flag\=g_printf:1:c-format",
+ "--flag\=g_fprintf:2:c-format",
+ "--flag\=g_sprintf:2:c-format",
+ "--flag\=g_snprintf:3:c-format",
+ "--flag\=g_scanner_error:2:c-format",
+ "--flag\=g_scanner_warn:2:c-format",
"--output\=$MODULE\.pot",
"--files-from\=\.\/POTFILES\.in\.temp");
my $XGETTEXT_KEYWORDS = &FindPOTKeywords;
@@ -784,9 +838,16 @@
{
-f "$MODULE.pot" or die "$PROGRAM: $MODULE.pot does not exist.\n";
- my $MSGMERGE = $ENV{"MSGMERGE"} || "@INTLTOOL_MSGMERGE@";
+ my $MSGMERGE = $ENV{"MSGMERGE"} || "msgmerge";
my ($lang, $outfile) = @_;
+ if (! isGNUGettextTool ("$MSGMERGE"))
+ {
+ print STDERR " *** GNU msgmerge is not found on this system!\n".
+ " *** Without it, intltool-update can not extract strings.\n";
+ exit;
+ }
+
print "Merging $SRCDIR/$lang.po with $MODULE.pot..." if $VERBOSE;
my $infile = "$SRCDIR/$lang.po";
@@ -827,7 +888,14 @@
sub Console_Write_TranslationStatus
{
my ($lang, $output_file) = @_;
- my $MSGFMT = $ENV{"MSGFMT"} || "@INTLTOOL_MSGFMT@";
+ my $MSGFMT = $ENV{"MSGFMT"} || "msgfmt";
+
+ if (! isGNUGettextTool ("$MSGFMT"))
+ {
+ print STDERR " *** GNU msgfmt is not found on this system!\n".
+ " *** Without it, intltool-update can not extract strings.\n";
+ exit;
+ }
$output_file = "$SRCDIR/$lang.po" if ($output_file eq "");
@@ -836,7 +904,14 @@
sub Console_Write_CoverageReport
{
- my $MSGFMT = $ENV{"MSGFMT"} || "@INTLTOOL_MSGFMT@";
+ my $MSGFMT = $ENV{"MSGFMT"} || "msgfmt";
+
+ if (! isGNUGettextTool ("$MSGFMT"))
+ {
+ print STDERR " *** GNU msgfmt is not found on this system!\n".
+ " *** Without it, intltool-update can not extract strings.\n";
+ exit;
+ }
&GatherPOFiles;
@@ -924,13 +999,13 @@
$conf_in || die "Cannot find top_builddir in Makevars.";
}
- elsif (-f "../configure.ac")
+ elsif (-f "$SRCDIR/../configure.ac")
{
- $conf_in = "../configure.ac";
+ $conf_in = "$SRCDIR/../configure.ac";
}
- elsif (-f "../configure.in")
+ elsif (-f "$SRCDIR/../configure.in")
{
- $conf_in = "../configure.in";
+ $conf_in = "$SRCDIR/../configure.in";
}
else
{
|