2
# -*- Mode: perl; indent-tabs-mode: nil; c-basic-offset: 4 -*-
5
# The Intltool Message Updater
7
# Copyright (C) 2000-2003 Free Software Foundation.
9
# Intltool is free software; you can redistribute it and/or
10
# modify it under the terms of the GNU General Public License
11
# version 2 published by the Free Software Foundation.
13
# Intltool is distributed in the hope that it will be useful,
14
# but WITHOUT ANY WARRANTY; without even the implied warranty of
15
# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
16
# General Public License for more details.
18
# You should have received a copy of the GNU General Public License
19
# along with this program; if not, write to the Free Software
20
# Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA.
22
# As a special exception to the GNU General Public License, if you
23
# distribute this file as part of a program that contains a
24
# configuration script generated by Autoconf, you may include it under
25
# the same distribution terms that you use for the rest of that program.
27
# Authors: Kenneth Christiansen <kenneth@gnu.org>
29
# Darin Adler <darin@bentspoon.com>
31
## Release information
32
my $PROGRAM = "intltool-update";
33
my $VERSION = "0.34.1";
34
my $PACKAGE = "intltool";
43
## Scalars used by the option stuff
52
my $GETTEXT_PACKAGE = "";
57
my %po_files_by_lang = ();
59
# Regular expressions to categorize file types.
60
# FIXME: Please check if the following is correct
63
"xml(?:\\.in)*|". # http://www.w3.org/XML/ (Note: .in is not required)
64
"ui|". # Bonobo specific - User Interface desc. files
66
"glade2?(?:\\.in)*|". # Glade specific - User Interface desc. files (Note: .in is not required)
67
"scm(?:\\.in)*|". # ? (Note: .in is not required)
68
"oaf(?:\\.in)+|". # DEPRECATED: Replaces by Bonobo .server files
70
"server(?:\\.in)+|". # Bonobo specific
71
"sheet(?:\\.in)+|". # ?
72
"schemas(?:\\.in)+|". # GConf specific
73
"pong(?:\\.in)+|". # DEPRECATED: PONG is not used [by GNOME] any longer.
74
"kbd(?:\\.in)+"; # GOK specific.
77
"icon(?:\\.in)+|". # http://www.freedesktop.org/Standards/icon-theme-spec
78
"desktop(?:\\.in)+|". # http://www.freedesktop.org/Standards/menu-spec
79
"caves(?:\\.in)+|". # GNOME Games specific
80
"directory(?:\\.in)+|". # http://www.freedesktop.org/Standards/menu-spec
81
"soundlist(?:\\.in)+|". # GNOME specific
82
"keys(?:\\.in)+|". # GNOME Mime database specific
83
"theme(?:\\.in)+"; # http://www.freedesktop.org/Standards/icon-theme-spec
85
my $buildin_gettext_support =
86
"c|y|cs|cc|cpp|c\\+\\+|h|hh|gob|py";
88
## Always flush buffer when printing
91
## Sometimes the source tree will be rooted somewhere else.
95
$SRCDIR = $ENV{"srcdir"} if $ENV{"srcdir"};
96
$POTFILES_in = "<$SRCDIR/POTFILES.in";
98
my $devnull = ($^O eq 'MSWin32' ? 'NUL:' : '/dev/null');
103
"help" => \$HELP_ARG,
104
"version" => \$VERSION_ARG,
105
"dist|d" => \$DIST_ARG,
106
"pot|p" => \$POT_ARG,
107
"headers|s" => \$HEADERS_ARG,
108
"maintain|m" => \$MAINTAIN_ARG,
109
"report|r" => \$REPORT_ARG,
110
"verbose|x" => \$VERBOSE,
111
"gettext-package|g=s" => \$GETTEXT_PACKAGE,
112
"output-file|o=s" => \$OUTPUT_FILE,
113
) or &Console_WriteError_InvalidOption;
115
&Console_Write_IntltoolHelp if $HELP_ARG;
116
&Console_Write_IntltoolVersion if $VERSION_ARG;
118
my $arg_count = ($DIST_ARG > 0)
121
+ ($MAINTAIN_ARG > 0)
124
&Console_Write_IntltoolHelp if $arg_count > 1;
126
# --version and --help don't require a module name
127
my $MODULE = $GETTEXT_PACKAGE || &FindPackageName;
138
elsif ($MAINTAIN_ARG)
146
&Console_Write_CoverageReport;
148
elsif ((defined $ARGV[0]) && $ARGV[0] =~ /^[a-z]/)
152
## Report error if the language file supplied
153
## to the command line is non-existent
154
&Console_WriteError_NotExisting("$SRCDIR/$lang.po")
155
if ! -s "$SRCDIR/$lang.po";
159
print "Working, please wait..." if $VERBOSE;
163
&POFile_Update ($lang, $OUTPUT_FILE);
164
&Console_Write_TranslationStatus ($lang, $OUTPUT_FILE);
168
&Console_Write_IntltoolHelp;
175
sub Console_Write_IntltoolVersion
178
${PROGRAM} (${PACKAGE}) $VERSION
179
Written by Kenneth Christiansen, Maciej Stachowiak, and Darin Adler.
181
Copyright (C) 2000-2003 Free Software Foundation, Inc.
182
This is free software; see the source for copying conditions. There is NO
183
warranty; not even for MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.
188
sub Console_Write_IntltoolHelp
191
Usage: ${PROGRAM} [OPTION]... LANGCODE
192
Updates PO template files and merge them with the translations.
194
Mode of operation (only one is allowed):
195
-p, --pot generate the PO template only
196
-s, --headers generate the header files in POTFILES.in
197
-m, --maintain search for left out files from POTFILES.in
198
-r, --report display a status report for the module
199
-d, --dist merge LANGCODE.po with existing PO template
202
-g, --gettext-package=NAME override PO template name, useful with --pot
203
-o, --output-file=FILE write merged translation to FILE
204
-x, --verbose display lots of feedback
205
--help display this help and exit
206
--version output version information and exit
209
${PROGRAM} --pot just create a new PO template
210
${PROGRAM} xy create new PO template and merge xy.po with it
212
Report bugs to http://bugzilla.gnome.org/ (product name "$PACKAGE")
213
or send email to <xml-i18n-tools\@gnome.org>.
221
my $ret = `echo "$str"`;
223
$ret =~ s/\n$//; # do we need the "s" flag?
228
sub POFile_DetermineType ($)
233
my $xml_regex = "(?:" . $xml_support . ")";
234
my $ini_regex = "(?:" . $ini_support . ")";
235
my $buildin_regex = "(?:" . $buildin_gettext_support . ")";
237
if ($type =~ /\[type: gettext\/([^\]].*)]/)
241
elsif ($type =~ /schemas(\.in)+$/)
243
$gettext_type="schemas";
245
elsif ($type =~ /glade2?(\.in)*$/)
247
$gettext_type="glade";
249
elsif ($type =~ /scm(\.in)*$/)
251
$gettext_type="scheme";
253
elsif ($type =~ /keys(\.in)+$/)
255
$gettext_type="keys";
260
elsif ($type =~ /$xml_regex$/)
264
elsif ($type =~ /$ini_regex$/)
268
elsif ($type =~ /$buildin_regex$/)
270
$gettext_type="buildin";
274
$gettext_type="unknown";
277
return "gettext\/$gettext_type";
280
sub TextFile_DetermineEncoding ($)
282
my $gettext_code="ASCII"; # All files are ASCII by default
283
my $filetype=`file $_ | cut -d ' ' -f 2`;
287
if ($filetype =~ /^(ISO|UTF)/)
289
chomp ($gettext_code = $filetype);
291
elsif ($filetype =~ /^XML/)
293
$gettext_code="UTF-8"; # We asume that .glade and other .xml files are UTF-8
297
return $gettext_code;
300
sub isNotValidMissing
304
return if $file =~ /^\{arch\}\/.*$/;
305
return if $file =~ /^$varhash{"PACKAGE"}-$varhash{"VERSION"}\/.*$/;
312
@buf_i18n_xml_unmarked,
315
@buf_potfiles_ignore,
317
@buf_allfiles_sorted,
321
## Search and find all translatable files
323
push @buf_i18n_plain, "$File::Find::name" if /\.($buildin_gettext_support)$/;
324
push @buf_i18n_xml, "$File::Find::name" if /\.($xml_support)$/;
325
push @buf_i18n_ini, "$File::Find::name" if /\.($ini_support)$/;
326
push @buf_i18n_xml_unmarked, "$File::Find::name" if /\.(schemas(\.in)+)$/;
330
open POTFILES, $POTFILES_in or die "$PROGRAM: there's no POTFILES.in!\n";
331
@buf_potfiles = grep !/^(#|\s*$)/, <POTFILES>;
334
foreach (@buf_potfiles) {
338
print "Searching for missing translatable files...\n" if $VERBOSE;
340
## Check if we should ignore some found files, when
341
## comparing with POTFILES.in
342
foreach my $ignore ("POTFILES.skip", "POTFILES.ignore")
344
(-s $ignore) or next;
346
if ("$ignore" eq "POTFILES.ignore")
348
print "The usage of POTFILES.ignore is deprecated. Please consider moving the\n".
349
"content of this file to POTFILES.skip.\n";
352
print "Found $ignore: Ignoring files...\n" if $VERBOSE;
353
open FILE, "<$ignore" or die "ERROR: Failed to open $ignore!\n";
357
push @buf_potfiles_ignore, $_ unless /^(#|\s*$)/;
361
@buf_potfiles = (@buf_potfiles_ignore, @buf_potfiles);
364
foreach my $file (@buf_i18n_plain)
372
# Handle continued multi-line comment.
375
next unless s-.*\*/--;
379
# Handle continued macro.
382
$in_macro = 0 unless /\\$/;
386
# Handle start of macro (or any preprocessor directive).
389
$in_macro = 1 if /^([^\\]|\\.)*\\$/;
393
# Handle comments and quoted text.
394
while (m-(/\*|//|\'|\")-) # \' and \" keep emacs perl mode happy
405
elsif ($match eq "//")
411
if (!s-$match([^\\]|\\.)*?$match-QUOTEDTEXT-)
413
warn "mismatched quotes at line $. in $file\n";
419
if (/\.GetString ?\(QUOTEDTEXT/)
421
if (defined isNotValidMissing (unpack("x3 A*", $file))) {
422
## Remove the first 3 chars and add newline
423
push @buf_allfiles, unpack("x3 A*", $file) . "\n";
430
if (defined isNotValidMissing (unpack("x3 A*", $file))) {
431
## Remove the first 3 chars and add newline
432
push @buf_allfiles, unpack("x3 A*", $file) . "\n";
440
foreach my $file (@buf_i18n_xml)
446
# FIXME: share the pattern matching code with intltool-extract
447
if (/\s_[-A-Za-z0-9._:]+\s*=\s*\"([^"]+)\"/ || /<_[^>]+>/ || /translatable=\"yes\"/)
449
if (defined isNotValidMissing (unpack("x3 A*", $file))) {
450
push @buf_allfiles, unpack("x3 A*", $file) . "\n";
458
foreach my $file (@buf_i18n_ini)
465
if (defined isNotValidMissing (unpack("x3 A*", $file))) {
466
push @buf_allfiles, unpack("x3 A*", $file) . "\n";
474
foreach my $file (@buf_i18n_xml_unmarked)
476
if (defined isNotValidMissing (unpack("x3 A*", $file))) {
477
push @buf_allfiles, unpack("x3 A*", $file) . "\n";
482
@buf_allfiles_sorted = sort (@buf_allfiles);
483
@buf_potfiles_sorted = sort (@buf_potfiles);
486
foreach (@buf_potfiles_sorted)
493
foreach (@buf_allfiles_sorted)
495
if (!exists($in2{$_}))
501
my @buf_potfiles_notexist;
503
foreach (@buf_potfiles_sorted)
505
chomp (my $dummy = $_);
506
if ("$dummy" ne "" and ! -f "../$dummy")
508
push @buf_potfiles_notexist, $_;
512
## Save file with information about the files missing
513
## if any, and give information about this procedure.
514
if (@result + @buf_potfiles_notexist > 0)
518
print "\n" if $VERBOSE;
520
open OUT, ">missing";
523
warn "\e[1mThe following files contain translations and are currently not in use. Please\e[0m\n".
524
"\e[1mconsider adding these to the POTFILES.in file, located in the po/ directory.\e[0m\n\n";
525
print STDERR @result, "\n";
526
warn "If some of these files are left out on purpose then please add them to\n".
527
"POTFILES.skip instead of POTFILES.in. A file \e[1m'missing'\e[0m containing this list\n".
528
"of left out files has been written in the current directory.\n";
530
if (@buf_potfiles_notexist)
533
open OUT, ">notexist";
534
print OUT @buf_potfiles_notexist;
536
warn "\n" if ($VERBOSE or @result);
537
warn "\e[1mThe following files do not exist anymore:\e[0m\n\n";
538
warn @buf_potfiles_notexist, "\n";
539
warn "Please remove them from POTFILES.in or POTFILES.skip. A file \e[1m'notexist'\e[0m\n".
540
"containing this list of absent files has been written in the current directory.\n";
544
## If there is nothing to complain about, notify the user
546
print "\nAll files containing translations are present in POTFILES.in.\n" if $VERBOSE;
550
sub Console_WriteError_InvalidOption
552
## Handle invalid arguments
553
print STDERR "Try `${PROGRAM} --help' for more information.\n";
559
my $EXTRACT = "@INTLTOOL_EXTRACT@";
562
$EXTRACT = $ENV{"INTLTOOL_EXTRACT"} if $ENV{"INTLTOOL_EXTRACT"};
564
## Generate the .h header files, so we can allow glade and
565
## xml translation support
568
print STDERR "\n *** The intltool-extract script wasn't found!"
569
."\n *** Without it, intltool-update can not generate files.\n";
574
open (FILE, $POTFILES_in) or die "$PROGRAM: POTFILES.in not found.\n";
579
next if /^\[\s*encoding/;
581
## Find xml files in POTFILES.in and generate the
582
## files with help from the extract script
584
my $gettext_type= &POFile_DetermineType ($1);
586
if (/\.($xml_support|$ini_support)$/ || /^\[/)
590
my $filename = "../$_";
594
system ($EXTRACT, "--update", "--srcdir=$SRCDIR",
595
"--type=$gettext_type", $filename);
599
system ($EXTRACT, "--update", "--type=$gettext_type",
600
"--srcdir=$SRCDIR", "--quiet", $filename);
609
# Generate .pot file from POTFILES.in
611
sub GeneratePOTemplate
613
my $XGETTEXT = $ENV{"XGETTEXT"} || "/home/gnome/bin/xgettext";
614
my $XGETTEXT_ARGS = $ENV{"XGETTEXT_ARGS"} || '';
619
print STDERR " *** xgettext is not found on this system!\n".
620
" *** Without it, intltool-update can not extract strings.\n";
624
print "Building $MODULE.pot...\n" if $VERBOSE;
626
open INFILE, $POTFILES_in;
627
unlink "POTFILES.in.temp";
628
open OUTFILE, ">POTFILES.in.temp" or die("Cannot open POTFILES.in.temp for writing");
630
my $gettext_support_nonascii = 0;
632
# checks for GNU gettext >= 0.12
633
my $dummy = `$XGETTEXT --version --from-code=UTF-8 >$devnull 2>$devnull`;
636
$gettext_support_nonascii = 1;
640
# urge everybody to upgrade gettext
641
print STDERR "WARNING: This version of gettext does not support extracting non-ASCII\n".
642
" strings. That means you should install a version of gettext\n".
643
" that supports non-ASCII strings (such as GNU gettext >= 0.12),\n".
644
" or have to let non-ASCII strings untranslated. (If there is any)\n";
647
my $encoding = "ASCII";
648
my $forced_gettext_code;
650
my $encoding_problem_is_reported = 0;
654
next if (/^#/ or /^\s*$/);
660
if (/^\[\s*encoding:\s*(.*)\s*\]/)
662
$forced_gettext_code=$1;
664
elsif (/\.($xml_support|$ini_support)$/ || /^\[/)
667
print OUTFILE "../$_.h\n";
668
push @temp_headers, "../$_.h";
669
$gettext_code = &TextFile_DetermineEncoding ("../$_.h") if ($gettext_support_nonascii and not defined $forced_gettext_code);
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);
681
next if (! $gettext_support_nonascii);
683
if (defined $forced_gettext_code)
685
$encoding=$forced_gettext_code;
687
elsif (defined $gettext_code and "$encoding" ne "$gettext_code")
689
if ($encoding eq "ASCII")
691
$encoding=$gettext_code;
693
elsif ($gettext_code ne "ASCII")
695
# Only report once because the message is quite long
696
if (! $encoding_problem_is_reported)
698
print STDERR "WARNING: You should use the same file encoding for all your project files,\n".
699
" but $PROGRAM thinks that most of the source files are in\n".
700
" $encoding encoding, while \"$_\" is (likely) in\n".
701
" $gettext_code encoding. If you are sure that all translatable strings\n".
702
" are in same encoding (say UTF-8), please \e[1m*prepend*\e[0m the following\n".
703
" line to POTFILES.in:\n\n".
704
" [encoding: UTF-8]\n\n".
705
" and make sure that configure.in/ac checks for $PACKAGE >= 0.27 .\n".
706
"(such warning message will only be reported once.)\n";
707
$encoding_problem_is_reported = 1;
716
unlink "$MODULE.pot";
717
my @xgettext_argument=("$XGETTEXT",
720
"--output\=$MODULE\.pot",
721
"--files-from\=\.\/POTFILES\.in\.temp");
722
my $XGETTEXT_KEYWORDS = &FindPOTKeywords;
723
push @xgettext_argument, $XGETTEXT_KEYWORDS;
724
push @xgettext_argument, "--from-code\=$encoding" if ($gettext_support_nonascii);
725
push @xgettext_argument, $XGETTEXT_ARGS if $XGETTEXT_ARGS;
726
my $xgettext_command = join ' ', @xgettext_argument;
728
# intercept xgettext error message
729
print "Running $xgettext_command\n" if $VERBOSE;
730
my $xgettext_error_msg = `$xgettext_command 2>\&1`;
731
my $command_failed = $?;
733
unlink "POTFILES.in.temp";
735
print "Removing generated header (.h) files..." if $VERBOSE;
736
unlink foreach (@temp_headers);
737
print "done.\n" if $VERBOSE;
739
if (! $command_failed)
741
if (! -e "$MODULE.pot")
743
print "None of the files in POTFILES.in contain strings marked for translation.\n" if $VERBOSE;
747
print "Wrote $MODULE.pot\n" if $VERBOSE;
752
if ($xgettext_error_msg =~ /--from-code/)
754
# replace non-ASCII error message with a more useful one.
755
print STDERR "ERROR: xgettext failed to generate PO template file because there is non-ASCII\n".
756
" string marked for translation. Please make sure that all strings marked\n".
757
" for translation are in uniform encoding (say UTF-8), then \e[1m*prepend*\e[0m the\n".
758
" following line to POTFILES.in and rerun $PROGRAM:\n\n".
759
" [encoding: UTF-8]\n\n";
763
print STDERR "$xgettext_error_msg";
764
if (-e "$MODULE.pot")
767
print STDERR "ERROR: xgettext failed but still managed to generate PO template file.\n".
768
" Please consult error message above if there is any.\n";
772
print STDERR "ERROR: xgettext failed to generate PO template file. Please consult\n".
773
" error message above if there is any.\n";
782
-f "$MODULE.pot" or die "$PROGRAM: $MODULE.pot does not exist.\n";
784
my $MSGMERGE = $ENV{"MSGMERGE"} || "/home/gnome/bin/msgmerge";
785
my ($lang, $outfile) = @_;
787
print "Merging $SRCDIR/$lang.po with $MODULE.pot..." if $VERBOSE;
789
my $infile = "$SRCDIR/$lang.po";
790
$outfile = "$SRCDIR/$lang.po" if ($outfile eq "");
792
# I think msgmerge won't overwrite old file if merge is not successful
793
system ("$MSGMERGE", "-o", $outfile, $infile, "$MODULE.pot");
796
sub Console_WriteError_NotExisting
800
## Report error if supplied language file is non-existing
801
print STDERR "$PROGRAM: $file does not exist!\n";
802
print STDERR "Try '$PROGRAM --help' for more information.\n";
808
my @po_files = glob ("./*.po");
810
@languages = map (&POFile_GetLanguage, @po_files);
812
foreach my $lang (@languages)
814
$po_files_by_lang{$lang} = shift (@po_files);
818
sub POFile_GetLanguage ($)
820
s/^(.*\/)?(.+)\.po$/$2/;
824
sub Console_Write_TranslationStatus
826
my ($lang, $output_file) = @_;
827
my $MSGFMT = $ENV{"MSGFMT"} || "/home/gnome/bin/msgfmt";
829
$output_file = "$SRCDIR/$lang.po" if ($output_file eq "");
831
system ("$MSGFMT", "-o", "$devnull", "--verbose", $output_file);
834
sub Console_Write_CoverageReport
836
my $MSGFMT = $ENV{"MSGFMT"} || "/home/gnome/bin/msgfmt";
840
foreach my $lang (@languages)
843
&POFile_Update ($lang, "");
846
print "\n\n * Current translation support in $MODULE \n\n";
848
foreach my $lang (@languages)
851
system ("$MSGFMT", "-o", "$devnull", "--verbose", "$SRCDIR/$lang.po");
855
sub SubstituteVariable
859
# always need to rewind file whenever it has been accessed
862
# cache each variable. varhash is global to we can add
863
# variables elsewhere.
868
($varhash{$1} = $2) =~ s/^["'](.*)["']$/$1/;
872
if ($str =~ /^(.*)\${?([A-Z_]+)}?(.*)$/)
876
my $sub = $varhash{$2};
878
return SubstituteVariable ("$untouched$sub$rest");
881
# We're using Perl backticks ` and "echo -n" here in order to
882
# expand any shell escapes (such as backticks themselves) in every variable
883
return echo_n ($str);
888
my $base_dirname = getcwd();
889
$base_dirname =~ s@.*/@@;
891
my ($conf_in, $src_dir);
893
if ($base_dirname =~ /^po(-.+)?$/)
900
open (IN, "<Makevars") || die "can't open Makevars: $!";
904
if (/^top_builddir[ \t]*=/)
907
$src_dir =~ s/^top_builddir[ \t]*=[ \t]*([^ \t\n\r]*)/$1/;
910
if (-f "$src_dir" . "/configure.ac") {
911
$conf_in = "$src_dir" . "/configure.ac" . "\n";
913
$conf_in = "$src_dir" . "/configure.in" . "\n";
920
$conf_in || die "Cannot find top_builddir in Makevars.";
922
elsif (-f "../configure.ac")
924
$conf_in = "../configure.ac";
926
elsif (-f "../configure.in")
928
$conf_in = "../configure.in";
935
open (IN, "<Makefile") || return;
939
if (/^top_srcdir[ \t]*=/)
942
$src_dir =~ s/^top_srcdir[ \t]*=[ \t]*([^ \t\n\r]*)/$1/;
945
$conf_in = "$src_dir" . "/configure.in" . "\n";
952
$conf_in || die "Cannot find top_srcdir in Makefile.";
955
open (CONF, "<$conf_in");
959
print STDERR "$PROGRAM: Unable to proceed.\n" .
960
"Make sure to run this script inside the po directory.\n";
968
my $domain = &FindMakevarsDomain;
969
my $name = $domain || "untitled";
975
open (IN, "<&CONF") || return $name;
977
local $/; # slurp mode
982
# priority for getting package name:
984
# 2. first argument of AC_INIT (with >= 2 arguments)
985
# 3. first argument of AM_INIT_AUTOMAKE (with >= 2 argument)
987
# /^AM_INIT_AUTOMAKE\([\s\[]*([^,\)\s\]]+)/m
988
# the \s makes this not work, why?
989
if ($conf_source =~ /^AM_INIT_AUTOMAKE\(([^,\)]+),([^,\)]+)/m)
991
($name, $version) = ($1, $2);
992
$name =~ s/[\[\]\s]//g;
993
$version =~ s/[\[\]\s]//g;
994
$varhash{"PACKAGE_NAME"} = $name;
995
$varhash{"PACKAGE"} = $name;
996
$varhash{"PACKAGE_VERSION"} = $version;
997
$varhash{"VERSION"} = $version;
1000
if ($conf_source =~ /^AC_INIT\(([^,\)]+),([^,\)]+)/m)
1002
($name, $version) = ($1, $2);
1003
$name =~ s/[\[\]\s]//g;
1004
$version =~ s/[\[\]\s]//g;
1005
$varhash{"PACKAGE_NAME"} = $name;
1006
$varhash{"PACKAGE"} = $name;
1007
$varhash{"PACKAGE_VERSION"} = $version;
1008
$varhash{"VERSION"} = $version;
1011
# \s makes this not work, why?
1012
$name = $1 if $conf_source =~ /^GETTEXT_PACKAGE=\[?([^\n\]]+)/m;
1014
# m4 macros AC_PACKAGE_NAME, AC_PACKAGE_VERSION etc. have same value
1015
# as corresponding $PACKAGE_NAME, $PACKAGE_VERSION etc. shell variables.
1016
$name =~ s/\bAC_PACKAGE_/\$PACKAGE_/g;
1018
$name = $domain if $domain;
1020
$name = SubstituteVariable ($name);
1021
$name =~ s/^["'](.*)["']$/$1/;
1023
return $name if $name;
1030
my $keywords = "--keyword\=\_ --keyword\=N\_ --keyword\=U\_ --keyword\=Q\_";
1031
my $varname = "XGETTEXT_OPTIONS";
1034
open (IN, "<Makevars") || (open(IN, "<Makefile.in.in") && ($varname = "XGETTEXT_KEYWORDS")) || return $keywords;
1036
local $/; # slurp mode
1037
$make_source = <IN>;
1041
$keywords = $1 if $make_source =~ /^$varname[ ]*=\[?([^\n\]]+)/m;
1046
sub FindMakevarsDomain
1050
my $makevars_source; {
1052
open (IN, "<Makevars") || return $domain;
1054
local $/; # slurp mode
1055
$makevars_source = <IN>;
1059
$domain = $1 if $makevars_source =~ /^DOMAIN[ ]*=\[?([^\n\]\$]+)/m;
1060
$domain =~ s/^\s+//;
1061
$domain =~ s/\s+$//;