Multilang support and cleaning for "en" locale

darcs-hash:20061122181456-86b55-3481c0c487ec5d9122e753cb4fdaf4db44cda0c3.gz
This commit is contained in:
David Rousselie
2006-11-22 19:14:56 +01:00
parent 062abf00b7
commit c0d0b29654
3 changed files with 46 additions and 46 deletions

View File

@@ -94,7 +94,7 @@ class JCLComponent(Component, object):
self.disco_info.add_feature("jabber:iq:version") self.disco_info.add_feature("jabber:iq:version")
self.disco_info.add_feature("jabber:iq:register") self.disco_info.add_feature("jabber:iq:register")
self.__logger = logging.getLogger("jcl.jabber.JCLComponent") self.__logger = logging.getLogger("jcl.jabber.JCLComponent")
self.__lang = Lang() # TODO : Lang(default_lang = from_config) self.lang = Lang()
self.running = False self.running = False
signal.signal(signal.SIGINT, self.signal_handler) signal.signal(signal.SIGINT, self.signal_handler)
@@ -295,7 +295,7 @@ class JCLComponent(Component, object):
"""Send back register form to user """Send back register form to user
""" """
self.__logger.debug("GET_REGISTER") self.__logger.debug("GET_REGISTER")
lang_class = self.__lang.get_lang_class_from_node(info_query.get_node()) lang_class = self.lang.get_lang_class_from_node(info_query.get_node())
base_from_jid = unicode(info_query.get_from().bare()) base_from_jid = unicode(info_query.get_from().bare())
to_jid = info_query.get_to() to_jid = info_query.get_to()
name = to_jid.node name = to_jid.node
@@ -344,7 +344,7 @@ class JCLComponent(Component, object):
""" """
self.__logger.debug("SET_REGISTER") self.__logger.debug("SET_REGISTER")
lang_class = \ lang_class = \
self.__lang.get_lang_class_from_node(info_query.get_node()) self.lang.get_lang_class_from_node(info_query.get_node())
from_jid = info_query.get_from() from_jid = info_query.get_from()
base_from_jid = unicode(from_jid.bare()) base_from_jid = unicode(from_jid.bare())
remove = info_query.xpath_eval("r:query/r:remove", \ remove = info_query.xpath_eval("r:query/r:remove", \
@@ -424,7 +424,7 @@ class JCLComponent(Component, object):
from_jid = stanza.get_from() from_jid = stanza.get_from()
base_from_jid = unicode(from_jid.bare()) base_from_jid = unicode(from_jid.bare())
name = stanza.get_to().node name = stanza.get_to().node
lang_class = self.__lang.get_lang_class_from_node(stanza.get_node()) lang_class = self.lang.get_lang_class_from_node(stanza.get_node())
show = stanza.get_show() show = stanza.get_show()
self.__logger.debug("SHOW : " + str(show)) self.__logger.debug("SHOW : " + str(show))
if name: if name:
@@ -433,7 +433,6 @@ class JCLComponent(Component, object):
if not name: if not name:
accounts = self.account_class.select(\ accounts = self.account_class.select(\
self.account_class.q.user_jid == base_from_jid) self.account_class.q.user_jid == base_from_jid)
# TODO: Translate
accounts_length = 0 accounts_length = 0
for _account in accounts: for _account in accounts:
accounts_length += 1 accounts_length += 1
@@ -442,7 +441,7 @@ class JCLComponent(Component, object):
to_jid = from_jid, \ to_jid = from_jid, \
status = \ status = \
str(accounts_length) \ str(accounts_length) \
+ " accounts registered.", \ + lang_class.message_status, \
show = show, \ show = show, \
stanza_type = "available") stanza_type = "available")
self.stream.send(presence) self.stream.send(presence)
@@ -537,7 +536,7 @@ class JCLComponent(Component, object):
Handle password response message Handle password response message
""" """
self.__logger.debug("MESSAGE: " + message.get_body()) self.__logger.debug("MESSAGE: " + message.get_body())
lang_class = self.__lang.get_lang_class_from_node(message.get_node()) lang_class = self.lang.get_lang_class_from_node(message.get_node())
name = message.get_to().node name = message.get_to().node
base_from_jid = unicode(message.get_from().bare()) base_from_jid = unicode(message.get_from().bare())
self.db_connect() self.db_connect()
@@ -596,9 +595,9 @@ class JCLComponent(Component, object):
to_jid = _account.user_jid, \ to_jid = _account.user_jid, \
stanza_type = "normal", \ stanza_type = "normal", \
subject = u"[PASSWORD] " + \ subject = u"[PASSWORD] " + \
lang_class.ask_password_subject)#, \ lang_class.ask_password_subject, \
## body = lang_class.ask_password_body)# % \ body = lang_class.ask_password_body % \
## (account.host, account.login)) (_account.name))
self.stream.send(msg) self.stream.send(msg)
def get_jid(self, _account): def get_jid(self, _account):

View File

@@ -65,44 +65,44 @@ class Lang:
class en: class en:
register_title = u"Jabber Mail connection registration" register_title = u"Jabber Mail connection registration"
register_instructions = u"Enter connection parameters" register_instructions = u"Enter connection parameters"
message_status = u" accounts registered."
account_name = u"Connection name" account_name = u"Connection name"
account_login = u"Login"
account_password = u"Password"
account_password_store = u"Store password on Jabber server?"
account_host = u"Host"
account_port = u"Port"
account_type = u"Mail server type"
account_mailbox = u"Mailbox path (IMAP)"
account_ffc_action = u"Action when state is 'Free For Chat'"
account_online_action = u"Action when state is 'Online'"
account_away_action = u"Action when state is 'Away'"
account_xa_action = u"Action when state is 'Not Available'"
account_dnd_action = u"Action when state is 'Do not Disturb'"
account_offline_action = u"Action when state is 'Offline'"
account_check_interval = u"Mail check interval (in minutes)"
account_live_email_only = u"Reports only emails received while " \
u"connected to Jabber"
action_nothing = u"Do nothing"
action_retrieve = u"Retrieve mail"
action_digest = u"Send mail digest"
update_title = u"Jabber mail connection update"
update_instructions = u"Modifying connection '%s'"
connection_label = u"%s connection '%s'"
update_account_message_subject = u"Updated account '%s'"
update_account_message_body = u"Updated account"
new_account_message_subject = u"New account '%s' created"
new_account_message_body = u"New account created"
ask_password_subject = u"Password request"
ask_password_body = u"Reply to this message with the password " \
"for the following account: \n" \
"\thost = %s\n" \
"\tlogin = %s\n"
password_saved_for_session = u"Password will be kept during your " \ password_saved_for_session = u"Password will be kept during your " \
u"Jabber session" u"Jabber session"
check_error_subject = u"Error while checking emails." ask_password_subject = u"Password request"
check_error_body = u"An error appears while checking emails:\n\t%s" ask_password_body = u"Reply to this message with the password " \
new_mail_subject = u"New email from %s" "for account %s\n"
new_digest_subject = u"%i new email(s)" new_account_message_subject = u"New account '%s' created"
new_account_message_body = u"New account created"
# account_login = u"Login"
# account_password = u"Password"
# account_password_store = u"Store password on Jabber server?"
# account_host = u"Host"
# account_port = u"Port"
# account_type = u"Mail server type"
# account_mailbox = u"Mailbox path (IMAP)"
# account_ffc_action = u"Action when state is 'Free For Chat'"
# account_online_action = u"Action when state is 'Online'"
# account_away_action = u"Action when state is 'Away'"
# account_xa_action = u"Action when state is 'Not Available'"
# account_dnd_action = u"Action when state is 'Do not Disturb'"
# account_offline_action = u"Action when state is 'Offline'"
# account_check_interval = u"Mail check interval (in minutes)"
# account_live_email_only = u"Reports only emails received while " \
# u"connected to Jabber"
# action_nothing = u"Do nothing"
# action_retrieve = u"Retrieve mail"
# action_digest = u"Send mail digest"
# update_title = u"Jabber mail connection update"
# update_instructions = u"Modifying connection '%s'"
# connection_label = u"%s connection '%s'"
# update_account_message_subject = u"Updated account '%s'"
# update_account_message_body = u"Updated account"
# check_error_subject = u"Error while checking emails."
# check_error_body = u"An error appears while checking emails:\n\t%s"
# new_mail_subject = u"New email from %s"
# new_digest_subject = u"%i new email(s)"
class fr: class fr:
register_title = u"Enregistrement d'une nouvelle connexion à un " \ register_title = u"Enregistrement d'une nouvelle connexion à un " \

View File

@@ -1073,7 +1073,8 @@ class JCLComponent_TestCase(unittest.TestCase):
"user1@test.com") "user1@test.com")
self.assertEqual(password_message.get_subject(), \ self.assertEqual(password_message.get_subject(), \
"[PASSWORD] Password request") "[PASSWORD] Password request")
self.assertEqual(password_message.get_body(), None) self.assertEqual(password_message.get_body(), \
Lang.en.ask_password_body % ("account11"))
def test_handle_presence_unavailable_to_component(self): def test_handle_presence_unavailable_to_component(self):
self.comp.stream = MockStream() self.comp.stream = MockStream()