From e7dbbd96b4b0c63103fa2b1ba8f77da373ced6a8 Mon Sep 17 00:00:00 2001 From: John Dennis Date: Tue, 16 Feb 2010 10:24:31 -0500 Subject: Add translation statistics The Makefile in install/po has a new target "msg-stats" which prints out statistics concerning the current pot and po files. Here is an example: % make msg-stats ipa.pot has 133 messages id.po: 107/133 80.5% 13 po untranslated, 13 missing, 26 untranslated kn.po: 4/133 3.0% 116 po untranslated, 13 missing, 129 untranslated pl.po: 120/133 90.2% 0 po untranslated, 13 missing, 13 untranslated Also update configure.ac to search for msgcmp, awk & sed programs. --- install/po/Makefile.in | 31 ++++++++++++++++++++++++++----- 1 file changed, 26 insertions(+), 5 deletions(-) (limited to 'install/po') diff --git a/install/po/Makefile.in b/install/po/Makefile.in index 0a8cd5e09..4b6587374 100644 --- a/install/po/Makefile.in +++ b/install/po/Makefile.in @@ -6,11 +6,14 @@ localedir = ${datarootdir}/locale INSTALL = @INSTALL@ INSTALL_DATA = @INSTALL@ -m 644 +AWK = @AWK@ +SED = @SED@ MKDIR_P = @MKDIR_P@ XGETTEXT = @XGETTEXT@ MSGFMT = @MSGFMT@ MSGINIT = @MSGINIT@ MSGMERGE = @MSGMERGE@ +MSGCMP = @MSGCMP@ DOMAIN = @GETTEXT_DOMAIN@ MSGMERGE_UPDATE = $(MSGMERGE) --update @@ -24,7 +27,7 @@ XGETTEXT_OPTIONS = \ --package-name="$(PACKAGE_NAME)" \ --msgid-bugs-address="$(PACKAGE_BUGREPORT)" -languages = $(shell sed 's/\#.*//' LINGUAS) # The sed command removes comments +languages = $(shell $(SED) 's/\#.*//' LINGUAS) # The sed command removes comments po_files = $(patsubst %, %.po, $(languages)) mo_files = $(patsubst %.po, %.mo, $(po_files)) @@ -167,7 +170,7 @@ SUFFIXES = .po .mo $(po_files): $(DOMAIN).pot @if [ ! -f @a ]; then \ - lang=`echo $@ | sed -r -e 's/\.po$$//'` # Strip .po suffix ; \ + lang=`echo $@ | $(SED) -r -e 's/\.po$$//'` # Strip .po suffix ; \ echo Creating nonexistent $@, you should add this file to your SCM repository; \ $(MSGINIT) --locale $$lang --no-translator -i $(DOMAIN).pot -o $@; \ fi; \ @@ -176,7 +179,7 @@ $(po_files): $(DOMAIN).pot create-po: $(DOMAIN).pot @for po_file in $(po_files); do \ if [ ! -e $$po_file ]; then \ - lang=`echo $$po_file | sed -r -e 's/\.po$$//'` # Strip .po suffix ; \ + lang=`echo $$po_file | $(SED) -r -e 's/\.po$$//'` # Strip .po suffix ; \ echo Creating nonexistent $$po_file, you should add this file to your SCM repository; \ $(MSGINIT) --locale $$lang --no-translator -i $(DOMAIN).pot -o $$po_file; \ fi; \ @@ -204,9 +207,27 @@ update-pot: mv $(DOMAIN).pot.update $(DOMAIN).pot \ && \ # Replace the charset with UTF-8 ; \ - sed -i -r -e 's%("Content-Type: text/plain; charset=)(.*)(\\n")%\1UTF-8\3%' $(DOMAIN).pot + $(SED) -i -r -e 's%("Content-Type: text/plain; charset=)(.*)(\\n")%\1UTF-8\3%' $(DOMAIN).pot +msg-stats: + @pot_count=`$(MSGFMT) --statistics $(DOMAIN).pot 2>&1 | \ + $(AWK) '{match($$0, /([0-9]+) translated messages, ([0-9]+) untranslated messages/, groups); \ + printf "%s\n", groups[2];}'` ; \ + echo "$(DOMAIN).pot has $$pot_count messages" ; \ + for po_file in $(po_files); do \ + $(MSGCMP) $$po_file $(DOMAIN).pot 2>&1 | \ + $(AWK) -v po_file=$$po_file -v pot_count=$$pot_count -v pot_file=$(DOMAIN).pot \ + 'BEGIN {po_untranslated=0; undefined=0;} \ + /this message is untranslated/ {po_untranslated++} \ + /this message is used but not defined/ {undefined++} \ + END {untranslated = po_untranslated+undefined; \ + translated = pot_count - untranslated; \ + ratio = sprintf("%d/%d", translated, pot_count); \ + printf "%-7s %8s %5.1f%% %4d po untranslated, %4d missing, %4d untranslated\n", \ + po_file ":", ratio, translated/pot_count*100.0, po_untranslated, undefined, untranslated;}'; \ + done + install: $(mo_files) @for lang in $(languages); do \ dstdir=$(DESTDIR)$(localedir)/$$lang/LC_MESSAGES; \ @@ -249,7 +270,7 @@ distclean: clean test_lang: rm -rf test.po test_locale $(MSGINIT) --no-translator -i $(DOMAIN).pot -l en_US -o test.po - sed -i -r -e 's/^msgstr[ \t]+"(.*)"[ \t]*$$/msgstr "\xe2\x86\x92\1\xe2\x86\x90"/' test.po + $(SED) -i -r -e 's/^msgstr[ \t]+"(.*)"[ \t]*$$/msgstr "\xe2\x86\x92\1\xe2\x86\x90"/' test.po $(MKDIR_P) test_locale/en_US/LC_MESSAGES $(MSGFMT) -o test_locale/en_US/LC_MESSAGES/ipa.mo test.po -- cgit