aboutsummaryrefslogtreecommitdiffstats
path: root/SQLiteStudio3/lang.tcl
diff options
context:
space:
mode:
authorLibravatarUnit 193 <unit193@ubuntu.com>2015-04-04 14:41:10 -0400
committerLibravatarUnit 193 <unit193@ubuntu.com>2015-04-04 14:41:10 -0400
commitb5f93b05578293d1d233b4920a28a5c2fd826f94 (patch)
tree82332679f647e9c76e331206786d07a58dcfa9b8 /SQLiteStudio3/lang.tcl
parentaf8a7a3e3dccf9c9ad257e3952173d180c8a7421 (diff)
parenta5b034d4a9c44f9bc1e83b01de82530f8fc63013 (diff)
Merge tag 'upstream/3.0.4'
Upstream version 3.0.4 # gpg: Signature made Sat 04 Apr 2015 02:41:09 PM EDT using RSA key ID EBE9BD91 # gpg: Good signature from "Unit 193 <unit193@gmail.com>" # gpg: aka "Unit 193 <unit193@ninthfloor.org>" # gpg: aka "Unit 193 <unit193@ubuntu.com>" # gpg: aka "Unit 193 <unit193@ninthfloor.com>"
Diffstat (limited to 'SQLiteStudio3/lang.tcl')
-rwxr-xr-xSQLiteStudio3/lang.tcl52
1 files changed, 51 insertions, 1 deletions
diff --git a/SQLiteStudio3/lang.tcl b/SQLiteStudio3/lang.tcl
index d9cacf9..00fd151 100755
--- a/SQLiteStudio3/lang.tcl
+++ b/SQLiteStudio3/lang.tcl
@@ -2,7 +2,7 @@
proc usage {} {
puts "$::argv0 (add|remove) <lang_name>"
- puts "$::argv0 (update|release)"
+ puts "$::argv0 (update|release|status)"
}
lassign $argv op lang
@@ -13,6 +13,41 @@ if {$::tcl_platform(platform) == "windows"} {
set ERR_NULL "2>/dev/null"
}
+proc countstrings {data search} {
+ set l [string length $search]
+ set count 0
+ while {[set i [string first $search $data]]>=0} {
+ incr count
+ incr i $l
+ set data [string range $data $i end]
+ }
+ set count
+}
+
+proc scanLangs {} {
+ set langs [dict create]
+ foreach f [exec find .. -name "*.ts"] {
+ set lang [lindex [regexp -inline {[^_]*_(\w+(\w+)?).ts$} $f] 1]
+ if {[dict exists $langs $lang]} {
+ set langDict [dict get $langs $lang]
+ } else {
+ set langDict [dict create translated 0 untranslated 0]
+ }
+
+ set fd [open $f r]
+ set data [read $fd]
+ close $fd
+
+ set c1 [countstrings $data "<translation>"]
+ set c2 [countstrings $data "<translation type=\"unfinished\">"]
+ dict incr langDict translated $c1
+ dict incr langDict untranslated $c2
+ dict set langs $lang $langDict
+ }
+
+ return $langs
+}
+
switch -- $op {
"update" - "release" {
if {$argc != 1} {
@@ -61,6 +96,21 @@ switch -- $op {
}
}
}
+ "status" {
+ set langs [scanLangs]
+ foreach k [dict keys $langs] {
+ set lang [dict get $langs $k]
+ set tr [dict get $lang translated]
+ set untr [dict get $lang untranslated]
+ set all [expr {$tr + $untr}]
+ if {$all == 0} continue
+
+ set perc [expr {round(double($tr)/$all * 1000)/10.0}]
+
+ set lang [string tolower $lang]
+ puts "$k - ${perc}% ($tr / $all)"
+ }
+ }
"add" - "remove" {
if {$argc != 2} {
usage