3 # We check each tranlated message against its original,
4 # making certain consistency checks.
6 # In theory this would be easy: we could read the .po file
7 # directly. But the format of the .po file is not documented.
8 # Looking at the source code for the po parser in GNU gettext,
9 # the syntax is complicated with a wide variety of escapes.
11 # So I would prefer to reuse the gettext parser. That means getting
12 # the output from gettext in some other format. Most of the gettext
13 # utilities output in annoying formats. The least annoying seems
14 # to be to use msgfmt to generate a tcl file (!)
18 # ./pairwise-potcheck [LANG]
21 puts stderr "usage: ./pairwise-pocheck [LANG]"
30 global po for_emsg bad
31 puts stderr "$po: $emsg $for_emsg"
35 proc check_equal {desc script} {
38 set m [uplevel 1 [list set msg$is]]
40 set r$is [uplevel 1 $script]
42 if {![string compare $rid $rstr]} { return 0 }
43 bad "mismatch $rid != $rstr $desc"
46 # called directly by msgfmt output
47 namespace eval ::msgcat {
48 proc mcset {lang msgid msgstr} {
49 check_msg $msgid $msgstr
53 proc check_msg {msgid msgstr} {
55 set for_emsg "msgid=[list $msgid] msgstr=[list $msgstr]"
56 check_equal "un-escaped non-pod < count (missing B or I?)" {
57 regexp -all {(?!\b[IBCLEFSXZ])\<} $m
62 # msgfmt --tcl wants to use a pretty much fixed filename:
63 # you get to specify part of it but it has to look like a
64 # locale. But we can specify ya directory to use, so
65 # one directory per po it is!
67 set vexdir ".$po.pwpc.tmp"
69 set vexfile $vexdir/$vexleaf
72 exec msgfmt -d$vexdir -lxx --tcl $po
74 # and then we execute it!
80 switch -glob [llength $argv].$argv {
83 1.* { set lang [lindex $argv 0] }
91 foreach po [lsort [glob -nocomplain *.$lang.po]] {
93 puts "pairwise-pocheck $po ok."
100 puts stderr "pairwise-pocheck: $bad errors"