i18n first draft

- gettext support added in SàT
- first draft of french translation
- added README with a HOWTO for translators
This commit is contained in:
Goffi 2010-03-03 17:12:23 +11:00
commit 4a293cdaa1

View file

@ -34,13 +34,13 @@ PLUGIN_INFO = {
"protocols": ["XEP-0100"],
"dependencies": ["XEP_0077"],
"main": "XEP_0100",
"description": """Implementation of Gateways protocol"""
"description": _("""Implementation of Gateways protocol""")
}
class XEP_0100():
def __init__(self, host):
info("Gateways plugin initialization")
info(_("Gateways plugin initialization"))
self.host = host
self.__gateways = {} #dict used to construct the answer to findGateways. Key = target jid
host.bridge.addMethod("findGateways", ".communication", in_sign='ss', out_sign='s', method=self.findGateways)
@ -50,7 +50,7 @@ class XEP_0100():
self.__gateways[request_id]['__handled_items']+=1
if self.__gateways[request_id]['__total_items'] == self.__gateways[request_id]['__handled_items']:
debug ("All items checked for id [%s]" % str(request_id))
debug (_("All items checked for id [%s]") % str(request_id))
del self.__gateways[request_id]['__total_items']
del self.__gateways[request_id]['__handled_items']
@ -61,7 +61,7 @@ class XEP_0100():
for identity in disco.identities:
if identity[0] == 'gateway':
print ("Found gateway (%s): %s" % (entity.full(), disco.identities[identity]))
print (_("Found gateway (%(jid)s): %(identity)s") % {'jid':entity.full(), 'identity':disco.identities[identity]})
self.__gateways[request_id][entity.full()] = {
'name':disco.identities[identity],
'type':identity[1]
@ -72,7 +72,7 @@ class XEP_0100():
def discoInfoErr(self, failure, entity, request_id):
"""Something is going wrong with disco"""
failure.trap(jab_error.StanzaError)
error("Error when discovering [%s]: %s" % (entity.full(), failure.value.condition))
error(_("Error when discovering [%(jid)s]: %(condition)s") % {'jid':entity.full(), 'condition':failure.value.condition})
self.__inc_handled_items(request_id)
@ -81,19 +81,19 @@ class XEP_0100():
#FIXME: target is used as we can't find the original iq node (parent is None)
# an other way would avoid this useless parameter (is there a way with wokkel ?)
if len(disco._items) == 0:
debug ("No gateway found")
debug (_("No gateway found"))
self.host.actionResultExt(request_id,"DICT_DICT",{})
return
self.__gateways[request_id] = {'__total_items':len(disco._items), '__handled_items':0, '__private__':{'target':target.full()}}
for item in disco._items:
debug ("item found: %s", item.name)
debug (_("item found: %s"), item.name)
client.disco.requestInfo(item.entity).addCallback(self.discoInfo, entity=item.entity, request_id=request_id)
client.disco.requestInfo(item.entity).addErrback(self.discoInfoErr, entity=item.entity, request_id=request_id)
def registrationSuccessful(self, target):
"""Called when in_band registration is ok, we must now follow the rest of procedure"""
print "Registration successful, doing the rest"
debug (_("Registration successful, doing the rest"))
self.host.addContact(target)
self.host.setPresence(target)
@ -109,9 +109,8 @@ class XEP_0100():
"""
client = self.host.getClient(profile_key)
assert(client)
print "target ===>", target
to_jid = jid.JID(target)
debug ("find gateways (target = %s)" % to_jid.full())
debug (_("find gateways (target = %s)") % to_jid.full())
request_id = self.host.get_next_id()
client.disco.requestItems(to_jid).addCallback(self.discoItems, request_id=request_id, target = to_jid, client = client)
return request_id