--- 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;
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;
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 ()
+ {
+ 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*$)/, ;
@@ -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 ()
{
@@ -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
{