Skip to content

Commit 95a8b67

Browse files
dschospearce
authored andcommitted
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>
1 parent 9a25ae8 commit 95a8b67

File tree

1 file changed

+20
-2
lines changed

1 file changed

+20
-2
lines changed

po/po2msg.sh

Lines changed: 20 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -26,11 +26,17 @@ proc u2a {s} {
2626
set output_directory "."
2727
set lang "dummy"
2828
set files [list]
29+
set show_statistics 0
2930

3031
# parse options
31-
for {set i 1} {$i < $argc} {incr i} {
32+
for {set i 0} {$i < $argc} {incr i} {
3233
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
3440
continue
3541
}
3642
if {$arg == "-l"} {
@@ -49,12 +55,14 @@ for {set i 1} {$i < $argc} {incr i} {
4955

5056
proc flush_msg {} {
5157
global msgid msgstr mode lang out fuzzy
58+
global translated_count fuzzy_count not_translated_count
5259

5360
if {![info exists msgid] || $mode == ""} {
5461
return
5562
}
5663
set mode ""
5764
if {$fuzzy == 1} {
65+
incr fuzzy_count
5866
set fuzzy 0
5967
return
6068
}
@@ -63,15 +71,20 @@ proc flush_msg {} {
6371
set prefix "set ::msgcat::header"
6472
} else {
6573
if {$msgstr == ""} {
74+
incr not_translated_count
6675
return
6776
}
6877
set prefix "::msgcat::mcset $lang \"[u2a $msgid]\""
78+
incr translated_count
6979
}
7080

7181
puts $out "$prefix \"[u2a $msgstr]\""
7282
}
7383

7484
set fuzzy 0
85+
set translated_count 0
86+
set fuzzy_count 0
87+
set not_translated_count 0
7588
foreach file $files {
7689
regsub "^.*/\(\[^/\]*\)\.po$" $file "$output_directory\\1.msg" outfile
7790
set in [open $file "r"]
@@ -113,3 +126,8 @@ foreach file $files {
113126
close $out
114127
}
115128

129+
if {$show_statistics} {
130+
puts [concat "$translated_count translated messages, " \
131+
"$fuzzy_count fuzzy ones, " \
132+
"$not_translated_count untranslated ones."]
133+
}

0 commit comments

Comments
 (0)