From 8a0f37cc692f4736436306526ea49dd7b9f498fa Mon Sep 17 00:00:00 2001 From: IKEDA Soji Date: Thu, 13 Oct 2022 18:12:49 +0900 Subject: [PATCH] Update support/xgettext.pl - cpanfile is no longer scanned. - add smalltalk-format flag to maketext'ed messages. - make some fields in the header updated. - suppress informational outputs. --- po/sympa/Makevars | 2 +- po/sympa/POTFILES.in | 1 - po/sympa/sympa.pot | 4 +- po/web_help/Makevars | 2 +- po/web_help/web_help.pot | 2 + support/xgettext.pl | 117 ++++++++++++++++++--------------------- 6 files changed, 61 insertions(+), 67 deletions(-) diff --git a/po/sympa/Makevars b/po/sympa/Makevars index ffce8f991..b1c3158e4 100644 --- a/po/sympa/Makevars +++ b/po/sympa/Makevars @@ -43,7 +43,7 @@ PACKAGE_GNU = no # It can be your email address, or a mailing list address where translators # can write to without being subscribed, or the URL of a web page through # which the translators can contact you. -MSGID_BUGS_ADDRESS = +MSGID_BUGS_ADDRESS = https://translate.sympa.community # This is the list of locale categories, beyond LC_MESSAGES, for which the # message catalogs shall be used. It is usually empty. diff --git a/po/sympa/POTFILES.in b/po/sympa/POTFILES.in index 278b09a61..babc27bcf 100644 --- a/po/sympa/POTFILES.in +++ b/po/sympa/POTFILES.in @@ -6,7 +6,6 @@ src/lib/*.pm src/lib/Sympa/*.pm src/lib/Sympa/*/*.pm src/lib/Sympa/*/*/*.pm -cpanfile src/cgi/*.fcgi.in default/web_tt2/*.tt2 default/mail_tt2/*.tt2 diff --git a/po/sympa/sympa.pot b/po/sympa/sympa.pot index d6486cc88..5f86a06b6 100644 --- a/po/sympa/sympa.pot +++ b/po/sympa/sympa.pot @@ -1,4 +1,4 @@ -# SOME DESCRIPTIVE TITLE. +# Sympa 6.2 user interface. # Copyright (C) YEAR THE PACKAGE'S COPYRIGHT HOLDER # This file is distributed under the same license as the PACKAGE package. # FIRST AUTHOR , YEAR. @@ -7,10 +7,12 @@ msgid "" msgstr "" "Project-Id-Version: PACKAGE VERSION\n" +"Report-Msgid-Bugs-To: \n" "POT-Creation-Date: 2002-07-16 17:27+0800\n" "PO-Revision-Date: YEAR-MO-DA HO:MI+ZONE\n" "Last-Translator: FULL NAME \n" "Language-Team: LANGUAGE \n" +"Language: \n" "MIME-Version: 1.0\n" "Content-Type: text/plain; charset=CHARSET\n" "Content-Transfer-Encoding: 8bit\n" diff --git a/po/web_help/Makevars b/po/web_help/Makevars index 975ae2f9c..f57bc16b4 100644 --- a/po/web_help/Makevars +++ b/po/web_help/Makevars @@ -43,7 +43,7 @@ PACKAGE_GNU = no # It can be your email address, or a mailing list address where translators # can write to without being subscribed, or the URL of a web page through # which the translators can contact you. -MSGID_BUGS_ADDRESS = +MSGID_BUGS_ADDRESS = https://translate.sympa.community # This is the list of locale categories, beyond LC_MESSAGES, for which the # message catalogs shall be used. It is usually empty. diff --git a/po/web_help/web_help.pot b/po/web_help/web_help.pot index 215e14215..9bc8726fb 100644 --- a/po/web_help/web_help.pot +++ b/po/web_help/web_help.pot @@ -7,10 +7,12 @@ msgid "" msgstr "" "Project-Id-Version: Sympa 5.3.3\n" +"Report-Msgid-Bugs-To: \n" "POT-Creation-Date: 2007-11-13 14:50+0200\n" "PO-Revision-Date: YEAR-MO-DA HO:MI+ZONE\n" "Last-Translator: FULL NAME \n" "Language-Team: LANGUAGE \n" +"Language: \n" "MIME-Version: 1.0\n" "Content-Type: text/plain; charset=UTF-8\n" "Content-Transfer-Encoding: 8bit\n" diff --git a/support/xgettext.pl b/support/xgettext.pl index 1172af6f3..a21f2df9c 100755 --- a/support/xgettext.pl +++ b/support/xgettext.pl @@ -6,8 +6,9 @@ use warnings; use Cwd qw(); use English; # FIXME: Avoid $MATCH usage -use Getopt::Long; +use Getopt::Long qw(:config no_ignore_case); use Pod::Usage; +use POSIX qw(); use constant NUL => 0; use constant BEG => 1; @@ -40,7 +41,8 @@ 'help|h', 'keyword|k:s@', 'msgid-bugs-address=s', "output|o=s", 'package-name=s', 'package-version=s', - 'version|v', 't=s@', + 'version|V', 'verbose|v', + 't=s@', ) or pod2usage(-verbose => 1, -exitval => 1); $opts{help} and pod2usage(-verbose => 2, -exitval => 0); @@ -78,7 +80,7 @@ foreach my $file (@ARGV) { next if $file =~ m{ [.] po.? \z }ix; # Don't parse po files - printf STDOUT "Processing %s...\n", $file; + printf STDOUT "Processing %s...\n", $file if $opts{verbose}; unless (-f $file) { printf STDERR "Cannot open %s\n", $file; next; @@ -86,7 +88,7 @@ # cpanfile if ($file eq 'cpanfile') { - CPANFile::load(); + printf STDERR "%s is no longer supported\n", $file; next; } @@ -156,7 +158,8 @@ last; } - 1 while chomp $out; + $out =~ s/[\r\n]+\z//; + $out .= "\n" if length $out; seek $pot, 0, 0; truncate $pot, 0; @@ -166,7 +169,7 @@ } select $pot; -print $out ? "$out\n" : (<< '.'); +$out ||= (<< '.'); # SOME DESCRIPTIVE TITLE. # Copyright (C) YEAR THE PACKAGE'S COPYRIGHT HOLDER # This file is distributed under the same license as the PACKAGE package. @@ -187,6 +190,18 @@ "Content-Transfer-Encoding: 8bit\n" . +$out =~ s{"(Project-Id-Version): .*\\n"} + {"$1: $opts{'package-name'}-$opts{'package-version'}\\n"} + if $opts{'package-name'} and $opts{'package-version'}; +$out =~ s{"(Report-Msgid-Bugs-To): .*\\n"} + {"$1: $opts{'msgid-bugs-address'}\\n"} + if $opts{'msgid-bugs-address'}; +my $cdate = POSIX::strftime('%Y-%m-%d %H:%M:%S+0000', gmtime time); +$out =~ s{"(POT-Creation-Date): .*\\n"} + {"$1: $cdate\\n"}; + +print $out; + foreach my $entry (@ordered_bis) { my %f = (map { ("$_->[0]:$_->[1]" => 1) } @{$file{$entry}}); my $f = join(' ', sort keys %f); @@ -224,7 +239,11 @@ # Print code/templates references. print "#:$f\n"; - print "#, c-format\n" if 'printf' eq ($type_of_entries{$entry} || ''); + if ('printf' eq ($type_of_entries{$entry} || '')) { + print "#, c-format\n"; + } elsif ('maketext' eq ($type_of_entries{$entry} || '')) { + print "#, smalltalk-format\n"; + } print "msgid "; output($entry); @@ -332,7 +351,11 @@ sub load_tt2 { filename => $filename, line => $line, vars => $vars, - (($this_tag eq 'locdt') ? (type => 'date') : ()) + ( ($this_tag eq 'locdt') ? (type => 'date') + : ($this_tag eq 'loc' and 0 <= index $str, '%') + ? (type => 'maketext') + : () + ) } ); } @@ -402,6 +425,9 @@ sub load_perl { } elsif ($1 eq 'gettext_sprintf') { $state = BEGM; $type = 'printf'; + } elsif ($1 eq 'maketext') { + $state = BEG; + $type = 'maketext'; } else { $state = BEG; undef $type; @@ -612,34 +638,6 @@ sub output { } } -package CPANFile; - -use strict; -use warnings; -use lib qw(.); - -my @entries; - -sub feature { - push @entries, - { - expression => $_[1], - filename => 'cpanfile', - line => [caller]->[2], - }; -} -sub on { $_[1]->() } -sub recommends { } -sub requires { } - -sub load { - do 'cpanfile'; - die unless @entries; - foreach my $entry (@entries) { - main::add_expression($entry); - } -} - 1; __END__ @@ -677,10 +675,17 @@ =head1 OPTIONS Enables GNU gettext interoperability by printing C<#, maketext-format> before each entry that has C<%> variables. +Instead, currently C<#, smalltalk-format>, the argument supported by +GNU gettext, is printed. + =item C<--help>, C<-h> Shows this documentation and exits. +=item C<--msgid-bugs-address> I
+ +Includes email address or URL where bugs are reported in output. + =item C<--output> I, C<-o>I POT file name to be written or incrementally @@ -688,12 +693,20 @@ =head1 OPTIONS C<--default-domain> option specified, F is used. +=item C<--package-name> I + +=item C<--package-version> I + +Includes name and version of package in output. + =item C<-t>I ... Specifies which tag(s) must be used to extract Template Toolkit strings. Default is C and C. Can be specified multiple times. +This option is the extension by Sympa package. + =item C<-u> B. @@ -701,7 +714,11 @@ =head1 OPTIONS format -- i.e. it leaves all brackets alone. This is useful if you are also using the Gettext syntax in your program. -=item C<--version>, C<-v> +=item C<--verbose>, C<-v> + +Prints the names of processed files. + +=item C<--version>, C<-V> Prints "C" and newline, and then exits. @@ -711,12 +728,6 @@ =head1 OPTIONS =item C<--keyword> [ I ], C<-k>[ I ], ... -=item C<--msgid-bugs-address> I
- -=item C<--package-name> I - -=item C<--package-version> I - These options will do nothing. They are prepared for compatibility to xgettext of GNU gettext. @@ -767,24 +778,4 @@ =head1 HISTORY Afterward, it has been drastically rewritten to be adopted to Sympa and original code hardly remains. -Part of changes are as following: - -=over - -=item [O. Salaun] 12/08/02 : - -Also look for gettext() in perl code. -No more escape '\' chars. -Extract gettext_comment, gettext_id and gettext_unit entries from List.pm. -Extract title.gettext entries from scenarios. - -=item [D. Verdin] 05/11/2007 : - -Strings ordered following the order in which files are read and -the order in which they appear in the files. -Switch to Getopt::Long to allow multiple value parameter. -Added 't' parameter the specifies which tags to explore in TT2. - -=back - =cut