Multilang support and cleaning for "en" locale
darcs-hash:20061122181456-86b55-3481c0c487ec5d9122e753cb4fdaf4db44cda0c3.gz
This commit is contained in:
@@ -94,7 +94,7 @@ class JCLComponent(Component, object):
|
||||
self.disco_info.add_feature("jabber:iq:version")
|
||||
self.disco_info.add_feature("jabber:iq:register")
|
||||
self.__logger = logging.getLogger("jcl.jabber.JCLComponent")
|
||||
self.__lang = Lang() # TODO : Lang(default_lang = from_config)
|
||||
self.lang = Lang()
|
||||
self.running = False
|
||||
|
||||
signal.signal(signal.SIGINT, self.signal_handler)
|
||||
@@ -295,7 +295,7 @@ class JCLComponent(Component, object):
|
||||
"""Send back register form to user
|
||||
"""
|
||||
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())
|
||||
to_jid = info_query.get_to()
|
||||
name = to_jid.node
|
||||
@@ -344,7 +344,7 @@ class JCLComponent(Component, object):
|
||||
"""
|
||||
self.__logger.debug("SET_REGISTER")
|
||||
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()
|
||||
base_from_jid = unicode(from_jid.bare())
|
||||
remove = info_query.xpath_eval("r:query/r:remove", \
|
||||
@@ -424,7 +424,7 @@ class JCLComponent(Component, object):
|
||||
from_jid = stanza.get_from()
|
||||
base_from_jid = unicode(from_jid.bare())
|
||||
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()
|
||||
self.__logger.debug("SHOW : " + str(show))
|
||||
if name:
|
||||
@@ -433,7 +433,6 @@ class JCLComponent(Component, object):
|
||||
if not name:
|
||||
accounts = self.account_class.select(\
|
||||
self.account_class.q.user_jid == base_from_jid)
|
||||
# TODO: Translate
|
||||
accounts_length = 0
|
||||
for _account in accounts:
|
||||
accounts_length += 1
|
||||
@@ -442,7 +441,7 @@ class JCLComponent(Component, object):
|
||||
to_jid = from_jid, \
|
||||
status = \
|
||||
str(accounts_length) \
|
||||
+ " accounts registered.", \
|
||||
+ lang_class.message_status, \
|
||||
show = show, \
|
||||
stanza_type = "available")
|
||||
self.stream.send(presence)
|
||||
@@ -537,7 +536,7 @@ class JCLComponent(Component, object):
|
||||
Handle password response message
|
||||
"""
|
||||
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
|
||||
base_from_jid = unicode(message.get_from().bare())
|
||||
self.db_connect()
|
||||
@@ -596,9 +595,9 @@ class JCLComponent(Component, object):
|
||||
to_jid = _account.user_jid, \
|
||||
stanza_type = "normal", \
|
||||
subject = u"[PASSWORD] " + \
|
||||
lang_class.ask_password_subject)#, \
|
||||
## body = lang_class.ask_password_body)# % \
|
||||
## (account.host, account.login))
|
||||
lang_class.ask_password_subject, \
|
||||
body = lang_class.ask_password_body % \
|
||||
(_account.name))
|
||||
self.stream.send(msg)
|
||||
|
||||
def get_jid(self, _account):
|
||||
|
||||
@@ -65,44 +65,44 @@ class Lang:
|
||||
class en:
|
||||
register_title = u"Jabber Mail connection registration"
|
||||
register_instructions = u"Enter connection parameters"
|
||||
message_status = u" accounts registered."
|
||||
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 " \
|
||||
u"Jabber session"
|
||||
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)"
|
||||
ask_password_subject = u"Password request"
|
||||
ask_password_body = u"Reply to this message with the password " \
|
||||
"for account %s\n"
|
||||
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:
|
||||
register_title = u"Enregistrement d'une nouvelle connexion à un " \
|
||||
|
||||
@@ -1073,7 +1073,8 @@ class JCLComponent_TestCase(unittest.TestCase):
|
||||
"user1@test.com")
|
||||
self.assertEqual(password_message.get_subject(), \
|
||||
"[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):
|
||||
self.comp.stream = MockStream()
|
||||
|
||||
Reference in New Issue
Block a user