@matheusbsbs / matheus-bagliano / commits / 95a8b67c26
Fork 0

po2msg: actually output statistics

The "--statistics" option was ignored so far; no longer. Now we have a message similar to that of msgfmt. (Untranslated, though ;-) Signed-off-by: Johannes Schindelin <johannes.schindelin@gmx.de> Signed-off-by: Shawn O. Pearce <spearce@spearce.org>

Johannes Schindelin committed Oct 30, 2007 at 11:25 UTC 95a8b67c2642c576f848005e72126fb25d11286c
1 file changed +20 -2
po/po2msg.sh
+20 -2
@@ -26,11 +26,17 @@ proc u2a {s} {
26 set output_directory "."
27 set lang "dummy"
28 set files [list]
29 +set show_statistics 0
30
31 # parse options
31 -for {set i 1} {$i < $argc} {incr i} {
32 +for {set i 0} {$i < $argc} {incr i} {
33 set arg [lindex $argv $i]
33 - if {$arg == "--statistics" || $arg == "--tcl"} {
34 + if {$arg == "--statistics"} {
35 + incr show_statistics
36 + continue
37 + }
38 + if {$arg == "--tcl"} {
39 + # we know
40 continue
41 }
42 if {$arg == "-l"} {
@@ -49,12 +55,14 @@ for {set i 1} {$i < $argc} {incr i} {
55
56 proc flush_msg {} {
57 global msgid msgstr mode lang out fuzzy
58 + global translated_count fuzzy_count not_translated_count
59
60 if {![info exists msgid] || $mode == ""} {
61 return
62 }
63 set mode ""
64 if {$fuzzy == 1} {
65 + incr fuzzy_count
66 set fuzzy 0
67 return
68 }
@@ -63,15 +71,20 @@ proc flush_msg {} {
71 set prefix "set ::msgcat::header"
72 } else {
73 if {$msgstr == ""} {
74 + incr not_translated_count
75 return
76 }
77 set prefix "::msgcat::mcset $lang \"[u2a $msgid]\""
78 + incr translated_count
79 }
80
81 puts $out "$prefix \"[u2a $msgstr]\""
82 }
83
84 set fuzzy 0
85 +set translated_count 0
86 +set fuzzy_count 0
87 +set not_translated_count 0
88 foreach file $files {
89 regsub "^.*/\(\[^/\]*\)\.po$" $file "$output_directory\\1.msg" outfile
90 set in [open $file "r"]
@@ -113,3 +126,8 @@ foreach file $files {
126 close $out
127 }
128
129 +if {$show_statistics} {
130 + puts [concat "$translated_count translated messages, " \
131 + "$fuzzy_count fuzzy ones, " \
132 + "$not_translated_count untranslated ones."]
133 +}