From 869774249ddacf45bc370ac18b2b05445e4840d5 Mon Sep 17 00:00:00 2001 From: Peter Eisentraut Date: Fri, 23 Sep 2016 12:00:00 -0400 Subject: [PATCH] perltidy --- wwwtools/.perltidyrc | 5 ++ wwwtools/nls-status-table | 124 ++++++++++++++++++++------------------ wwwtools/pg-make-po | 113 +++++++++++++++++++--------------- 3 files changed, 133 insertions(+), 109 deletions(-) create mode 100644 wwwtools/.perltidyrc diff --git a/wwwtools/.perltidyrc b/wwwtools/.perltidyrc new file mode 100644 index 0000000..86b9b1f --- /dev/null +++ b/wwwtools/.perltidyrc @@ -0,0 +1,5 @@ +-se +-w +-l=120 +-nolq +-pt=2 diff --git a/wwwtools/nls-status-table b/wwwtools/nls-status-table index 67fe522..c21dd8e 100755 --- a/wwwtools/nls-status-table +++ b/wwwtools/nls-status-table @@ -34,30 +34,31 @@ my %catalog_count; foreach (@ARGV) { /(\w+).pot/ && do { - my $catname = $1; + my $catname = $1; - push @catalogs, $catname; + push @catalogs, $catname; - my $tmp = `LC_ALL=C msgfmt -o /dev/null -v $_ 2>&1`; - $tmp =~ /(\d+) untranslated/ and $catalog_count{$catname} = $1; + my $tmp = `LC_ALL=C msgfmt -o /dev/null -v $_ 2>&1`; + $tmp =~ /(\d+) untranslated/ and $catalog_count{$catname} = $1; - next; + next; }; /(\w+)-(\w+).po/ || next; my $catalogname = $1; - my $lang = $2; + my $lang = $2; my $tmp; if (-e "$_.old") { - $tmp = `LC_ALL=C msgfmt -o /dev/null -v $_.old 2>&1`; - } else { - $tmp = `LC_ALL=C msgfmt -o /dev/null -v $_ 2>&1`; - $new->{$catalogname}{$lang} = 1; + $tmp = `LC_ALL=C msgfmt -o /dev/null -v $_.old 2>&1`; + } + else { + $tmp = `LC_ALL=C msgfmt -o /dev/null -v $_ 2>&1`; + $new->{$catalogname}{$lang} = 1; } $tmp =~ /(\d+) translated/ and $everything->{"$catalogname"}{"$lang"} = $1; if (-f "$_.err") { - $errors->{"$catalogname"}{"$lang"} = 1; + $errors->{"$catalogname"}{"$lang"} = 1; } } @@ -65,14 +66,14 @@ foreach (@ARGV) { my @all_lang = (); foreach my $catalog (@catalogs) { - foreach my $lang (keys %{$everything->{$catalog}}) { - if (not grep($_ eq $lang, @all_lang)) { - push @all_lang, $lang; - } + foreach my $lang (keys %{ $everything->{$catalog} }) { + if (not grep($_ eq $lang, @all_lang)) { + push @all_lang, $lang; + } # Convert count to percentage here; can't do it above in case we # hadn't seen the pot file yet. - $everything->{$catalog}{$lang} = floor($everything->{$catalog}{$lang}/$catalog_count{$catalog} * 100); + $everything->{$catalog}{$lang} = floor($everything->{$catalog}{$lang} / $catalog_count{$catalog} * 100); } } @@ -85,16 +86,16 @@ print "

Last update: $date

\n"; print "\n\n"; print "\n"; -print "\n"; +print "\n"; print "\n"; print "\n"; print "\n"; foreach (@all_lang) { my $c; ($c = $_) =~ tr/_/-/; - print "\n"; + print "\n"; } -print "\n"; +print "\n"; print "\n\n"; my %langavg; @@ -106,48 +107,53 @@ foreach my $catalog (sort @catalogs) { print "\n"; foreach my $lang (@all_lang) { - my $pct = $everything->{$catalog}{$lang}; - print "\n"; - - print LIST "$catalog/$lang\n" if $list_file and defined $pct and $pct >= $QUALIFIED_CUTOFF; + elsif ($errors->{"$catalog"}{"$lang"}) { + print " (E)"; + } + else { + print " "; + } + print "\n"; + + print LIST "$catalog/$lang\n" if $list_file and defined $pct and $pct >= $QUALIFIED_CUTOFF; } print "\n"; @@ -156,18 +162,19 @@ foreach my $catalog (sort @catalogs) { my @totalavg; print "\n"; -print "\n"; +print "\n"; foreach my $lang (@all_lang) { print "\n"; } print "\n"; print "\n\n"; @@ -177,11 +184,10 @@ print "\n"; close LIST if $list_file; - sub list_sum { my $total; foreach (@_) { - $total += $_; + $total += $_; } return $total; } diff --git a/wwwtools/pg-make-po b/wwwtools/pg-make-po index 55a4fb6..c0776ab 100755 --- a/wwwtools/pg-make-po +++ b/wwwtools/pg-make-po @@ -19,9 +19,9 @@ getopts('o:v:', \%opts) or die; my $outdir = $opts{'o'} || '.'; my $version = $opts{'v'}; -my $gmake = $ENV{'GMAKE'} || 'gmake'; +my $gmake = $ENV{'GMAKE'} || 'gmake'; my $msgmerge = $ENV{'MSGMERGE'} || 'msgmerge'; -my $msgfmt = $ENV{'MSGFMT'} || 'msgfmt'; +my $msgfmt = $ENV{'MSGFMT'} || 'msgfmt'; # order as in the GNU gettext manual my %plural_rules = ( @@ -36,28 +36,28 @@ my %plural_rules = ( ); my %plural_forms = ( - 'af' => 'en', - 'cs' => 'cs', - 'de' => 'en', - 'es' => 'en', - 'fa' => 'ja', - 'fr' => 'fr', - 'hr' => 'ru', - 'hu' => 'en', - 'it' => 'en', - 'ja' => 'ja', - 'ko' => 'ja', - 'nb' => 'en', - 'nl' => 'en', - 'pl' => 'pl', + 'af' => 'en', + 'cs' => 'cs', + 'de' => 'en', + 'es' => 'en', + 'fa' => 'ja', + 'fr' => 'fr', + 'hr' => 'ru', + 'hu' => 'en', + 'it' => 'en', + 'ja' => 'ja', + 'ko' => 'ja', + 'nb' => 'en', + 'nl' => 'en', + 'pl' => 'pl', 'pt_BR' => 'fr', - 'ro' => 'ro', - 'ru' => 'ru', - 'sk' => 'cs', - 'sl' => 'sl', - 'sv' => 'en', - 'ta' => 'en', - 'tr' => 'ja', + 'ro' => 'ro', + 'ru' => 'ru', + 'sk' => 'cs', + 'sl' => 'sl', + 'sv' => 'en', + 'ta' => 'en', + 'tr' => 'ja', 'zh_CN' => 'ja', 'zh_TW' => 'ja', ); @@ -76,7 +76,6 @@ undef %saw; @saw{@all_languages} = (); @all_languages = sort keys %saw; - foreach (@ARGV) { my $dirname = dirname($_); open NLSMK, "<$_" or die "could not open $_: $!\n"; @@ -85,44 +84,52 @@ foreach (@ARGV) { my $lang; while () { - /^CATALOG_NAME\s*:?=\s*(\S+)\s*$/ and $catalogname = $1; + /^CATALOG_NAME\s*:?=\s*(\S+)\s*$/ and $catalogname = $1; } close NLSMK; - system("$gmake -C $dirname init-po") == 0 or die "$!\n"; + system("$gmake -C $dirname init-po") == 0 or die "$!\n"; system("cp -f $dirname/po/$catalogname.pot $outdir/$catalogname.pot") == 0 or die "$!\n"; my $avail_languages = join(' ', map { m!/([^/]+)\.po$! && $1 } glob("$dirname/po/*.po")); print STDERR "* $catalogname\n"; foreach $lang (@all_languages) { - print STDERR "$lang: "; + print STDERR "$lang: "; - system("rm -f $outdir/$catalogname-$lang.po.err"); + system("rm -f $outdir/$catalogname-$lang.po.err"); if (-f "$dirname/po/$lang.po") { + # This is what we use to calculate the displayed percentages. - if (system("$msgmerge $dirname/po/$lang.po $dirname/po/$catalogname.pot -o $dirname/po/$lang.po.mrg") != 0) { - system("$msgmerge $dirname/po/$lang.po $dirname/po/$catalogname.pot -o $dirname/po/$lang.po.mrg 2>>$outdir/$catalogname-$lang.po.err 1>/dev/null"); + if (system("$msgmerge $dirname/po/$lang.po $dirname/po/$catalogname.pot -o $dirname/po/$lang.po.mrg") != 0) + { + system( + "$msgmerge $dirname/po/$lang.po $dirname/po/$catalogname.pot -o $dirname/po/$lang.po.mrg 2>>$outdir/$catalogname-$lang.po.err 1>/dev/null" + ); } - if (system("$msgfmt -o /dev/null -v -c $dirname/po/$lang.po >/dev/null 2>&1") != 0 - or system("$msgfmt -o /dev/null -v -c $dirname/po/$lang.po 2>&1 | grep -q 'warning'") == 0) { - system("$msgfmt -o /dev/null -v -c $dirname/po/$lang.po 2>>$outdir/$catalogname-$lang.po.err 1>/dev/null"); - } + if ( system("$msgfmt -o /dev/null -v -c $dirname/po/$lang.po >/dev/null 2>&1") != 0 + or system("$msgfmt -o /dev/null -v -c $dirname/po/$lang.po 2>&1 | grep -q 'warning'") == 0) + { + system( + "$msgfmt -o /dev/null -v -c $dirname/po/$lang.po 2>>$outdir/$catalogname-$lang.po.err 1>/dev/null"); + } - if (system("grep -q -IU ' ' $dirname/po/$lang.po") == 0) { - system("echo '$dirname/po/$lang.po contains DOS line endings' >>$outdir/$catalogname-$lang.po.err"); - } + if (system("grep -q -IU ' ' $dirname/po/$lang.po") == 0) { + system("echo '$dirname/po/$lang.po contains DOS line endings' >>$outdir/$catalogname-$lang.po.err"); + } } - # This is what we offer for download. - if (system("$gmake -C $dirname po/$lang.po.new AVAIL_LANGUAGES='$avail_languages'") != 0) { - system("$gmake -C $dirname po/$lang.po.new AVAIL_LANGUAGES='$avail_languages' 2>>$outdir/$catalogname-$lang.po.err 1>/dev/null"); - } + # This is what we offer for download. + if (system("$gmake -C $dirname po/$lang.po.new AVAIL_LANGUAGES='$avail_languages'") != 0) { + system( + "$gmake -C $dirname po/$lang.po.new AVAIL_LANGUAGES='$avail_languages' 2>>$outdir/$catalogname-$lang.po.err 1>/dev/null" + ); + } - if (-f "$dirname/po/$lang.po.mrg" && ! -f "$dirname/po/$lang.po.new") { + if (-f "$dirname/po/$lang.po.mrg" && !-f "$dirname/po/$lang.po.new") { system("cp $dirname/po/$lang.po.mrg $outdir/$catalogname-$lang.po"); system("cp $dirname/po/$lang.po.mrg $outdir/$catalogname-$lang.po.old"); } @@ -132,15 +139,21 @@ foreach (@ARGV) { system("cp $dirname/po/$lang.po.mrg $outdir/$catalogname-$lang.po.old"); } - if (! -f "$dirname/po/$lang.po.mrg" && -f "$dirname/po/$lang.po.new") { - my $pe = $plural_rules{$plural_forms{$lang}}; + if (!-f "$dirname/po/$lang.po.mrg" && -f "$dirname/po/$lang.po.new") { + my $pe = $plural_rules{ $plural_forms{$lang} }; $pe =~ s/\&/\\\&/g; - system("cat $dirname/po/$lang.po.new | sed '/Plural-Forms:/s/nplurals=INTEGER; plural=EXPRESSION;/$pe/' >$outdir/$catalogname-$lang.po"); + system( + "cat $dirname/po/$lang.po.new | sed '/Plural-Forms:/s/nplurals=INTEGER; plural=EXPRESSION;/$pe/' >$outdir/$catalogname-$lang.po" + ); } - if (system("$msgfmt -o /dev/null -v -c $outdir/$catalogname-$lang.po >/dev/null 2>&1") != 0 - or system("$msgfmt -o /dev/null -v -c $outdir/$catalogname-$lang.po >/dev/null 2>&1 | grep -q 'warning'") == 0) { - system("$msgfmt -o /dev/null -v -c $outdir/$catalogname-$lang.po 2>>$outdir/$catalogname-$lang.po.err 1>/dev/null"); + if ( system("$msgfmt -o /dev/null -v -c $outdir/$catalogname-$lang.po >/dev/null 2>&1") != 0 + or system("$msgfmt -o /dev/null -v -c $outdir/$catalogname-$lang.po >/dev/null 2>&1 | grep -q 'warning'") + == 0) + { + system( + "$msgfmt -o /dev/null -v -c $outdir/$catalogname-$lang.po 2>>$outdir/$catalogname-$lang.po.err 1>/dev/null" + ); } - } # foreach $lang -} # foreach @ARGV + } # foreach $lang +} # foreach @ARGV -- 2.39.5
$_$_".scalar(@all_lang)."" . scalar(@all_lang) . "
"; print "$catalog"; - print "
(".$catalog_count{$catalog}." strings)"; + print "
(" . $catalog_count{$catalog} . " strings)"; print "
{"$catalog"}{"$lang"}) { - print " class='errorpo'"; - } elsif (defined $pct and int($pct) == 100) { - print " class='fullpo'"; - } elsif (defined $pct and $pct >= $QUALIFIED_CUTOFF) { - print " class='qualifiedpo'"; + my $pct = $everything->{$catalog}{$lang}; + print "{"$catalog"}{"$lang"}) { + print " class='errorpo'"; + } + elsif (defined $pct and int($pct) == 100) { + print " class='fullpo'"; + } + elsif (defined $pct and $pct >= $QUALIFIED_CUTOFF) { + print " class='qualifiedpo'"; + } + print ">"; + + if (defined $pct and $pct > 0) { + if (!$new->{$catalog}{$lang}) { + printf "%.0f", $pct; + + push @{ $langavg{"$lang"} }, $pct; + push @catavg, $pct; + } + else { + printf "%.0f", $pct; + } + + if ($errors->{"$catalog"}{"$lang"}) { + print " (E)"; + } } - print ">"; - - if (defined $pct and $pct > 0) { - if (!$new->{$catalog}{$lang}) { - printf "%.0f", $pct; - - push @{$langavg{"$lang"}}, $pct; - push @catavg, $pct; - } else { - printf "%.0f", $pct; - } - - if ($errors->{"$catalog"}{"$lang"}) { - print " (E)"; - } - } elsif ($errors->{"$catalog"}{"$lang"}) { - print " (E)"; - } else { - print " "; - } - print ""; printf "%d", scalar(@catavg); if (@catavg) { - printf " (%.0f)", floor(list_sum(@catavg)/scalar(@catavg)); + printf " (%.0f)", floor(list_sum(@catavg) / scalar(@catavg)); } print "
". scalar(@catalogs) ."" . scalar(@catalogs) . ""; - if (@{$langavg{$lang}}) { - printf "%d (%.0f)", scalar(@{$langavg{$lang}}), floor(list_sum(@{$langavg{$lang}})/scalar(@{$langavg{$lang}})); - push @totalavg, @{$langavg{$lang}}; + if (@{ $langavg{$lang} }) { + printf "%d (%.0f)", scalar(@{ $langavg{$lang} }), + floor(list_sum(@{ $langavg{$lang} }) / scalar(@{ $langavg{$lang} })); + push @totalavg, @{ $langavg{$lang} }; } print ""; -printf "%d (%.0f)", scalar(@totalavg), floor(list_sum(@totalavg)/scalar(@totalavg)); +printf "%d (%.0f)", scalar(@totalavg), floor(list_sum(@totalavg) / scalar(@totalavg)); print "