diff plugins/plugin_xep_0065.py @ 69:86f1f7f6d332

i18n first draft - gettext support added in SàT - first draft of french translation - added README with a HOWTO for translators
author Goffi <goffi@goffi.org>
date Wed, 03 Mar 2010 17:12:23 +1100
parents d46f849664aa
children f271fff3a713
line wrap: on
line diff
--- a/plugins/plugin_xep_0065.py	Thu Feb 25 17:09:18 2010 +1100
+++ b/plugins/plugin_xep_0065.py	Wed Mar 03 17:12:23 2010 +1100
@@ -86,7 +86,7 @@
 "protocols": ["XEP-0065"],
 "main": "XEP_0065",
 "handler": "yes",
-"description": """Implementation of SOCKS5 Bytestreams"""
+"description": _("""Implementation of SOCKS5 Bytestreams""")
 }
 
 STATE_INITIAL = 0
@@ -132,7 +132,7 @@
 
 class SOCKSv5(protocol.Protocol, FileSender):
     def __init__(self):
-        debug("Protocol init")
+        debug(_("Protocol init"))
         self.state = STATE_INITIAL
         self.buf = ""
         self.supportedAuthMechs = [ AUTHMECH_ANON ]
@@ -214,7 +214,7 @@
         self.transport.loseConnection()
     
     def addConnection(self, address, connection):
-        info("Adding connection: %s, %s", address, connection)
+        info(_("Adding connection: %(address)s, %(connection)s") % {'address':address, 'connection':connection})
         olist = self.pendingConns.get(address, [])
         if len(olist) <= 1:
             olist.append(connection)
@@ -310,7 +310,7 @@
                 self.loseConnection()
                 return
 
-            debug("Saving file in %s.", self.data["dest_path"])
+            debug(_("Saving file in %s."), self.data["dest_path"])
             self.dest_file = open(self.data["dest_path"], 'w')
             self.state = STATE_TARGET_READY
             self.activateCB(self.target_jid, self.initiator_jid, self.sid, self.IQ_id, self.xmlstream)
@@ -328,7 +328,7 @@
             self._startNegotiation()
 
     def connectRequested(self, addr, port):
-        debug(("connectRequested"))
+        debug("connectRequested")
         # Check for special connect to the namespace -- this signifies that the client
         # is just checking to ensure it can connect to the streamhost
         if addr == "http://jabber.org/protocol/bytestreams":
@@ -361,7 +361,7 @@
             data["position"] = ""
 
     def fileTransfered(self, d):
-        info("File transfer completed, closing connection")
+        info(_("File transfer completed, closing connection"))
         self.transport.loseConnection()
 
     def updateTransfered(self, data):
@@ -435,20 +435,20 @@
 
 
     def startedConnecting(self, connector):
-        debug ("Socks 5 server connection started")
+        debug (_("Socks 5 server connection started"))
 
     def clientConnectionLost(self, connector, reason):
-        debug ("Socks 5 server connection lost (reason: %s)", reason)
+        debug (_("Socks 5 server connection lost (reason: %s)"), reason)
 
 class Socks5ClientFactory(protocol.ClientFactory):
     protocol = SOCKSv5
     protocol.mode = "target"  #FIXME: Q&D way, fix it 
 
     def startedConnecting(self, connector):
-        debug ("Socks 5 client connection started")
+        debug (_("Socks 5 client connection started"))
 
     def clientConnectionLost(self, connector, reason):
-        debug ("Socks 5 client connection lost (reason: %s)", reason)
+        debug (_("Socks 5 client connection lost (reason: %s)"), reason)
 
 
 class XEP_0065():
@@ -465,9 +465,9 @@
     """
 
     def __init__(self, host):
-        info("Plugin XEP_0065 initialization")
+        info(_("Plugin XEP_0065 initialization"))
         self.host = host
-        debug("registering")
+        debug(_("registering"))
         self.server_factory = Socks5ServerFactory()
         self.server_factory.protocol.host = self.host #needed for progress CB
         self.client_factory = Socks5ClientFactory()
@@ -477,7 +477,7 @@
         host.memory.setDefault("IP", "File Transfert", self.getExternalIP)
         
         port = int(self.host.memory.getParamA("Port", "File Transfert"))
-        info("Launching Socks5 Stream server on port %d", port)
+        info(_("Launching Socks5 Stream server on port %d"), port)
         reactor.listenTCP(port, self.server_factory)
     
     def getHandler(self):
@@ -493,7 +493,7 @@
         
     def sendFile(self, id, filepath, size):
         #lauching socks5 initiator
-        debug("Launching socks5 initiator")
+        debug(_("Launching socks5 initiator"))
         self.server_factory.protocol.mode = "initiator"
         self.server_factory.protocol.filepath = filepath
         self.server_factory.protocol.filesize = size
@@ -508,7 +508,7 @@
         IQ_id = iq['id']
         for element in SI_elem.elements():
             if element.name == "streamhost":
-                info ("Stream proposed: host=[%s] port=[%s]", element['host'], element['port'])
+                info (_("Stream proposed: host=[%(host)s] port=[%(post)s]") % {'host':element['host'], 'port':element['port']})
                 factory = self.client_factory
                 self.server_factory.protocol.mode = "target"
                 factory.protocol.host = self.host #needed for progress CB
@@ -524,7 +524,7 @@
                 reactor.connectTCP(element['host'], int(element['port']), factory)
                 
     def activateStream(self, from_jid, to_jid, sid, IQ_id, xmlstream):
-        debug("activating stream")
+        debug(_("activating stream"))
         result = domish.Element(('', 'iq'))
         result['type'] = 'result'
         result['id'] = IQ_id