translations-stats 991 B

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647
  1. #!/usr/bin/perl
  2. use strict;
  3. use warnings;
  4. use v5.10;
  5. use utf8;
  6. my $help = q{
  7. NAME
  8. translations-stats - print statistics about Oddmuse translations
  9. SYNOPSIS
  10. scripts/translations-stats [FILE]...
  11. DESCRIPTION
  12. Read all translation files and print some stats.
  13. EXAMPLES
  14. scripts/translations-stats
  15. scripts/translations-stats wiki.pl modules/joiner.pl
  16. };
  17. if (@ARGV == 1 and $ARGV[0] eq '--help') {
  18. print $help;
  19. exit 0;
  20. }
  21. sub AddModuleDescription { print $_[0], ' ' };
  22. our %Translate;
  23. my @files = <modules/translations/*-utf8.pl>;
  24. for (@files) {
  25. if (@ARGV) { # some specific modules
  26. my $files = join ' ', map { quotemeta } @ARGV; # quick and dirty
  27. my $out = `stuff/oddtrans -l \Q$_\E $files`;
  28. eval $out;
  29. } else {
  30. do $_;
  31. }
  32. my $total = keys %Translate;
  33. my $count = grep { $_ } values %Translate;
  34. my $missing = $total - $count;
  35. printf(qq{%d/%d translations missing (%d%% done)\n}, $missing, $total, 100 * $count / $total);
  36. }