statistics.pl 709 B

123456789101112131415161718192021222324252627282930
  1. #! /usr/bin/env perl
  2. use strict;
  3. use warnings;
  4. my $first = 1;
  5. foreach my $f (@ARGV) {
  6. my ($lang, $translated, $fuzzy, $untranslated) = (undef, 0, 0, 0);
  7. # statistics are printed on stderr, as well as error messages.
  8. my $stat = `msgfmt --statistics "$f" 2>&1`;
  9. ($lang = $f) =~ s,\.po$,,;
  10. if ($stat =~ qr"(\d+)\s+translated") {
  11. $translated = $1;
  12. }
  13. if ($stat =~ qr"(\d+)\s+fuzzy") {
  14. $fuzzy = $1;
  15. }
  16. if ($stat =~ qr"(\d+)\s+untranslated") {
  17. $untranslated = $1;
  18. }
  19. if ($first) {
  20. printf("%8s %10s %5s %12s\n",
  21. "language", "translated", "fuzzy", "untranslated");
  22. printf("%s\n", "-" x 43);
  23. $first = 0;
  24. }
  25. printf("%8s %10d %5d %12d\n",
  26. $lang, $translated, $fuzzy, $untranslated);
  27. }