mirror of
https://github.com/Llewellynvdm/Tomb.git
synced 2024-11-05 12:57:56 +00:00
[i18n] Update translation generation script
The script doesn't include code snippets in the pot file now, as they made it huge and wheren't very useful. The $fold and $function name are included in the reference instead of normal comments. A hash has been added to manage translatable strings that can't be automatically detected.
This commit is contained in:
parent
15ff5abe61
commit
85fff8a95b
@ -26,18 +26,25 @@ msgstr ""
|
|||||||
|
|
||||||
my @blacklist = ('"--"', '"\\\\000"', '`.*`', '$\(.*\)');
|
my @blacklist = ('"--"', '"\\\\000"', '`.*`', '$\(.*\)');
|
||||||
|
|
||||||
|
# Translatable strings that can't be automatically detected yet
|
||||||
|
my %undetectable = (
|
||||||
|
124 => '[sudo] Enter password for user ::1 user:: to gain superuser privileges'
|
||||||
|
);
|
||||||
|
|
||||||
open my $handle, $FILE or die "Failed to open $FILE";
|
open my $handle, $FILE or die "Failed to open $FILE";
|
||||||
my @lines = <$handle>;
|
my @lines = <$handle>;
|
||||||
close $handle;
|
close $handle;
|
||||||
|
|
||||||
my %seen;
|
my %seen;
|
||||||
my @ignored;
|
|
||||||
my $index = 0;
|
my $index = 0;
|
||||||
my $fold;
|
my $fold;
|
||||||
my $func;
|
my $func;
|
||||||
|
my $force;
|
||||||
|
my $str;
|
||||||
|
|
||||||
foreach (@lines) {
|
foreach (@lines) {
|
||||||
$index++;
|
$index++;
|
||||||
|
$force = 0;
|
||||||
|
|
||||||
# It's a fold title
|
# It's a fold title
|
||||||
if (m/^# +{{{ +(.*)$/) {
|
if (m/^# +{{{ +(.*)$/) {
|
||||||
@ -51,44 +58,28 @@ foreach (@lines) {
|
|||||||
next;
|
next;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
# Force if it's undetectable
|
||||||
|
$force = 1 if exists($undetectable{$index});
|
||||||
|
|
||||||
# Next if there is no print function
|
# Next if there is no print function
|
||||||
next unless m/$FUNCPATTERN +$STRINGPATTERN/;
|
next unless $force or m/$FUNCPATTERN +$STRINGPATTERN/;
|
||||||
|
|
||||||
|
# Get string from the $undetectable hash or via regex
|
||||||
|
if ($force) {
|
||||||
|
$str = "\"$undetectable{$index}\"";
|
||||||
|
}
|
||||||
|
else {
|
||||||
|
$str = $2;
|
||||||
|
}
|
||||||
|
|
||||||
# Next if it was seen before
|
# Next if it was seen before
|
||||||
$seen{$2}++;
|
$seen{$str}++;
|
||||||
next if $seen{$2} > 1;
|
next if $seen{$str} > 1;
|
||||||
|
|
||||||
# Next if it's blacklisted
|
# Next if it's blacklisted
|
||||||
if (grep {$2 =~ m/$_/} @blacklist) {
|
next if grep {$str =~ m/$_/} @blacklist;
|
||||||
push @ignored, $2;
|
|
||||||
next;
|
|
||||||
}
|
|
||||||
|
|
||||||
print "#. Fold: $fold\n";
|
print "#: tomb:$fold:$func:$index\n";
|
||||||
print "#. Function: $func\n";
|
print "msgid $str\n";
|
||||||
print "#.\n";
|
|
||||||
print "#. Code sample:\n";
|
|
||||||
|
|
||||||
my $sign = ' ';
|
|
||||||
for (-7..3) {
|
|
||||||
if($_ == -1) {
|
|
||||||
$sign = '>';
|
|
||||||
}
|
|
||||||
else {
|
|
||||||
$sign = ' ';
|
|
||||||
}
|
|
||||||
|
|
||||||
my $n = $index + $_;
|
|
||||||
print "#. $sign $lines[$n]";
|
|
||||||
}
|
|
||||||
|
|
||||||
print "#: tomb:$index\n";
|
|
||||||
print "msgid $2\n";
|
|
||||||
print "msgstr \"\"\n\n";
|
print "msgstr \"\"\n\n";
|
||||||
}
|
}
|
||||||
|
|
||||||
print STDERR "-- IGNORED\n";
|
|
||||||
foreach (@ignored) {
|
|
||||||
print STDERR "$_\n";
|
|
||||||
}
|
|
||||||
|
|
||||||
|
Loading…
Reference in New Issue
Block a user