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";
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";
101 "help" => \$HELP_ARG,
102 "version" => \$VERSION_ARG,
103 "dist|d" => \$DIST_ARG,
104 "pot|p" => \$POT_ARG,
105 "headers|s" => \$HEADERS_ARG,
106 "maintain|m" => \$MAINTAIN_ARG,
107 "report|r" => \$REPORT_ARG,
108 "verbose|x" => \$VERBOSE,
109 "gettext-package|g=s" => \$GETTEXT_PACKAGE,
110 "output-file|o=s" => \$OUTPUT_FILE,
111 ) or &Console_WriteError_InvalidOption;
113 &Console_Write_IntltoolHelp if $HELP_ARG;
114 &Console_Write_IntltoolVersion if $VERSION_ARG;
116 my $arg_count = ($DIST_ARG > 0)
119 + ($MAINTAIN_ARG > 0)
122 &Console_Write_IntltoolHelp if $arg_count > 1;
124 # --version and --help don't require a module name
125 my $MODULE = $GETTEXT_PACKAGE || &FindPackageName;
136 elsif ($MAINTAIN_ARG)
144 &Console_Write_CoverageReport;
146 elsif ((defined $ARGV[0]) && $ARGV[0] =~ /^[a-z]/)
150 ## Report error if the language file supplied
151 ## to the command line is non-existent
152 &Console_WriteError_NotExisting("$SRCDIR/$lang.po")
153 if ! -s "$SRCDIR/$lang.po";
157 print "Working, please wait..." if $VERBOSE;
161 &POFile_Update ($lang, $OUTPUT_FILE);
162 &Console_Write_TranslationStatus ($lang, $OUTPUT_FILE);
166 &Console_Write_IntltoolHelp;
173 sub Console_Write_IntltoolVersion
176 ${PROGRAM} (${PACKAGE}) $VERSION
177 Written by Kenneth Christiansen, Maciej Stachowiak, and Darin Adler.
179 Copyright (C) 2000-2003 Free Software Foundation, Inc.
180 This is free software; see the source for copying conditions. There is NO
181 warranty; not even for MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.
186 sub Console_Write_IntltoolHelp
189 Usage: ${PROGRAM} [OPTION]... LANGCODE
190 Updates PO template files and merge them with the translations.
192 Mode of operation (only one is allowed):
193 -p, --pot generate the PO template only
194 -s, --headers generate the header files in POTFILES.in
195 -m, --maintain search for left out files from POTFILES.in
196 -r, --report display a status report for the module
197 -d, --dist merge LANGCODE.po with existing PO template
200 -g, --gettext-package=NAME override PO template name, useful with --pot
201 -o, --output-file=FILE write merged translation to FILE
202 -x, --verbose display lots of feedback
203 --help display this help and exit
204 --version output version information and exit
207 ${PROGRAM} --pot just create a new PO template
208 ${PROGRAM} xy create new PO template and merge xy.po with it
210 Report bugs to http://bugzilla.gnome.org/ (product name "$PACKAGE")
211 or send email to <xml-i18n-tools\@gnome.org>.
219 my $ret = `echo "$str"`;
221 $ret =~ s/\n$//; # do we need the "s" flag?
226 sub POFile_DetermineType ($)
231 my $xml_regex = "(?:" . $xml_support . ")";
232 my $ini_regex = "(?:" . $ini_support . ")";
233 my $buildin_regex = "(?:" . $buildin_gettext_support . ")";
235 if ($type =~ /\[type: gettext\/([^\]].*)]/)
239 elsif ($type =~ /schemas(\.in)+$/)
241 $gettext_type="schemas";
243 elsif ($type =~ /glade2?(\.in)*$/)
245 $gettext_type="glade";
247 elsif ($type =~ /scm(\.in)*$/)
249 $gettext_type="scheme";
251 elsif ($type =~ /keys(\.in)+$/)
253 $gettext_type="keys";
258 elsif ($type =~ /$xml_regex$/)
262 elsif ($type =~ /$ini_regex$/)
266 elsif ($type =~ /$buildin_regex$/)
268 $gettext_type="buildin";
272 $gettext_type="unknown";
275 return "gettext\/$gettext_type";
278 sub TextFile_DetermineEncoding ($)
280 my $gettext_code="ASCII"; # All files are ASCII by default
281 my $filetype=`file $_ | cut -d ' ' -f 2`;
285 if ($filetype =~ /^(ISO|UTF)/)
287 chomp ($gettext_code = $filetype);
289 elsif ($filetype =~ /^XML/)
291 $gettext_code="UTF-8"; # We asume that .glade and other .xml files are UTF-8
295 return $gettext_code;
298 sub isNotValidMissing
302 return if $file =~ /^\{arch\}\/.*$/;
303 return if $file =~ /^$varhash{"PACKAGE"}-$varhash{"VERSION"}\/.*$/;
310 @buf_i18n_xml_unmarked,
313 @buf_potfiles_ignore,
315 @buf_allfiles_sorted,
319 ## Search and find all translatable files
321 push @buf_i18n_plain, "$File::Find::name" if /\.($buildin_gettext_support)$/;
322 push @buf_i18n_xml, "$File::Find::name" if /\.($xml_support)$/;
323 push @buf_i18n_ini, "$File::Find::name" if /\.($ini_support)$/;
324 push @buf_i18n_xml_unmarked, "$File::Find::name" if /\.(schemas(\.in)+)$/;
328 open POTFILES, $POTFILES_in or die "$PROGRAM: there's no POTFILES.in!\n";
329 @buf_potfiles = grep !/^(#|\s*$)/, <POTFILES>;
332 foreach (@buf_potfiles) {
336 print "Searching for missing translatable files...\n" if $VERBOSE;
338 ## Check if we should ignore some found files, when
339 ## comparing with POTFILES.in
340 foreach my $ignore ("POTFILES.skip", "POTFILES.ignore")
342 (-s $ignore) or next;
344 if ("$ignore" eq "POTFILES.ignore")
346 print "The usage of POTFILES.ignore is deprecated. Please consider moving the\n".
347 "content of this file to POTFILES.skip.\n";
350 print "Found $ignore: Ignoring files...\n" if $VERBOSE;
351 open FILE, "<$ignore" or die "ERROR: Failed to open $ignore!\n";
355 push @buf_potfiles_ignore, $_ unless /^(#|\s*$)/;
359 @buf_potfiles = (@buf_potfiles_ignore, @buf_potfiles);
362 foreach my $file (@buf_i18n_plain)
370 # Handle continued multi-line comment.
373 next unless s-.*\*/--;
377 # Handle continued macro.
380 $in_macro = 0 unless /\\$/;
384 # Handle start of macro (or any preprocessor directive).
387 $in_macro = 1 if /^([^\\]|\\.)*\\$/;
391 # Handle comments and quoted text.
392 while (m-(/\*|//|\'|\")-) # \' and \" keep emacs perl mode happy
403 elsif ($match eq "//")
409 if (!s-$match([^\\]|\\.)*?$match-QUOTEDTEXT-)
411 warn "mismatched quotes at line $. in $file\n";
417 if (/\.GetString ?\(QUOTEDTEXT/)
419 if (defined isNotValidMissing (unpack("x3 A*", $file))) {
420 ## Remove the first 3 chars and add newline
421 push @buf_allfiles, unpack("x3 A*", $file) . "\n";
428 if (defined isNotValidMissing (unpack("x3 A*", $file))) {
429 ## Remove the first 3 chars and add newline
430 push @buf_allfiles, unpack("x3 A*", $file) . "\n";
438 foreach my $file (@buf_i18n_xml)
444 # FIXME: share the pattern matching code with intltool-extract
445 if (/\s_(.*)=\"/ || /<_[^>]+>/ || /translatable=\"yes\"/)
447 if (defined isNotValidMissing (unpack("x3 A*", $file))) {
448 push @buf_allfiles, unpack("x3 A*", $file) . "\n";
456 foreach my $file (@buf_i18n_ini)
463 if (defined isNotValidMissing (unpack("x3 A*", $file))) {
464 push @buf_allfiles, unpack("x3 A*", $file) . "\n";
472 foreach my $file (@buf_i18n_xml_unmarked)
474 if (defined isNotValidMissing (unpack("x3 A*", $file))) {
475 push @buf_allfiles, unpack("x3 A*", $file) . "\n";
480 @buf_allfiles_sorted = sort (@buf_allfiles);
481 @buf_potfiles_sorted = sort (@buf_potfiles);
484 foreach (@buf_potfiles_sorted)
491 foreach (@buf_allfiles_sorted)
493 if (!exists($in2{$_}))
499 my @buf_potfiles_notexist;
501 foreach (@buf_potfiles_sorted)
503 chomp (my $dummy = $_);
504 if ("$dummy" ne "" and ! -f "../$dummy")
506 push @buf_potfiles_notexist, $_;
510 ## Save file with information about the files missing
511 ## if any, and give information about this procedure.
512 if (@result + @buf_potfiles_notexist > 0)
516 print "\n" if $VERBOSE;
518 open OUT, ">missing";
521 warn "\e[1mThe following files contain translations and are currently not in use. Please\e[0m\n".
522 "\e[1mconsider adding these to the POTFILES.in file, located in the po/ directory.\e[0m\n\n";
523 print STDERR @result, "\n";
524 warn "If some of these files are left out on purpose then please add them to\n".
525 "POTFILES.skip instead of POTFILES.in. A file \e[1m'missing'\e[0m containing this list\n".
526 "of left out files has been written in the current directory.\n";
528 if (@buf_potfiles_notexist)
531 open OUT, ">notexist";
532 print OUT @buf_potfiles_notexist;
534 warn "\n" if ($VERBOSE or @result);
535 warn "\e[1mThe following files do not exist anymore:\e[0m\n\n";
536 warn @buf_potfiles_notexist, "\n";
537 warn "Please remove them from POTFILES.in or POTFILES.skip. A file \e[1m'notexist'\e[0m\n".
538 "containing this list of absent files has been written in the current directory.\n";
542 ## If there is nothing to complain about, notify the user
544 print "\nAll files containing translations are present in POTFILES.in.\n" if $VERBOSE;
548 sub Console_WriteError_InvalidOption
550 ## Handle invalid arguments
551 print STDERR "Try `${PROGRAM} --help' for more information.\n";
557 my $EXTRACT = "@INTLTOOL_EXTRACT@";
560 $EXTRACT = $ENV{"INTLTOOL_EXTRACT"} if $ENV{"INTLTOOL_EXTRACT"};
562 ## Generate the .h header files, so we can allow glade and
563 ## xml translation support
566 print STDERR "\n *** The intltool-extract script wasn't found!"
567 ."\n *** Without it, intltool-update can not generate files.\n";
572 open (FILE, $POTFILES_in) or die "$PROGRAM: POTFILES.in not found.\n";
577 next if /^\[\s*encoding/;
579 ## Find xml files in POTFILES.in and generate the
580 ## files with help from the extract script
582 my $gettext_type= &POFile_DetermineType ($1);
584 if (/\.($xml_support|$ini_support)$/ || /^\[/)
588 my $filename = "../$_";
592 system ($EXTRACT, "--update", "--srcdir=$SRCDIR",
593 "--type=$gettext_type", $filename);
597 system ($EXTRACT, "--update", "--type=$gettext_type",
598 "--srcdir=$SRCDIR", "--quiet", $filename);
607 # Generate .pot file from POTFILES.in
609 sub GeneratePOTemplate
611 my $XGETTEXT = $ENV{"XGETTEXT"} || "/scratchbox/devkits/slp-tools/bin/xgettext";
612 my $XGETTEXT_ARGS = $ENV{"XGETTEXT_ARGS"} || '';
617 print STDERR " *** xgettext is not found on this system!\n".
618 " *** Without it, intltool-update can not extract strings.\n";
622 print "Building $MODULE.pot...\n" if $VERBOSE;
624 open INFILE, $POTFILES_in;
625 unlink "POTFILES.in.temp";
626 open OUTFILE, ">POTFILES.in.temp" or die("Cannot open POTFILES.in.temp for writing");
628 my $gettext_support_nonascii = 0;
630 # checks for GNU gettext >= 0.12
631 my $dummy = `$XGETTEXT --version --from-code=UTF-8 >/dev/null 2>/dev/null`;
634 $gettext_support_nonascii = 1;
638 # urge everybody to upgrade gettext
639 print STDERR "WARNING: This version of gettext does not support extracting non-ASCII\n".
640 " strings. That means you should install a version of gettext\n".
641 " that supports non-ASCII strings (such as GNU gettext >= 0.12),\n".
642 " or have to let non-ASCII strings untranslated. (If there is any)\n";
645 my $encoding = "ASCII";
646 my $forced_gettext_code;
648 my $encoding_problem_is_reported = 0;
652 next if (/^#/ or /^\s*$/);
658 if (/^\[\s*encoding:\s*(.*)\s*\]/)
660 $forced_gettext_code=$1;
662 elsif (/\.($xml_support|$ini_support)$/ || /^\[/)
665 print OUTFILE "../$_.h\n";
666 push @temp_headers, "../$_.h";
667 $gettext_code = &TextFile_DetermineEncoding ("../$_.h") if ($gettext_support_nonascii and not defined $forced_gettext_code);
671 if ($SRCDIR eq ".") {
672 print OUTFILE "../$_\n";
674 print OUTFILE "$SRCDIR/../$_\n";
676 $gettext_code = &TextFile_DetermineEncoding ("../$_") if ($gettext_support_nonascii and not defined $forced_gettext_code);
679 next if (! $gettext_support_nonascii);
681 if (defined $forced_gettext_code)
683 $encoding=$forced_gettext_code;
685 elsif (defined $gettext_code and "$encoding" ne "$gettext_code")
687 if ($encoding eq "ASCII")
689 $encoding=$gettext_code;
691 elsif ($gettext_code ne "ASCII")
693 # Only report once because the message is quite long
694 if (! $encoding_problem_is_reported)
696 print STDERR "WARNING: You should use the same file encoding for all your project files,\n".
697 " but $PROGRAM thinks that most of the source files are in\n".
698 " $encoding encoding, while \"$_\" is (likely) in\n".
699 " $gettext_code encoding. If you are sure that all translatable strings\n".
700 " are in same encoding (say UTF-8), please \e[1m*prepend*\e[0m the following\n".
701 " line to POTFILES.in:\n\n".
702 " [encoding: UTF-8]\n\n".
703 " and make sure that configure.in/ac checks for $PACKAGE >= 0.27 .\n".
704 "(such warning message will only be reported once.)\n";
705 $encoding_problem_is_reported = 1;
714 unlink "$MODULE.pot";
715 my @xgettext_argument=("$XGETTEXT",
718 "--output\=$MODULE\.pot",
719 "--files-from\=\.\/POTFILES\.in\.temp");
720 my $XGETTEXT_KEYWORDS = &FindPOTKeywords;
721 push @xgettext_argument, $XGETTEXT_KEYWORDS;
722 push @xgettext_argument, "--from-code\=$encoding" if ($gettext_support_nonascii);
723 push @xgettext_argument, $XGETTEXT_ARGS if $XGETTEXT_ARGS;
724 my $xgettext_command = join ' ', @xgettext_argument;
726 # intercept xgettext error message
727 print "Running $xgettext_command\n" if $VERBOSE;
728 my $xgettext_error_msg = `$xgettext_command 2>\&1`;
729 my $command_failed = $?;
731 unlink "POTFILES.in.temp";
733 print "Removing generated header (.h) files..." if $VERBOSE;
734 unlink foreach (@temp_headers);
735 print "done.\n" if $VERBOSE;
737 if (! $command_failed)
739 if (! -e "$MODULE.pot")
741 print "None of the files in POTFILES.in contain strings marked for translation.\n" if $VERBOSE;
745 print "Wrote $MODULE.pot\n" if $VERBOSE;
750 if ($xgettext_error_msg =~ /--from-code/)
752 # replace non-ASCII error message with a more useful one.
753 print STDERR "ERROR: xgettext failed to generate PO template file because there is non-ASCII\n".
754 " string marked for translation. Please make sure that all strings marked\n".
755 " for translation are in uniform encoding (say UTF-8), then \e[1m*prepend*\e[0m the\n".
756 " following line to POTFILES.in and rerun $PROGRAM:\n\n".
757 " [encoding: UTF-8]\n\n";
761 print STDERR "$xgettext_error_msg";
762 if (-e "$MODULE.pot")
765 print STDERR "ERROR: xgettext failed but still managed to generate PO template file.\n".
766 " Please consult error message above if there is any.\n";
770 print STDERR "ERROR: xgettext failed to generate PO template file. Please consult\n".
771 " error message above if there is any.\n";
780 -f "$MODULE.pot" or die "$PROGRAM: $MODULE.pot does not exist.\n";
782 my $MSGMERGE = $ENV{"MSGMERGE"} || "/usr/bin/msgmerge";
783 my ($lang, $outfile) = @_;
785 print "Merging $SRCDIR/$lang.po with $MODULE.pot..." if $VERBOSE;
787 my $infile = "$SRCDIR/$lang.po";
788 $outfile = "$SRCDIR/$lang.po" if ($outfile eq "");
790 # I think msgmerge won't overwrite old file if merge is not successful
791 system ("$MSGMERGE", "-o", $outfile, $infile, "$MODULE.pot");
794 sub Console_WriteError_NotExisting
798 ## Report error if supplied language file is non-existing
799 print STDERR "$PROGRAM: $file does not exist!\n";
800 print STDERR "Try '$PROGRAM --help' for more information.\n";
806 my @po_files = glob ("./*.po");
808 @languages = map (&POFile_GetLanguage, @po_files);
810 foreach my $lang (@languages)
812 $po_files_by_lang{$lang} = shift (@po_files);
816 sub POFile_GetLanguage ($)
818 s/^(.*\/)?(.+)\.po$/$2/;
822 sub Console_Write_TranslationStatus
824 my ($lang, $output_file) = @_;
825 my $MSGFMT = $ENV{"MSGFMT"} || "/usr/bin/msgfmt";
827 $output_file = "$SRCDIR/$lang.po" if ($output_file eq "");
829 system ("$MSGFMT", "-o", "/dev/null", "--statistics", $output_file);
832 sub Console_Write_CoverageReport
834 my $MSGFMT = $ENV{"MSGFMT"} || "/usr/bin/msgfmt";
838 foreach my $lang (@languages)
841 &POFile_Update ($lang, "");
844 print "\n\n * Current translation support in $MODULE \n\n";
846 foreach my $lang (@languages)
849 system ("$MSGFMT", "-o", "/dev/null", "--statistics", "$SRCDIR/$lang.po");
853 sub SubstituteVariable
857 # always need to rewind file whenever it has been accessed
860 # cache each variable. varhash is global to we can add
861 # variables elsewhere.
866 ($varhash{$1} = $2) =~ s/^["'](.*)["']$/$1/;
870 if ($str =~ /^(.*)\${?([A-Z_]+)}?(.*)$/)
874 my $sub = $varhash{$2};
876 return SubstituteVariable ("$untouched$sub$rest");
879 # We're using Perl backticks ` and "echo -n" here in order to
880 # expand any shell escapes (such as backticks themselves) in every variable
881 return echo_n ($str);
886 my $base_dirname = getcwd();
887 $base_dirname =~ s@.*/@@;
889 my ($conf_in, $src_dir);
891 if ($base_dirname =~ /^po(-.+)?$/)
898 open (IN, "<Makevars") || die "can't open Makevars: $!";
902 if (/^top_builddir[ \t]*=/)
905 $src_dir =~ s/^top_builddir[ \t]*=[ \t]*([^ \t\n\r]*)/$1/;
908 if (-f "$src_dir" . "/configure.ac") {
909 $conf_in = "$src_dir" . "/configure.ac" . "\n";
911 $conf_in = "$src_dir" . "/configure.in" . "\n";
918 $conf_in || die "Cannot find top_builddir in Makevars.";
920 elsif (-f "../configure.ac")
922 $conf_in = "../configure.ac";
924 elsif (-f "../configure.in")
926 $conf_in = "../configure.in";
933 open (IN, "<Makefile") || return;
937 if (/^top_srcdir[ \t]*=/)
940 $src_dir =~ s/^top_srcdir[ \t]*=[ \t]*([^ \t\n\r]*)/$1/;
943 $conf_in = "$src_dir" . "/configure.in" . "\n";
950 $conf_in || die "Cannot find top_srcdir in Makefile.";
953 open (CONF, "<$conf_in");
957 print STDERR "$PROGRAM: Unable to proceed.\n" .
958 "Make sure to run this script inside the po directory.\n";
966 my $domain = &FindMakevarsDomain;
967 my $name = $domain || "untitled";
973 open (IN, "<&CONF") || return $name;
975 local $/; # slurp mode
980 # priority for getting package name:
982 # 2. first argument of AC_INIT (with >= 2 arguments)
983 # 3. first argument of AM_INIT_AUTOMAKE (with >= 2 argument)
985 # /^AM_INIT_AUTOMAKE\([\s\[]*([^,\)\s\]]+)/m
986 # the \s makes this not work, why?
987 if ($conf_source =~ /^AM_INIT_AUTOMAKE\(([^,\)]+),([^,\)]+)/m)
989 ($name, $version) = ($1, $2);
990 $name =~ s/[\[\]\s]//g;
991 $version =~ s/[\[\]\s]//g;
992 $varhash{"AC_PACKAGE_NAME"} = $name;
993 $varhash{"PACKAGE"} = $name;
994 $varhash{"AC_PACKAGE_VERSION"} = $version;
995 $varhash{"VERSION"} = $version;
998 if ($conf_source =~ /^AC_INIT\(([^,\)]+),([^,\)]+)/m)
1000 ($name, $version) = ($1, $2);
1001 $name =~ s/[\[\]\s]//g;
1002 $version =~ s/[\[\]\s]//g;
1003 $varhash{"AC_PACKAGE_NAME"} = $name;
1004 $varhash{"PACKAGE"} = $name;
1005 $varhash{"AC_PACKAGE_VERSION"} = $version;
1006 $varhash{"VERSION"} = $version;
1009 # \s makes this not work, why?
1010 $name = $1 if $conf_source =~ /^GETTEXT_PACKAGE=\[?([^\n\]]+)/m;
1012 # prepend '$' to auto* internal variables, usually they are
1013 # used in configure.in/ac without the '$'
1014 $name =~ s/AC_/\$AC_/g;
1015 $name =~ s/\$\$/\$/g;
1017 $name = $domain if $domain;
1019 $name = SubstituteVariable ($name);
1020 $name =~ s/^["'](.*)["']$/$1/;
1022 return $name if $name;
1029 my $keywords = "--keyword\=\_ --keyword\=N\_ --keyword\=U\_ --keyword\=Q\_";
1030 my $varname = "XGETTEXT_OPTIONS";
1033 open (IN, "<Makevars") || (open(IN, "<Makefile.in.in") && ($varname = "XGETTEXT_KEYWORDS")) || return $keywords;
1035 local $/; # slurp mode
1036 $make_source = <IN>;
1040 $keywords = $1 if $make_source =~ /^$varname[ ]*=\[?([^\n\]]+)/m;
1045 sub FindMakevarsDomain
1049 my $makevars_source; {
1051 open (IN, "<Makevars") || return $domain;
1053 local $/; # slurp mode
1054 $makevars_source = <IN>;
1058 $domain = $1 if $makevars_source =~ /^DOMAIN[ ]*=\[?([^\n\]\$]+)/m;
1059 $domain =~ s/^\s+//;
1060 $domain =~ s/\s+$//;