Skip to content

Commit

Permalink
Extract-translators fix enumeration of translators and writing to po …
Browse files Browse the repository at this point in the history
…file.
  • Loading branch information
jralls committed Dec 15, 2024
1 parent b04726b commit c80a63a
Showing 1 changed file with 8 additions and 8 deletions.
16 changes: 8 additions & 8 deletions util/extract-translators.pl
Original file line number Diff line number Diff line change
@@ -1,10 +1,11 @@
use strict;
use warnings;
use utf8;
use Data::Dumper;

my $start = 0;
my $credits = 0;
my $extract_re = qr{^# ([-[:alpha:]\d_., ]+)(?: [(<].*[)>])*, ([-\d, ]+)};
my $extract_re = qr{^# ([-[:alpha:]\d_., ]+)(?: [(<].*[)>])*,? ([-\d, ]+).?$};
my $credits_re = qr(^msgid "translator-credits"$);
my %translators = ();
my $infile = shift;
Expand All @@ -16,16 +17,14 @@
if ($_ =~ $extract_re && $start < 1) {
$start++;
}
if ($start == 1 && $_ !~ $extract_re) {
$start++;
}

if ($start == 1) {
my $input = $_;
utf8::decode($input);
$input =~ $extract_re;
unless ($1) {
print $OUTFILE $_;
$start++;
next;
}
my $name = $1;
Expand All @@ -38,17 +37,18 @@
}
}
if ($_ =~ $credits_re && %translators) {
my $translators_str;
$credits++;
print $OUTFILE $_;
print $OUTFILE "msgstr \"\"\n";
my @translator_list = ();
foreach my $translator (sort(keys(%translators))) {
my $dates = join(", ", sort(@{$translators{$translator}}));
$translators_str .= "$translator: $dates; ";
push @translator_list, "$translator: $dates";
}
my $translators_str = join("; ", @translator_list);
if (defined $translators_str) {
print $OUTFILE "\"$_;\"\n" for map substr($_, 0, 72), $translators_str =~ m[(.{1,72})(?:; |$)]g;
print $OUTFILE "\"\n\n";
print $OUTFILE "\"$_\"\n" for map substr($_, 0, 72), $translators_str =~ m[(.{1,72})(?:; |$)]g;
print $OUTFILE "\n";
}
}
$credits++ if ($credits && substr($_, 0, 1) eq "#");
Expand Down

0 comments on commit c80a63a

Please sign in to comment.