71
71
"sheet(?:\\.in)+|". # ?
72
72
"schemas(?:\\.in)+|". # GConf specific
73
73
"pong(?:\\.in)+|". # DEPRECATED: PONG is not used [by GNOME] any longer.
74
"kbd(?:\\.in)+"; # GOK specific.
74
"kbd(?:\\.in)+|". # GOK specific.
75
"policy(?:\\.in)+"; # PolicyKit files
77
78
"icon(?:\\.in)+|". # http://www.freedesktop.org/Standards/icon-theme-spec
80
81
"directory(?:\\.in)+|". # http://www.freedesktop.org/Standards/menu-spec
81
82
"soundlist(?:\\.in)+|". # GNOME specific
82
83
"keys(?:\\.in)+|". # GNOME Mime database specific
83
"theme(?:\\.in)+"; # http://www.freedesktop.org/Standards/icon-theme-spec
84
"theme(?:\\.in)+|". # http://www.freedesktop.org/Standards/icon-theme-spec
85
"service(?:\\.in)+"; # DBus specific
85
87
my $buildin_gettext_support =
86
88
"c|y|cs|cc|cpp|c\\+\\+|h|hh|gob|py";
91
93
## Sometimes the source tree will be rooted somewhere else.
94
my $SRCDIR = $ENV{"srcdir"} || ".";
95
$SRCDIR = $ENV{"srcdir"} if $ENV{"srcdir"};
96
97
$POTFILES_in = "<$SRCDIR/POTFILES.in";
98
99
my $devnull = ($^O eq 'MSWin32' ? 'NUL:' : '/dev/null');
124
125
&Console_Write_IntltoolHelp if $arg_count > 1;
127
my $PKGNAME = FindPackageName ();
126
129
# --version and --help don't require a module name
127
my $MODULE = $GETTEXT_PACKAGE || &FindPackageName;
130
my $MODULE = $GETTEXT_PACKAGE || $PKGNAME || "unknown";
325
329
push @buf_i18n_ini, "$File::Find::name" if /\.($ini_support)$/;
326
330
push @buf_i18n_xml_unmarked, "$File::Find::name" if /\.(schemas(\.in)+)$/;
333
push @buf_i18n_plain, "$File::Find::name" if /\.($buildin_gettext_support)$/;
334
push @buf_i18n_xml, "$File::Find::name" if /\.($xml_support)$/;
335
push @buf_i18n_ini, "$File::Find::name" if /\.($ini_support)$/;
336
push @buf_i18n_xml_unmarked, "$File::Find::name" if /\.(schemas(\.in)+)$/;
337
}, "$SRCDIR/.." if "$SRCDIR" ne ".";
330
339
open POTFILES, $POTFILES_in or die "$PROGRAM: there's no POTFILES.in!\n";
331
340
@buf_potfiles = grep !/^(#|\s*$)/, <POTFILES>;
341
350
## comparing with POTFILES.in
342
351
foreach my $ignore ("POTFILES.skip", "POTFILES.ignore")
344
(-s $ignore) or next;
353
(-s "$SRCDIR/$ignore") or next;
346
355
if ("$ignore" eq "POTFILES.ignore")
419
if (/\.GetString ?\(QUOTEDTEXT/)
428
if (/\w\.GetString *\(QUOTEDTEXT/)
421
430
if (defined isNotValidMissing (unpack("x3 A*", $file))) {
422
431
## Remove the first 3 chars and add newline
437
## C_ N_ Q_ and _ are the macros defined in gi8n.h
438
if (/[CNQ]?_ *\(QUOTEDTEXT/)
430
440
if (defined isNotValidMissing (unpack("x3 A*", $file))) {
431
441
## Remove the first 3 chars and add newline
503
529
foreach (@buf_potfiles_sorted)
505
531
chomp (my $dummy = $_);
506
if ("$dummy" ne "" and ! -f "../$dummy")
532
if ("$dummy" ne "" and !(-f "$SRCDIR/../$dummy" or -f "../$dummy"))
508
534
push @buf_potfiles_notexist, $_;
536
562
warn "\n" if ($VERBOSE or @result);
537
563
warn "\e[1mThe following files do not exist anymore:\e[0m\n\n";
538
564
warn @buf_potfiles_notexist, "\n";
539
warn "Please remove them from POTFILES.in or POTFILES.skip. A file \e[1m'notexist'\e[0m\n".
565
warn "Please remove them from POTFILES.in. A file \e[1m'notexist'\e[0m\n".
540
566
"containing this list of absent files has been written in the current directory.\n";
586
# If either a file exists, or when run it returns 0 exit status
587
return 1 if ((-x $file) or (system("$file --version >$devnull") == 0));
594
# Check that we are using GNU gettext tools
595
if (isProgramInPath ($file))
597
my $version = `$file --version`;
598
return 1 if ($version =~ m/.*\(GNU .*\).*/);
557
603
sub GenerateHeaders
559
my $EXTRACT = "@INTLTOOL_EXTRACT@";
562
$EXTRACT = $ENV{"INTLTOOL_EXTRACT"} if $ENV{"INTLTOOL_EXTRACT"};
605
my $EXTRACT = $ENV{"INTLTOOL_EXTRACT"} || "intltool-extract";
564
607
## Generate the .h header files, so we can allow glade and
565
608
## xml translation support
609
if (! isProgramInPath ("$EXTRACT"))
568
611
print STDERR "\n *** The intltool-extract script wasn't found!"
569
612
."\n *** Without it, intltool-update can not generate files.\n";
611
654
sub GeneratePOTemplate
613
my $XGETTEXT = $ENV{"XGETTEXT"} || "/usr/bin/xgettext";
656
my $XGETTEXT = $ENV{"XGETTEXT"} || "xgettext";
614
657
my $XGETTEXT_ARGS = $ENV{"XGETTEXT_ARGS"} || '';
660
if (! isGNUGettextTool ("$XGETTEXT"))
619
print STDERR " *** xgettext is not found on this system!\n".
662
print STDERR " *** GNU xgettext is not found on this system!\n".
620
663
" *** Without it, intltool-update can not extract strings.\n";
673
if ($SRCDIR eq ".") {
674
print OUTFILE "../$_\n";
676
print OUTFILE "$SRCDIR/../$_\n";
678
$gettext_code = &TextFile_DetermineEncoding ("../$_") if ($gettext_support_nonascii and not defined $forced_gettext_code);
716
print OUTFILE "$SRCDIR/../$_\n";
717
$gettext_code = &TextFile_DetermineEncoding ("$SRCDIR/../$_") if ($gettext_support_nonascii and not defined $forced_gettext_code);
681
720
next if (! $gettext_support_nonascii);
716
755
unlink "$MODULE.pot";
717
756
my @xgettext_argument=("$XGETTEXT",
718
757
"--add-comments",
759
"--default-domain\=$MODULE",
760
"--flag\=g_strdup_printf:1:c-format",
761
"--flag\=g_string_printf:2:c-format",
762
"--flag\=g_string_append_printf:2:c-format",
763
"--flag\=g_error_new:3:c-format",
764
"--flag\=g_set_error:4:c-format",
765
"--flag\=g_markup_printf_escaped:1:c-format",
766
"--flag\=g_log:3:c-format",
767
"--flag\=g_print:1:c-format",
768
"--flag\=g_printerr:1:c-format",
769
"--flag\=g_printf:1:c-format",
770
"--flag\=g_fprintf:2:c-format",
771
"--flag\=g_sprintf:2:c-format",
772
"--flag\=g_snprintf:3:c-format",
773
"--flag\=g_scanner_error:2:c-format",
774
"--flag\=g_scanner_warn:2:c-format",
720
775
"--output\=$MODULE\.pot",
721
776
"--files-from\=\.\/POTFILES\.in\.temp");
722
777
my $XGETTEXT_KEYWORDS = &FindPOTKeywords;
723
778
push @xgettext_argument, $XGETTEXT_KEYWORDS;
779
my $MSGID_BUGS_ADDRESS = &FindMakevarsBugAddress;
780
push @xgettext_argument, "--msgid-bugs-address\=\"$MSGID_BUGS_ADDRESS\"" if $MSGID_BUGS_ADDRESS;
724
781
push @xgettext_argument, "--from-code\=$encoding" if ($gettext_support_nonascii);
725
782
push @xgettext_argument, $XGETTEXT_ARGS if $XGETTEXT_ARGS;
726
783
my $xgettext_command = join ' ', @xgettext_argument;
782
839
-f "$MODULE.pot" or die "$PROGRAM: $MODULE.pot does not exist.\n";
784
my $MSGMERGE = $ENV{"MSGMERGE"} || "/usr/bin/msgmerge";
841
my $MSGMERGE = $ENV{"MSGMERGE"} || "msgmerge";
785
842
my ($lang, $outfile) = @_;
844
if (! isGNUGettextTool ("$MSGMERGE"))
846
print STDERR " *** GNU msgmerge is not found on this system!\n".
847
" *** Without it, intltool-update can not extract strings.\n";
787
851
print "Merging $SRCDIR/$lang.po with $MODULE.pot..." if $VERBOSE;
789
853
my $infile = "$SRCDIR/$lang.po";
824
888
sub Console_Write_TranslationStatus
826
890
my ($lang, $output_file) = @_;
827
my $MSGFMT = $ENV{"MSGFMT"} || "/usr/bin/msgfmt";
891
my $MSGFMT = $ENV{"MSGFMT"} || "msgfmt";
893
if (! isGNUGettextTool ("$MSGFMT"))
895
print STDERR " *** GNU msgfmt is not found on this system!\n".
896
" *** Without it, intltool-update can not extract strings.\n";
829
900
$output_file = "$SRCDIR/$lang.po" if ($output_file eq "");
834
905
sub Console_Write_CoverageReport
836
my $MSGFMT = $ENV{"MSGFMT"} || "/usr/bin/msgfmt";
907
my $MSGFMT = $ENV{"MSGFMT"} || "msgfmt";
909
if (! isGNUGettextTool ("$MSGFMT"))
911
print STDERR " *** GNU msgfmt is not found on this system!\n".
912
" *** Without it, intltool-update can not extract strings.\n";
840
918
foreach my $lang (@languages)
920
print STDERR "$lang: ";
843
921
&POFile_Update ($lang, "");
846
print "\n\n * Current translation support in $MODULE \n\n";
924
print STDERR "\n\n * Current translation support in $MODULE \n\n";
848
926
foreach my $lang (@languages)
928
print STDERR "$lang: ";
851
929
system ("$MSGFMT", "-o", "$devnull", "--verbose", "$SRCDIR/$lang.po");
920
1000
$conf_in || die "Cannot find top_builddir in Makevars.";
922
elsif (-f "../configure.ac")
1002
elsif (-f "$SRCDIR/../configure.ac")
924
$conf_in = "../configure.ac";
1004
$conf_in = "$SRCDIR/../configure.ac";
926
elsif (-f "../configure.in")
1006
elsif (-f "$SRCDIR/../configure.in")
928
$conf_in = "../configure.in";
1008
$conf_in = "$SRCDIR/../configure.in";
991
1071
($name, $version) = ($1, $2);
992
1072
$name =~ s/[\[\]\s]//g;
993
1073
$version =~ s/[\[\]\s]//g;
994
$varhash{"AC_PACKAGE_NAME"} = $name;
995
$varhash{"PACKAGE"} = $name;
996
$varhash{"AC_PACKAGE_VERSION"} = $version;
997
$varhash{"VERSION"} = $version;
1074
$varhash{"PACKAGE_NAME"} = $name if (not $name =~ /\${?AC_PACKAGE_NAME}?/);
1075
$varhash{"PACKAGE"} = $name if (not $name =~ /\${?PACKAGE}?/);
1076
$varhash{"PACKAGE_VERSION"} = $version if (not $name =~ /\${?AC_PACKAGE_VERSION}?/);
1077
$varhash{"VERSION"} = $version if (not $name =~ /\${?VERSION}?/);
1000
1080
if ($conf_source =~ /^AC_INIT\(([^,\)]+),([^,\)]+)/m)
1002
1082
($name, $version) = ($1, $2);
1003
1083
$name =~ s/[\[\]\s]//g;
1004
1084
$version =~ s/[\[\]\s]//g;
1005
$varhash{"AC_PACKAGE_NAME"} = $name;
1006
$varhash{"PACKAGE"} = $name;
1007
$varhash{"AC_PACKAGE_VERSION"} = $version;
1008
$varhash{"VERSION"} = $version;
1085
$varhash{"PACKAGE_NAME"} = $name if (not $name =~ /\${?AC_PACKAGE_NAME}?/);
1086
$varhash{"PACKAGE"} = $name if (not $name =~ /\${?PACKAGE}?/);
1087
$varhash{"PACKAGE_VERSION"} = $version if (not $name =~ /\${?AC_PACKAGE_VERSION}?/);
1088
$varhash{"VERSION"} = $version if (not $name =~ /\${?VERSION}?/);
1011
1091
# \s makes this not work, why?
1012
1092
$name = $1 if $conf_source =~ /^GETTEXT_PACKAGE=\[?([^\n\]]+)/m;
1014
# prepend '$' to auto* internal variables, usually they are
1015
# used in configure.in/ac without the '$'
1016
$name =~ s/AC_/\$AC_/g;
1017
$name =~ s/\$\$/\$/g;
1094
# m4 macros AC_PACKAGE_NAME, AC_PACKAGE_VERSION etc. have same value
1095
# as corresponding $PACKAGE_NAME, $PACKAGE_VERSION etc. shell variables.
1096
$name =~ s/\bAC_PACKAGE_/\$PACKAGE_/g;
1019
1098
$name = $domain if $domain;