Mercurial > libervia-backend
diff plugins/plugin_xep_0077.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 | 783e9d6980ec |
line wrap: on
line diff
--- a/plugins/plugin_xep_0077.py Thu Feb 25 17:09:18 2010 +1100 +++ b/plugins/plugin_xep_0077.py Wed Mar 03 17:12:23 2010 +1100 @@ -38,13 +38,13 @@ "protocols": ["XEP-0077"], "dependencies": [], "main": "XEP_0077", -"description": """Implementation of in-band registration""" +"description": _("""Implementation of in-band registration""") } class XEP_0077(): def __init__(self, host): - info("Plugin XEP_0077 initialization") + info(_("Plugin XEP_0077 initialization")) self.host = host self.triggers = {} #used by other protocol (e.g. XEP-0100) to finish registration. key = target_jid host.bridge.addMethod("in_band_register", ".communication", in_sign='ss', out_sign='s', method=self.in_band_register) @@ -59,10 +59,10 @@ try: x_elem = filter (lambda x:x.name == "x", answer.firstChildElement().elements())[0] #We only want the "x" element (data form) except IndexError: - info("No data form found") + info(_("No data form found")) #TODO: manage registration without data form answer_data = {} - answer_data={"reason": "unmanaged", "message":"This gateway can't be managed by SàT, sorry :("} + answer_data={"reason": "unmanaged", "message":_("This gateway can't be managed by SàT, sorry :(")} answer_type = "ERROR" self.host.bridge.actionResult(answer_type, answer['id'], answer_data) return @@ -73,7 +73,7 @@ def reg_err(self, failure): """Called when something is wrong with registration""" - info ("Registration failure: %s" % str(failure.value)) + info (_("Registration failure: %s") % str(failure.value)) answer_data = {} answer_data['reason'] = 'unknown' answer_data={"message":"%s [code: %s]" % (failure.value.condition, failure.value.code)} @@ -81,39 +81,39 @@ self.host.bridge.actionResult(answer_type, failure.value.stanza['id'], answer_data) def unregistrationAnswer(self, answer): - debug ("registration answer: %s" % answer.toXml()) + debug (_("registration answer: %s") % answer.toXml()) answer_type = "SUCCESS" - answer_data={"message":"Your are now unregistred"} + answer_data={"message":_("Your are now unregistred")} self.host.bridge.actionResult(answer_type, answer['id'], answer_data) def unregistrationFailure(self, failure): - info ("Unregistration failure: %s" % str(failure.value)) + info (_("Unregistration failure: %s") % str(failure.value)) answer_type = "ERROR" answer_data = {} answer_data['reason'] = 'unknown' - answer_data={"message":"Unregistration failed: %s" % failure.value.condition} + answer_data={"message":_("Unregistration failed: %s") % failure.value.condition} self.host.bridge.actionResult(answer_type, failure.value.stanza['id'], answer_data) def registrationAnswer(self, answer): - debug ("registration answer: %s" % answer.toXml()) + debug (_("registration answer: %s") % answer.toXml()) answer_type = "SUCCESS" - answer_data={"message":"Registration successfull"} + answer_data={"message":_("Registration successfull")} self.host.bridge.actionResult(answer_type, answer['id'], answer_data) if self.triggers.has_key(answer["from"]): self.triggers[answer["from"]](answer["from"]) del self.triggers[answer["from"]] def registrationFailure(self, failure): - info ("Registration failure: %s" % str(failure.value)) + info (_("Registration failure: %s") % str(failure.value)) print failure.value.stanza.toXml() answer_type = "ERROR" answer_data = {} if failure.value.condition == 'conflict': answer_data['reason'] = 'conflict' - answer_data={"message":"Username already exists, please choose an other one"} + answer_data={"message":_("Username already exists, please choose an other one")} else: answer_data['reason'] = 'unknown' - answer_data={"message":"Registration failed"} + answer_data={"message":_("Registration failed")} self.host.bridge.actionResult(answer_type, failure.value.stanza['id'], answer_data) if self.triggers.has_key(answer["from"]): del self.triggers[answer["from"]] @@ -131,10 +131,10 @@ """register to a target JID""" current_jid, xmlstream = self.host.getJidNStream(profile_key) if not xmlstream: - error ('Asking profile for an non-existant or not connected profile') + error (_('Asking for an non-existant or not connected profile')) return "" to_jid = jid.JID(target) - debug("Asking registration for [%s]" % to_jid.full()) + debug(_("Asking registration for [%s]") % to_jid.full()) reg_request=IQ(xmlstream,'get') reg_request["from"]=current_jid.full() reg_request["to"] = to_jid.full()