5
0
mirror of git://git.proxmox.com/git/proxmox-i18n.git synced 2025-01-10 09:17:41 +03:00

po2js: cleanup perl code

Signed-off-by: Thomas Lamprecht <t.lamprecht@proxmox.com>
This commit is contained in:
Thomas Lamprecht 2023-05-16 17:20:32 +02:00
parent 7159a792bb
commit df8c4aa493

View File

@ -18,22 +18,14 @@ getopts('t:o:v:', $options) ||
die "no files specified\n" if !scalar(@ARGV); die "no files specified\n" if !scalar(@ARGV);
#my $filename = shift || die "no po file specified\n";
# like FNV32a, but we only return 31 bits (positive numbers) # like FNV32a, but we only return 31 bits (positive numbers)
sub fnv31a { sub fnv31a {
my ($string) = @_; my ($string) = @_;
my $hval = 0x811c9dc5; my $hval = 0x811c9dc5;
for my $c (unpack('C*', $string)) {
foreach my $c (unpack('C*', $string)) {
$hval ^= $c; $hval ^= $c;
$hval += ( $hval += ($hval << 1) + ($hval << 4) + ($hval << 7) + ($hval << 8) + ($hval << 24);
(($hval << 1) ) +
(($hval << 4) ) +
(($hval << 7) ) +
(($hval << 8) ) +
(($hval << 24) ) );
$hval = $hval & 0xffffffff; $hval = $hval & 0xffffffff;
} }
return $hval & 0x7fffffff; return $hval & 0x7fffffff;
@ -54,16 +46,12 @@ foreach my $filename (@ARGV) {
die "unable to get charset\n" if !$charset; die "unable to get charset\n" if !$charset;
} }
for my $k (keys %$href) {
foreach my $k (keys %$href) {
my $po = $href->{$k}; my $po = $href->{$k};
next if $po->fuzzy(); # skip fuzzy entries next if $po->fuzzy(); # skip fuzzy entries
my $ref = $po->reference(); my $ref = $po->reference() or next; # skip unused entries
# skip unused entries # skip entries if "t" is defined (pve/pmg) and the string is
next if !$ref;
# skip entries if t is defined (pve/pmg) and the string is
# not used there or in the widget toolkit # not used there or in the widget toolkit
next if $options->{t} && $ref !~ m/($options->{t}|proxmox)\-/; next if $options->{t} && $ref !~ m/($options->{t}|proxmox)\-/;
@ -74,12 +62,11 @@ foreach my $filename (@ARGV) {
my $msgstr = $po->dequote($qmsgstr); my $msgstr = $po->dequote($qmsgstr);
next if !length($msgid); # skip header next if !length($msgid); # skip header
next if !length($msgstr); # skip untranslated entries next if !length($msgstr); # skip untranslated entries
my $digest = fnv31a($msgid); my $digest = fnv31a($msgid);
die "duplicate digest" if $catalog->{$digest}; die "duplicate digest '$digest' (msgid '$msgid')\n" if $catalog->{$digest};
$catalog->{$digest} = [ $msgstr ]; $catalog->{$digest} = [ $msgstr ];
# later, we can add plural forms to the array # later, we can add plural forms to the array