diff options
Diffstat (limited to 'po4a')
-rw-r--r-- | po4a/.gitignore | 2 | ||||
-rw-r--r-- | po4a/Makefile | 18 | ||||
-rwxr-xr-x | po4a/list-documents | 2 | ||||
-rwxr-xr-x | po4a/pairwise-pocheck | 107 | ||||
-rw-r--r-- | po4a/po4a.cfg | 2 |
5 files changed, 126 insertions, 5 deletions
diff --git a/po4a/.gitignore b/po4a/.gitignore index e640b7e..b80fca6 100644 --- a/po4a/.gitignore +++ b/po4a/.gitignore @@ -1,5 +1,5 @@ translated preview.* -.*.po4a.cfg +.po4a.*.cfg .*.translated *.tmp diff --git a/po4a/Makefile b/po4a/Makefile index c759ce8..e88aded 100644 --- a/po4a/Makefile +++ b/po4a/Makefile @@ -75,6 +75,11 @@ # tree. # # make targets: install +# +# Check: +# +# make targets: check +# pairwise-pocheck.check default: pofiles @@ -84,6 +89,8 @@ PO4A ?= po4a all update: translated +check: po4a.cfg.check pairwise-pocheck.check + pofiles: po4a.cfg $(PO4A) --no-translations $< @@ -97,10 +104,13 @@ po4a.cfg.check: list-documents ./$< >$@.tmp diff po4a.cfg $@.tmp +pairwise-pocheck.check: + ./pairwise-pocheck + t = ../.po4a.translated-only p = ../po4a -translated-only: po4a.cfg +translated-only: po4a.cfg pairwise-pocheck.check rm -rf $t && mkdir $t cd $t && ln -s $p/*.po $p/*.pot $p/po4a.cfg . cd $t && $(PO4A) po4a.cfg @@ -114,7 +124,11 @@ translated-only: po4a.cfg .PRECIOUS: .po4a.%.cfg -preview.%: .po4a.%.cfg +pairwise-pocheck.%.check: + @tclsh /dev/null || printf ':;:; Please run apt-get install tcl\n' + ./pairwise-pocheck $* + +preview.%: .po4a.%.cfg pairwise-pocheck.%.check $S $(PO4A) $< $S ./install-documents >/dev/null .$*.translated $@ @ echo '# runes to preview the various final tranlated manpages:' diff --git a/po4a/list-documents b/po4a/list-documents index 4d625e0..9924379 100755 --- a/po4a/list-documents +++ b/po4a/list-documents @@ -13,7 +13,7 @@ cat <<END # ^ add your language here (separate with spaces) # Do not edit the rest of this file. It is automatically maintained. -[options] opt:"-MUTF-8" opt:"-k10" +[options] opt:"-MUTF-8" opt:"-LUTF-8" opt:"-k10" [po4a_paths] \$master.pot \$lang:\$master.\$lang.po END diff --git a/po4a/pairwise-pocheck b/po4a/pairwise-pocheck new file mode 100755 index 0000000..6a71f64 --- /dev/null +++ b/po4a/pairwise-pocheck @@ -0,0 +1,107 @@ +#!/usr/bin/tclsh +# +# We check each tranlated message against its original, +# making certain consistency checks. + +# In theory this would be easy: we could read the .po file +# directly. But the format of the .po file is not documented. +# Looking at the source code for the po parser in GNU gettext, +# the syntax is complicated with a wide variety of escapes. +# +# So I would prefer to reuse the gettext parser. That means getting +# the output from gettext in some other format. Most of the gettext +# utilities output in annoying formats. The least annoying seems +# to be to use msgfmt to generate a tcl file (!) + +# usage: +# cd po4a +# ./pairwise-potcheck [LANG] + +proc badusage {} { + puts stderr "usage: ./pairwise-pocheck [LANG]" + exit 1 +} + +set lang * + +set bad 0 + +proc bad {emsg} { + global po for_emsg bad + puts stderr "$po: $emsg $for_emsg" + incr bad +} + +proc check_equal {desc script} { + upvar 1 m m + foreach is {id str} { + set m [uplevel 1 [list set msg$is]] + set m$is $m + set r$is [uplevel 1 $script] + } + if {![string compare $rid $rstr]} { return 0 } + bad "mismatch $rid != $rstr $desc" +} + +# called directly by msgfmt output +namespace eval ::msgcat { + proc mcset {lang msgid msgstr} { + check_msg $msgid $msgstr + } +} + +proc check_msg {msgid msgstr} { + global for_emsg + set for_emsg "msgid=[list $msgid] msgstr=[list $msgstr]" + check_equal "un-escaped non-pod < count (missing B or I?)" { + regexp -all {(?!\b[IBCLEFSXZ])\<} $m + } +} + +proc check {} { + # msgfmt --tcl wants to use a pretty much fixed filename: + # you get to specify part of it but it has to look like a + # locale. But we can specify ya directory to use, so + # one directory per po it is! + global po + set vexdir ".$po.pwpc.tmp" + set vexleaf xx.msg + set vexfile $vexdir/$vexleaf + file mkdir $vexdir + file delete $vexfile + exec msgfmt -d$vexdir -lxx --tcl $po + + # and then we execute it! + source $vexfile +} + +proc parseargs {} { + global argv lang + switch -glob [llength $argv].$argv { + 0. { } + 1.-* { badusage } + 1.* { set lang [lindex $argv 0] } + * { badusage } + } +} + +proc iterate {} { + global po lang + + foreach po [lsort [glob -nocomplain *.$lang.po]] { + check + puts "pairwise-pocheck $po ok." + } +} + +proc report {} { + global bad + if {$bad} { + puts stderr "pairwise-pocheck: $bad errors" + exit 1 + } +} + +parseargs +iterate +report diff --git a/po4a/po4a.cfg b/po4a/po4a.cfg index a7c3e12..15e7f55 100644 --- a/po4a/po4a.cfg +++ b/po4a/po4a.cfg @@ -2,7 +2,7 @@ # ^ add your language here (separate with spaces) # Do not edit the rest of this file. It is automatically maintained. -[options] opt:"-MUTF-8" opt:"-k10" +[options] opt:"-MUTF-8" opt:"-LUTF-8" opt:"-k10" [po4a_paths] $master.pot $lang:$master.$lang.po [type: man] ../dgit.1 $lang:translated/man/$lang/man1/dgit.1 master:file=dgit_1 [type: man] ../dgit.7 $lang:translated/man/$lang/man7/dgit.7 master:file=dgit_7 |