[Tkabber-dev] r1818 - trunk/tkabber

tkabber-svn at jabber.ru tkabber-svn at jabber.ru
Mon Jul 27 22:44:03 MSD 2009


Author: sergei
Date: 2009-07-27 22:44:02 +0400 (Mon, 27 Jul 2009)
New Revision: 1818

Modified:
   trunk/tkabber/ChangeLog
   trunk/tkabber/muc.tcl
Log:
	* muc.tcl: Improved localization in affiliation and role lists windows. 


Modified: trunk/tkabber/ChangeLog
===================================================================
--- trunk/tkabber/ChangeLog	2009-07-27 18:12:37 UTC (rev 1817)
+++ trunk/tkabber/ChangeLog	2009-07-27 18:44:02 UTC (rev 1818)
@@ -7,6 +7,8 @@
 
 	* msgs/de.msg: Updated German translation (thanks to Roger Sondermann).
 
+	* muc.tcl: Improved localization in affiliation and role lists windows. 
+
 2009-07-25  Sergei Golovan  <sgolovan at nes.ru>
 
 	* plugins/general/xcommands.tcl: Made ad-hoc command window

Modified: trunk/tkabber/muc.tcl
===================================================================
--- trunk/tkabber/muc.tcl	2009-07-27 18:12:37 UTC (rev 1817)
+++ trunk/tkabber/muc.tcl	2009-07-27 18:44:02 UTC (rev 1818)
@@ -40,20 +40,28 @@
 	[::msgcat::mc "Report the list of current MUC rooms on\
 		       disco#items query."] \
 	-type boolean -group IQ
+
+    # MUC affiliations and roles:
+
+    array set e2l [list owner       [::msgcat::mc "owner"] \
+			admin       [::msgcat::mc "admin"] \
+			member      [::msgcat::mc "member"] \
+			outcast     [::msgcat::mc "outcast"] \
+			none        [::msgcat::mc "none"] \
+			moderator   [::msgcat::mc "moderator"] \
+			participant [::msgcat::mc "participant"] \
+			visitor     [::msgcat::mc "visitor"]]
+
+    variable maxl 0
+    foreach n [array names e2l] {
+	set l2e($e2l($n)) $n
+	set l [string length $e2l($n)]
+	if {$l + 2 > $maxl} {
+	    set maxl [expr {$l + 2}]
+	}
+    }
 }
 
-# MUC affiliations (for translation):
-# [::msgcat::mc "owner"]
-# [::msgcat::mc "admin"]
-# [::msgcat::mc "member"]
-# [::msgcat::mc "outcast"]
-# [::msgcat::mc "none"]
-# MUC roles (for translation):
-# [::msgcat::mc "moderator"]
-# [::msgcat::mc "participant"]
-# [::msgcat::mc "visitor"]
-# (yet another "none" omitted)
-
 ###############################################################################
 
 set ::NS(muc)       http://jabber.org/protocol/muc
@@ -548,6 +556,9 @@
 
 
 proc muc::receive_list {attr val chatid res child} {
+    variable e2l
+    variable maxl
+
     set xlib [chat::get_xlib $chatid]
     set group [chat::get_jid $chatid]
     if {![string equal $res ok]} {
@@ -567,7 +578,16 @@
 	destroy $w
     }
 
-    Dialog $w -title [::msgcat::mc "Edit %s list" $val] \
+    # [format] is intentional here. After %s substitution, it becomes
+    # one of the following:
+    # [::msgcat::mc "Edit owner list"]
+    # [::msgcat::mc "Edit admin list"]
+    # [::msgcat::mc "Edit member list"]
+    # [::msgcat::mc "Edit outcast list"]
+    # [::msgcat::mc "Edit moderator list"]
+    # [::msgcat::mc "Edit participant list"]
+    # [::msgcat::mc "Edit visitor list"]
+    Dialog $w -title [::msgcat::mc [format "Edit %s list" $val]] \
         -modal none -separator 1 -anchor e -default 0 -cancel 1 \
         -parent .
 
@@ -627,16 +647,16 @@
 
     switch -- $attr {
 	role {
-	    ComboBox $w.fr1.attr1 -text $val \
-		-values {moderator participant visitor none} \
+	    ComboBox $w.fr1.attr1 -text $e2l($val) \
+		-values [list $e2l(moderator) $e2l(participant) $e2l(visitor) $e2l(none)] \
 		-editable no \
-		-width 11
+		-width $maxl
 	}
 	affiliation {
-	    ComboBox $w.fr1.attr1 -text $val \
-		-values {owner admin member none outcast} \
+	    ComboBox $w.fr1.attr1 -text $e2l($val) \
+		-values [list $e2l(owner) $e2l(admin) $e2l(member) $e2l(none) $e2l(outcast)] \
 		-editable no \
-		-width 7
+		-width $maxl
 	}
     }
 
@@ -656,16 +676,16 @@
 
     switch -- $attr {
 	role {
-	    ComboBox $w.fr1.attr2 -text $val \
-		-values {moderator participant visitor none} \
+	    ComboBox $w.fr1.attr2 -text $e2l($val) \
+		-values [list $e2l(moderator) $e2l(participant) $e2l(visitor) $e2l(none)] \
 		-editable no \
-		-width 11
+		-width $maxl
 	}
 	affiliation {
-	    ComboBox $w.fr1.attr2 -text $val \
-		-values {owner admin member none outcast} \
+	    ComboBox $w.fr1.attr2 -text $e2l($val) \
+		-values [list $e2l(owner) $e2l(admin) $e2l(member) $e2l(none) $e2l(outcast)] \
 		-editable no \
-		-width 7
+		-width $maxl
 	}
     }
 
@@ -687,18 +707,18 @@
 
     switch -- $attr {
 	role {
-	    ComboBox $w.roleall -text $val \
-		-values {moderator participant visitor none} \
+	    ComboBox $w.roleall -text $e2l($val) \
+		-values [list $e2l(moderator) $e2l(participant) $e2l(visitor) $e2l(none)] \
 		-editable no \
-		-width 11 \
+		-width $maxl \
 		-modifycmd [list muc::change_all_items $lb $w.roleall $attr]
 	    pack $w.roleall -side left -anchor w -in $w.fr1.fr -pady 1m
 	}
 	affiliation {
-	    ComboBox $w.affiliationall -text $val \
-		-values {owner admin member none outcast} \
+	    ComboBox $w.affiliationall -text $e2l($val) \
+		-values [list $e2l(owner) $e2l(admin) $e2l(member) $e2l(none) $e2l(outcast)] \
 		-editable no \
-		-width 7 \
+		-width $maxl \
 		-modifycmd [list muc::change_all_items $lb $w.affiliationall $attr]
 	    pack $w.affiliationall -side left -in $w.fr1.fr -pady 1m
 	}
@@ -793,6 +813,8 @@
 proc muc::fill_list {lb items attr val} {
     variable listdata
     variable lastsort
+    variable e2l
+    variable maxl
 
     set lastsort($lb) jid
 
@@ -813,9 +835,8 @@
     switch -- $attr {
 	role {
 	    set width(3) [expr {[string length [::msgcat::mc "Role"]] + 2}]
-	    if {$width(3) < 13} {
-		# " participant "
-		set width(3) 13
+	    if {$width(3) < $maxl} {
+		set width(3) $maxl
 	    }
 	    set name(3) role
 	    $lb column add role -label [untrim [::msgcat::mc "Role"]]
@@ -823,9 +844,8 @@
 	}
 	affiliation {
 	    set width(3) [expr {[string length [::msgcat::mc "Affiliation"]] + 2}]
-	    if {$width(3) < 9} {
-		# " outcast "
-		set width(3) 9
+	    if {$width(3) < $maxl} {
+		set width(3) $maxl
 	    }
 	    set name(3) affiliation
 	    $lb column add affiliation -label [untrim [::msgcat::mc "Affiliation"]]
@@ -863,7 +883,7 @@
 			set reason $scdata
 		    }
 		}
-		lappend items2 [list $nick $jid $attribute $reason]
+		lappend items2 [list $nick $jid $e2l($attribute) $reason]
 	    }
 	}
     }
@@ -920,6 +940,8 @@
 ###############################################################################
 
 proc muc::list_add_item {lb val fr} {
+    variable e2l
+
     set n [trim [lindex [$lb get end] 0]]
     if {[string equal $n ""]} {
 	set n 0
@@ -935,7 +957,7 @@
 
     $fr.nick2 delete 0 end
     $fr.jid2 delete 0 end
-    $fr.attr2 configure -text $val
+    $fr.attr2 configure -text $e2l($val)
     $fr.reason2 delete 0 end
 }
 
@@ -943,6 +965,7 @@
 
 proc muc::send_list {chatid attr val w lb} {
     variable listdata
+    variable l2e
 
     foreach item $listdata($lb) {
 	set tmp([lrange $item 0 1]) $item
@@ -964,7 +987,7 @@
 	if {[info exists tmp([list $nick $jid])] && \
 		$tmp([list $nick $jid]) == [list $nick $jid $val $reason]} continue
 
-	set attrs [list $attr $val]
+	set attrs [list $attr $l2e($val)]
 	if {$nick != ""} {
 	    lappend attrs nick $nick
 	}



More information about the Tkabber-dev mailing list