Commits

Anonymous committed 95a8b67

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>

Comments (0)

Files changed (1)

 set output_directory "."
 set lang "dummy"
 set files [list]
+set show_statistics 0
 
 # parse options
-for {set i 1} {$i < $argc} {incr i} {
+for {set i 0} {$i < $argc} {incr i} {
 	set arg [lindex $argv $i]
-	if {$arg == "--statistics" || $arg == "--tcl"} {
+	if {$arg == "--statistics"} {
+		incr show_statistics
+		continue
+	}
+	if {$arg == "--tcl"} {
+		# we know
 		continue
 	}
 	if {$arg == "-l"} {
 
 proc flush_msg {} {
 	global msgid msgstr mode lang out fuzzy
+	global translated_count fuzzy_count not_translated_count
 
 	if {![info exists msgid] || $mode == ""} {
 		return
 	}
 	set mode ""
 	if {$fuzzy == 1} {
+		incr fuzzy_count
 		set fuzzy 0
 		return
 	}
 		set prefix "set ::msgcat::header"
 	} else {
 		if {$msgstr == ""} {
+			incr not_translated_count
 			return
 		}
 		set prefix "::msgcat::mcset $lang \"[u2a $msgid]\""
+		incr translated_count
 	}
 
 	puts $out "$prefix \"[u2a $msgstr]\""
 }
 
 set fuzzy 0
+set translated_count 0
+set fuzzy_count 0
+set not_translated_count 0
 foreach file $files {
 	regsub "^.*/\(\[^/\]*\)\.po$" $file "$output_directory\\1.msg" outfile
 	set in [open $file "r"]
 	close $out
 }
 
+if {$show_statistics} {
+	puts [concat "$translated_count translated messages, " \
+		"$fuzzy_count fuzzy ones, " \
+		"$not_translated_count untranslated ones."]
+}
Tip: Filter by directory path e.g. /media app.js to search for public/media/app.js.
Tip: Use camelCasing e.g. ProjME to search for ProjectModifiedEvent.java.
Tip: Filter by extension type e.g. /repo .js to search for all .js files in the /repo directory.
Tip: Separate your search with spaces e.g. /ssh pom.xml to search for src/ssh/pom.xml.
Tip: Use ↑ and ↓ arrow keys to navigate and return to view the file.
Tip: You can also navigate files with Ctrl+j (next) and Ctrl+k (previous) and view the file with Ctrl+o.
Tip: You can also navigate files with Alt+j (next) and Alt+k (previous) and view the file with Alt+o.