[i18n] Add {{{-folding name and function name

Adds the {{{-folding name and the function name to the context of the
strings in the .pot file.
This commit is contained in:
gdrooid 2014-12-21 18:58:57 +01:00
parent 5e4141a628
commit 035cfcbeeb

View File

@ -33,26 +33,55 @@ close $handle;
my %seen; my %seen;
my @ignored; my @ignored;
my $index = 0; my $index = 0;
my $fold;
my $func;
foreach (@lines) { foreach (@lines) {
$index++; $index++;
# Ignore if there is no print function on this line
# It's a fold title
if (m/^# +{{{ +(.*)$/) {
$fold = $1;
next;
}
# It's a function name
if (m/^(.*)\(\) *{$/) {
$func = $1;
next;
}
# Next if there is no print function
next unless m/$FUNCPATTERN +$STRINGPATTERN/; next unless m/$FUNCPATTERN +$STRINGPATTERN/;
# Ignore if the string was seen before # Next if it was seen before
$seen{$2}++; $seen{$2}++;
next if $seen{$2} > 1; next if $seen{$2} > 1;
# Ignore if this string is blacklisted # Next if it's blacklisted
if (grep {$2 =~ m/$_/} @blacklist) { if (grep {$2 =~ m/$_/} @blacklist) {
push @ignored, $2; push @ignored, $2;
next; next;
} }
print "#. Fold: $fold\n";
print "#. Function: $func\n";
print "#.\n";
print "#. Code sample:\n";
my $sign = ' ';
for (-7..3) { for (-7..3) {
my $n = $index + $_; if($_ == -1) {
print "#. $lines[$n]"; $sign = '>';
} }
else {
$sign = ' ';
}
my $n = $index + $_;
print "#. $sign $lines[$n]";
}
print "#: tomb:$index\n"; print "#: tomb:$index\n";
print "msgid $2\n"; print "msgid $2\n";
print "msgstr \"\"\n\n"; print "msgstr \"\"\n\n";