Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Update support/xgettext.pl #1511

Merged
merged 1 commit into from
Nov 14, 2022
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 1 addition & 1 deletion po/sympa/Makevars
Original file line number Diff line number Diff line change
Expand Up @@ -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.
Expand Down
1 change: 0 additions & 1 deletion po/sympa/POTFILES.in
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down
4 changes: 3 additions & 1 deletion po/sympa/sympa.pot
Original file line number Diff line number Diff line change
@@ -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 <EMAIL@ADDRESS>, YEAR.
Expand All @@ -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 <EMAIL@ADDRESS>\n"
"Language-Team: LANGUAGE <LL@li.org>\n"
"Language: \n"
"MIME-Version: 1.0\n"
"Content-Type: text/plain; charset=CHARSET\n"
"Content-Transfer-Encoding: 8bit\n"
Expand Down
2 changes: 1 addition & 1 deletion po/web_help/Makevars
Original file line number Diff line number Diff line change
Expand Up @@ -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.
Expand Down
2 changes: 2 additions & 0 deletions po/web_help/web_help.pot
Original file line number Diff line number Diff line change
Expand Up @@ -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 <EMAIL@ADDRESS>\n"
"Language-Team: LANGUAGE <LL@li.org>\n"
"Language: \n"
"MIME-Version: 1.0\n"
"Content-Type: text/plain; charset=UTF-8\n"
"Content-Transfer-Encoding: 8bit\n"
Expand Down
117 changes: 54 additions & 63 deletions support/xgettext.pl
Original file line number Diff line number Diff line change
Expand Up @@ -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;
Expand Down Expand Up @@ -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);
Expand Down Expand Up @@ -78,15 +80,15 @@
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;
}

# cpanfile
if ($file eq 'cpanfile') {
CPANFile::load();
printf STDERR "%s is no longer supported\n", $file;
next;
}

Expand Down Expand Up @@ -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;
Expand All @@ -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.
Expand All @@ -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);
Expand Down Expand Up @@ -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);
Expand Down Expand Up @@ -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')
: ()
)
}
);
}
Expand Down Expand Up @@ -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;
Expand Down Expand Up @@ -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__

Expand Down Expand Up @@ -677,31 +675,50 @@ =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<address>

Includes email address or URL where bugs are reported in output.

=item C<--output> I<outputfile>, C<-o>I<outputfile>

POT file name to be written or incrementally
updated C<-> means writing to F<STDOUT>. If neither this option nor
C<--default-domain> option specified,
F<messages.po> is used.

=item C<--package-name> I<name>

=item C<--package-version> I<version>

Includes name and version of package in output.

=item C<-t>I<tag1> ...

Specifies which tag(s) must be used to extract Template Toolkit strings.
Default is C<loc> and C<locdt>.
Can be specified multiple times.

This option is the extension by Sympa package.

=item C<-u>

B<Deprecated>.
Disables conversion from Maketext format to Gettext
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<sympa-6>" and newline, and then exits.

Expand All @@ -711,12 +728,6 @@ =head1 OPTIONS

=item C<--keyword> [ I<word> ], C<-k>[ I<word> ], ...

=item C<--msgid-bugs-address> I<address>

=item C<--package-name> I<name>

=item C<--package-version> I<version>

These options will do nothing.
They are prepared for compatibility to xgettext of GNU gettext.

Expand Down Expand Up @@ -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