[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
[bug-gettext] BUG - xgettext fails to extract perl strings below ternary
From: |
Vasco Almeida |
Subject: |
[bug-gettext] BUG - xgettext fails to extract perl strings below ternary operator |
Date: |
Tue, 14 Jun 2016 12:20:31 +0000 |
User-agent: |
KMail/4.14.10 (Linux/4.1.21-14-default; KDE/4.14.18; x86_64; ; ) |
I'm trying to internationalize Git's perl scripts.
Whilst doing git-add-interactive.perl I noticed that xgettext quits extracting
strings from the last part of the file to pot template.
I have figured out that was happening because of one ternary operator (aka
conditional operator) in diff_cmd function. To make xgettext extract the rest
of the file I had to change the named line to
my $reference = (is_initial_commit()) ? get_empty_tree() : 'HEAD';
(include brackets '()' around is_initial_commit())
After that, the remaining strings were successfully extracted.
Below I include (also attach) the patch for Git source I have used to figure
what was happening.
To test apply the patch to Git sources and then run 'make pot'.
Open po/git.pot template and notice that the string "My test 2b.\n" and the
ones below are not extracted to the end of the template.
To make xgettext extract them, add bracket as described previously.
Tested with xgettext versions 0.19.2 and 0.19.8.
Git code at:
https://github.com/git/git/
The tarballs are found at:
https://www.kernel.org/pub/software/scm/git/
---- >8 ----
diff --git a/git-add--interactive.perl b/git-add--interactive.perl
index 822f857..ef30c61 100755
--- a/git-add--interactive.perl
+++ b/git-add--interactive.perl
@@ -4,6 +4,7 @@ use 5.008;
use strict;
use warnings;
use Git;
+use Git::I18N;
binmode(STDOUT, ":raw");
@@ -60,7 +61,7 @@ if ($repo->config_bool("interactive.singlekey")) {
$use_readkey = 1;
};
if (!$use_readkey) {
- print STDERR "missing Term::ReadKey, disabling
interactive.singlekey\n";
+ print STDERR __("missing Term::ReadKey, disabling
interactive.singlekey\n");
}
eval {
require Term::Cap;
@@ -1547,9 +1548,11 @@ sub patch_update_file {
print "\n";
return $quit;
+ print __("My test 1.\n");
}
sub diff_cmd {
+ print __("My test 2.\n");
my @mods = list_modified('index-only');
@mods = grep { !($_->{BINARY}) } @mods;
return if (address@hidden);
@@ -1557,14 +1560,18 @@ sub diff_cmd {
IMMEDIATE => 1,
HEADER => $status_head, },
@mods);
+ print __("My test 2a.\n");
return if (address@hidden);
- my $reference = is_initial_commit() ? get_empty_tree() : 'HEAD';
+ print __("My test 2a.1.\n");
+ my $reference = (is_initial_commit()) ? get_empty_tree() : 'HEAD';
+ print __("My test 2b.\n");
system(qw(git diff -p --cached), $reference, '--',
map { $_->{VALUE} } @them);
+ print __("My test 3.\n");
}
sub quit_cmd {
- print "Bye.\n";
+ print __("Bye.\n");
exit(0);
}
@@ -1620,6 +1627,7 @@ sub process_args {
}
elsif ($arg ne "--") {
die "invalid argument $arg, expecting --";
+ print __("My test 4.");
}
}
@@ -1634,7 +1642,7 @@ sub main_loop {
[ 'help', \&help_cmd, ],
);
while (1) {
- my ($it) = list_and_choose({ PROMPT => 'What now',
+ my ($it) = list_and_choose({ PROMPT => __('What now'),
SINGLETON => 1,
LIST_FLAT => 4,
HEADER => '*** Commands ***',
debug-git-add--intereacive.perl-xgettext.patch
Description: Text Data
[Prev in Thread] |
Current Thread |
[Next in Thread] |
- [bug-gettext] BUG - xgettext fails to extract perl strings below ternary operator,
Vasco Almeida <=