gnucash maint: Add small utility to print message catalog statistics.

John Ralls jralls at code.gnucash.org
Tue Jan 19 19:25:04 EST 2016


Updated	 via  https://github.com/Gnucash/gnucash/commit/58392358 (commit)
	from  https://github.com/Gnucash/gnucash/commit/db0fd2e9 (commit)



commit 5839235861691a0835356a2de0a2dbf50ed9bb12
Author: John Ralls <jralls at ceridwen.us>
Date:   Tue Jan 19 16:24:20 2016 -0800

    Add small utility to print message catalog statistics.
    
    Use perldoc on it for details.

diff --git a/util/check-po.pl b/util/check-po.pl
new file mode 100755
index 0000000..9b1d43f
--- /dev/null
+++ b/util/check-po.pl
@@ -0,0 +1,54 @@
+#!/usr/bin/perl -w
+use strict;
+
+my $filename = $ARGV[0];
+my ($last_merge, $last_rev, $msgtot, $msgtrans, $msgfuzz);
+my $date_re = '(\d{4}-\d{2}-\d{2})';
+my $merge_re = qr/^"POT-Creation-Date: $date_re/;
+my $rev_re = qr/^"PO-Revision-Date: $date_re/;
+my $msgid_re = qr(^msgid ".+");
+my $str_re = qr/^msgstr ".+"/;
+
+while (<>) {
+    $last_merge = $1 if ($_ =~ $merge_re);
+    $last_rev = $1 if ($_ =~ $rev_re);
+}
+my ($strings, $fuzzy, $missing);
+open STATS, "msgfmt --stat $filename 2>&1 |" or die;
+while (<STATS>) {
+    #print;
+    $_ =~ /^(\d+) translated messages(?:, (\d+) fuzzy translations)?(?:, (\d+) untranslated messages)?./;
+    $strings = $1 || 0;
+    $fuzzy = $2 || 0;
+    $missing = $3 ||0;
+}
+close STATS;
+my $total = ($strings + $fuzzy + $missing) || 1;
+my $percent = $strings/$total * 100.0;
+my $fuzpct = ($strings + $fuzzy) / $total * 100.0;
+printf "%14s: %s %s\t%4d\t%4d\t%4d\t%3.2f%%\t %3.2f%%\n", $filename, $last_rev,
+        $last_merge, $strings, $fuzzy, $total, $percent, $fuzpct;
+
+=head1 NAME
+
+check-po.pl
+
+=head1 SYNOPSIS
+
+check-po.pl po-filename
+
+=head1 SUMMARY
+
+Prints the filename, last revision date, date of the potfile with which it was
+last merged, the number of translated strings not marked fuzzy, the number of
+translated strings marked fuzzy, the total number of translatable strings, the
+percentage of strings with not-fuzzy translations and the percentage of strings
+with both fuzzy and non-fuzzy translations.
+
+Most effectively used in a shell for loop, e.g.:
+
+C<for i in *.po; do check-po.pl $i; done>
+
+The results of which can be piped to sort(1) for simple analysis.
+
+=cut



Summary of changes:
 util/check-po.pl | 54 ++++++++++++++++++++++++++++++++++++++++++++++++++++++
 1 file changed, 54 insertions(+)
 create mode 100755 util/check-po.pl



More information about the gnucash-changes mailing list