summaryrefslogtreecommitdiffstats
path: root/install
diff options
context:
space:
mode:
authorJohn Dennis <jdennis@redhat.com>2010-02-16 10:24:31 -0500
committerRob Crittenden <rcritten@redhat.com>2010-02-19 14:53:43 -0500
commite7dbbd96b4b0c63103fa2b1ba8f77da373ced6a8 (patch)
treee7d52e3a828560c1d0d86d8fc3ce4c7a6568fad4 /install
parent7ef9cc94ed08c208df09d7a08d68e14c5472bac9 (diff)
downloadfreeipa-e7dbbd96b4b0c63103fa2b1ba8f77da373ced6a8.tar.gz
freeipa-e7dbbd96b4b0c63103fa2b1ba8f77da373ced6a8.tar.xz
freeipa-e7dbbd96b4b0c63103fa2b1ba8f77da373ced6a8.zip
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.
Diffstat (limited to 'install')
-rw-r--r--install/configure.ac7
-rw-r--r--install/po/Makefile.in31
2 files changed, 33 insertions, 5 deletions
diff --git a/install/configure.ac b/install/configure.ac
index 83579ac66..eb2d3cd13 100644
--- a/install/configure.ac
+++ b/install/configure.ac
@@ -20,6 +20,8 @@ AM_MAINTAINER_MODE
AC_SUBST(VERSION)
AC_PROG_MKDIR_P
+AC_PROG_AWK
+AC_PROG_SED
AC_PATH_PROG(XGETTEXT, xgettext, [no])
if test "x$XGETTEXT" = "xno"; then
@@ -41,6 +43,11 @@ if test "x$MSGMERGE" = "xno"; then
AC_MSG_ERROR([msgmerge not found, install gettext])
fi
+AC_PATH_PROG(MSGCMP, msgcmp, [no])
+if test "x$MSGCMP" = "xno"; then
+ AC_MSG_ERROR([msgcmp not found, install gettext])
+fi
+
AC_ARG_WITH([gettext_domain],
[AS_HELP_STRING([--with-gettext-domain=name],
[set the name of the i18n message catalog])],
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