From 8fdd9d3be424482ac6bfd20fa4e9fca6eaadc937 Mon Sep 17 00:00:00 2001 From: David Rousselie Date: Sat, 28 Jan 2006 18:42:18 +0100 Subject: [PATCH] Multilang support darcs-hash:20060128174218-86b55-4a70de917515e6938b764351be56a81991a5f95b.gz --- TODO | 33 +-- jabber/component.py | 533 ++++++++++++++++++++++---------------------- jabber/lang.py | 82 +++++++ jmc.py | 3 + tests/jmc-test.xml | 2 +- 5 files changed, 358 insertions(+), 295 deletions(-) create mode 100644 jabber/lang.py diff --git a/TODO b/TODO index 61b012c..67e90cd 100644 --- a/TODO +++ b/TODO @@ -1,5 +1,3 @@ -* Make real documentation - * i18n support in the same way as ejabberd and PyMSNt, PyICQ-t and PyAIM-t: using xml:lang, but have an option in the config to set the default language to show, when the client do @@ -7,38 +5,17 @@ * Database backend (default SQLLite) -* Checkbox and radio button options in the forms to set when and how - you like to get the messages (in offline, online, free for chat, - away,... presence). - So: -Online: -Away: -Free for Chat: -Extended Away: -Offline: +* Support for attachements with size limit and file format limit + (e.g. only png, jpeg,... but no exe, bat,...). -* Dropdown menu in the forms with configurable time-intervals. E.g., - users can choose betwoon 1 minute, 2 minutes, 5 minutes, 15 - minutes, 30 minutes, 60 minutes, 1 day. The admin can configure in - the configuration file of jmc which options are available. +* make JMC run on windows + +* Make real documentation * Support for Ad Hoc Commands (see PyMSNt cvs, avatar branch). Interesting for statistics. -* Support for attachements with size limit and file format limit - (e.g. only png, jpeg,... but no exe, bat,...). - * Support for epoll, kpoll and kqueu (see PyMSNt cvs, avatar branch code). -* make JMC run on windows - diff --git a/jabber/component.py b/jabber/component.py index dba1106..7885050 100644 --- a/jabber/component.py +++ b/jabber/component.py @@ -1,3 +1,4 @@ +# -*- coding: UTF-8 -*- ## ## component.py ## Login : David Rousselie @@ -18,7 +19,7 @@ ## You should have received a copy of the GNU General Public License ## along with this program; if not, write to the Free Software ## Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA -## +## import re import signal @@ -43,6 +44,8 @@ from pyxmpp.jid import JID from pyxmpp.jabber.disco import DiscoItems, DiscoItem, DiscoInfo, DiscoIdentity from pyxmpp.jabberd.component import Component +from jabber.lang import Lang + class ComponentFatalError(RuntimeError): pass @@ -57,7 +60,8 @@ class MailComponent(Component): disco_type = "headline") self.__logger = logging.getLogger("jabber.Component") self.__shutdown = 0 - + self.__default_lang = config.get_content("config/jabber/language") + # TODO : delete signals not known by Windows signal.signal(signal.SIGINT, self.signal_handler) signal.signal(signal.SIGPIPE, self.signal_handler) @@ -77,8 +81,6 @@ class MailComponent(Component): config.get_content("config/jabber/service") self.__storage.spool_dir = self.__spool_dir self.__storage.nb_pk_fields = 2 - self.__reg_form = None - self.__reg_form_init = None # dump registered accounts (save) every hour self.__count = 60 self.running = False @@ -86,271 +88,266 @@ class MailComponent(Component): def __del__(self): logging.shutdown() + def get_lang(self, node): + lang = node.getLang() + if lang is None: + self.__logger.debug("Using default lang " + self.__default_lang) + lang = self.__default_lang + return lang + + def get_lang_class(self, lang): + return getattr(Lang, lang) + """ Register Form creator """ - def get_reg_form(self): - if self.__reg_form == None: - self.__reg_form = X() - self.__reg_form.xmlns = "jabber:x:data" - self.__reg_form.title = "Jabber Mail connection registration" - self.__reg_form.instructions = "Enter anything below" - self.__reg_form.type = "form" - - self.__reg_form.add_field(type = "text-single", \ - label = "Connection name", \ - var = "name") - - self.__reg_form.add_field(type = "text-single", \ - label = "Login", \ - var = "login") - - self.__reg_form.add_field(type = "text-private", \ - label = "Password", \ - var = "password") - - self.__reg_form.add_field(type = "text-single", \ - label = "Host", \ - var = "host") - - self.__reg_form.add_field(type = "text-single", \ - label = "Port", \ - var = "port") + def get_reg_form(self, lang_class): + reg_form = X() + reg_form.xmlns = "jabber:x:data" + reg_form.title = lang_class.register_title + reg_form.instructions = lang_class.register_instructions + reg_form.type = "form" - field = self.__reg_form.add_field(type = "list-single", \ - label = "Mailbox type", \ - var = "type") - field.add_option(label = "POP3", \ - value = "pop3") - field.add_option(label = "POP3S", \ - value = "pop3s") - field.add_option(label = "IMAP", \ - value = "imap") - field.add_option(label = "IMAPS", \ - value = "imaps") - - self.__reg_form.add_field(type = "text-single", \ - label = "Mailbox (IMAP)", \ - var = "mailbox", \ - value = "INBOX") - - field = self.__reg_form.add_field(type = "list-single", \ - label = "Action when state is 'Free For Chat'", \ - var = "chat_action", \ - value = str(mailconnection.RETRIEVE)) - field.add_option(label = "Do nothing", \ - value = str(mailconnection.DO_NOTHING)) - field.add_option(label = "Send mail digest", \ - value = str(mailconnection.DIGEST)) - field.add_option(label = "Retrieve mail", \ - value = str(mailconnection.RETRIEVE)) - - field = self.__reg_form.add_field(type = "list-single", \ - label = "Action when state is 'Online'", \ - var = "online_action", \ - value = str(mailconnection.RETRIEVE)) - field.add_option(label = "Do nothing", \ - value = str(mailconnection.DO_NOTHING)) - field.add_option(label = "Send mail digest", \ - value = str(mailconnection.DIGEST)) - field.add_option(label = "Retrieve mail", \ - value = str(mailconnection.RETRIEVE)) - - field = self.__reg_form.add_field(type = "list-single", \ - label = "Action when state is 'Away'", \ - var = "away_action", \ - value = str(mailconnection.DIGEST)) - field.add_option(label = "Do nothing", \ - value = str(mailconnection.DO_NOTHING)) - field.add_option(label = "Send mail digest", \ - value = str(mailconnection.DIGEST)) - field.add_option(label = "Retrieve mail", \ - value = str(mailconnection.RETRIEVE)) - - field = self.__reg_form.add_field(type = "list-single", \ - label = "Action when state is 'Not Available'", \ - var = "xa_action", \ - value = str(mailconnection.DIGEST)) - field.add_option(label = "Do nothing", \ - value = str(mailconnection.DO_NOTHING)) - field.add_option(label = "Send mail digest", \ - value = str(mailconnection.DIGEST)) - field.add_option(label = "Retrieve mail", \ - value = str(mailconnection.RETRIEVE)) - - field = self.__reg_form.add_field(type = "list-single", \ - label = "Action when state is 'Do not Disturb'", \ - var = "dnd_action", \ - value = str(mailconnection.DIGEST)) - field.add_option(label = "Do nothing", \ - value = str(mailconnection.DO_NOTHING)) - field.add_option(label = "Send mail digest", \ - value = str(mailconnection.DIGEST)) - field.add_option(label = "Retrieve mail", \ - value = str(mailconnection.RETRIEVE)) - - field = self.__reg_form.add_field(type = "list-single", \ - label = "Action when state is 'Offline'", \ - var = "offline_action", \ - value = str(mailconnection.DO_NOTHING)) - field.add_option(label = "Do nothing", \ - value = str(mailconnection.DO_NOTHING)) - field.add_option(label = "Send mail digest", \ - value = str(mailconnection.DIGEST)) - field.add_option(label = "Retrieve mail", \ - value = str(mailconnection.RETRIEVE)) - - # default interval in config file - self.__reg_form.add_field(type = "text-single", \ - label = "Mail check interval (in minutes)", \ - var = "interval", \ - value = "5") - - return self.__reg_form + reg_form.add_field(type = "text-single", \ + label = lang_class.account_name, \ + var = "name") + + reg_form.add_field(type = "text-single", \ + label = lang_class.account_login, \ + var = "login") + + reg_form.add_field(type = "text-private", \ + label = lang_class.account_password, \ + var = "password") + + reg_form.add_field(type = "text-single", \ + label = lang_class.account_host, \ + var = "host") + + reg_form.add_field(type = "text-single", \ + label = lang_class.account_port, \ + var = "port") + + field = reg_form.add_field(type = "list-single", \ + label = lang_class.account_type, \ + var = "type") + field.add_option(label = "POP3", \ + value = "pop3") + field.add_option(label = "POP3S", \ + value = "pop3s") + field.add_option(label = "IMAP", \ + value = "imap") + field.add_option(label = "IMAPS", \ + value = "imaps") + + reg_form.add_field(type = "text-single", \ + label = lang_class.account_mailbox, \ + var = "mailbox", \ + value = "INBOX") + + field = reg_form.add_field(type = "list-single", \ + label = lang_class.account_ffc_action, \ + var = "chat_action", \ + value = str(mailconnection.RETRIEVE)) + field.add_option(label = lang_class.action_nothing, \ + value = str(mailconnection.DO_NOTHING)) + field.add_option(label = lang_class.action_digest, \ + value = str(mailconnection.DIGEST)) + field.add_option(label = lang_class.action_retrieve, \ + value = str(mailconnection.RETRIEVE)) + + field = reg_form.add_field(type = "list-single", \ + label = lang_class.account_online_action, \ + var = "online_action", \ + value = str(mailconnection.RETRIEVE)) + field.add_option(label = lang_class.action_nothing, \ + value = str(mailconnection.DO_NOTHING)) + field.add_option(label = lang_class.action_digest, \ + value = str(mailconnection.DIGEST)) + field.add_option(label = lang_class.action_retrieve, \ + value = str(mailconnection.RETRIEVE)) + + field = reg_form.add_field(type = "list-single", \ + label = lang_class.account_away_action, \ + var = "away_action", \ + value = str(mailconnection.DIGEST)) + field.add_option(label = lang_class.action_nothing, \ + value = str(mailconnection.DO_NOTHING)) + field.add_option(label = lang_class.action_digest, \ + value = str(mailconnection.DIGEST)) + field.add_option(label = lang_class.action_retrieve, \ + value = str(mailconnection.RETRIEVE)) + + field = reg_form.add_field(type = "list-single", \ + label = lang_class.account_xa_action, \ + var = "xa_action", \ + value = str(mailconnection.DIGEST)) + field.add_option(label = lang_class.action_nothing, \ + value = str(mailconnection.DO_NOTHING)) + field.add_option(label = lang_class.action_digest, \ + value = str(mailconnection.DIGEST)) + field.add_option(label = lang_class.action_retrieve, \ + value = str(mailconnection.RETRIEVE)) + + field = reg_form.add_field(type = "list-single", \ + label = lang_class.account_dnd_action, \ + var = "dnd_action", \ + value = str(mailconnection.DIGEST)) + field.add_option(label = lang_class.action_nothing, \ + value = str(mailconnection.DO_NOTHING)) + field.add_option(label = lang_class.action_digest, \ + value = str(mailconnection.DIGEST)) + field.add_option(label = lang_class.action_retrieve, \ + value = str(mailconnection.RETRIEVE)) + + field = reg_form.add_field(type = "list-single", \ + label = lang_class.account_offline_action, \ + var = "offline_action", \ + value = str(mailconnection.DO_NOTHING)) + field.add_option(label = lang_class.action_nothing, \ + value = str(mailconnection.DO_NOTHING)) + field.add_option(label = lang_class.action_digest, \ + value = str(mailconnection.DIGEST)) + field.add_option(label = lang_class.action_retrieve, \ + value = str(mailconnection.RETRIEVE)) + + # default interval in config file + reg_form.add_field(type = "text-single", \ + label = lang_class.account_check_interval, \ + var = "interval", \ + value = "5") + + return reg_form """ Register Form modifier for existing accounts """ - def get_reg_form_init(self, jid, name): + def get_reg_form_init(self, lang_class, jid, name): if not self.__storage.has_key((jid, name)): return None account = self.__storage[(jid, name)] - if self.__reg_form_init == None: - self.__reg_form_init = X() - self.__reg_form_init.xmlns = "jabber:x:data" - self.__reg_form_init.title = "Jabber mail connection Modifier" - self.__reg_form_init.instructions = "Modifier for connection " + \ - name - self.__reg_form_init.type = "form" - - self.__reg_form_init.add_field(type = "fixed", \ - label = "Connection name", \ - var = "name", \ - value = name) - - self.__reg_form_init.add_field(type = "text-single", \ - label = "Login", \ - var = "login", \ - value = account.login) - - self.__reg_form_init.add_field(type = "text-private", \ - label = "Password", \ - var = "password", \ - value = account.password) - - self.__reg_form_init.add_field(type = "text-single", \ - label = "Host", \ - var = "host", \ - value = account.host) - - self.__reg_form_init.add_field(type = "text-single", \ - label = "Port", \ - var = "port", \ - value = str(account.port)) - - field = self.__reg_form_init.add_field(type = "list-single", \ - label = "Mailbox type", \ - var = "type", \ - value = account.get_type()) - field.add_option(label = "POP3", \ - value = "pop3") - field.add_option(label = "POP3S", \ - value = "pop3s") - field.add_option(label = "IMAP", \ - value = "imap") - field.add_option(label = "IMAPS", \ - value = "imaps") - - self.__reg_form_init.add_field(type = "text-single", \ - label = "Mailbox (IMAP)", \ - var = "mailbox") - - field = self.__reg_form_init.add_field(type = "list-single", \ - label = "Action when state is 'Free For Chat'", \ - var = "chat_action", \ - value = str(account.chat_action)) - field.add_option(label = "Do nothing", \ - value = str(mailconnection.DO_NOTHING)) - field.add_option(label = "Send mail digest", \ - value = str(mailconnection.DIGEST)) - field.add_option(label = "Retrieve mail", \ - value = str(mailconnection.RETRIEVE)) - - field = self.__reg_form_init.add_field(type = "list-single", \ - label = "Action when state is 'Online'", \ - var = "online_action", \ - value = str(account.online_action)) - field.add_option(label = "Do nothing", \ - value = str(mailconnection.DO_NOTHING)) - field.add_option(label = "Send mail digest", \ - value = str(mailconnection.DIGEST)) - field.add_option(label = "Retrieve mail", \ - value = str(mailconnection.RETRIEVE)) - - field = self.__reg_form_init.add_field(type = "list-single", \ - label = "Action when state is 'Away'", \ - var = "away_action", \ - value = str(account.away_action)) - field.add_option(label = "Do nothing", \ - value = str(mailconnection.DO_NOTHING)) - field.add_option(label = "Send mail digest", \ - value = str(mailconnection.DIGEST)) - field.add_option(label = "Retrieve mail", \ - value = str(mailconnection.RETRIEVE)) - - field = self.__reg_form_init.add_field(type = "list-single", \ - label = "Action when state is 'Not Available'", \ - var = "xa_action", \ - value = str(account.xa_action)) - field.add_option(label = "Do nothing", \ - value = str(mailconnection.DO_NOTHING)) - field.add_option(label = "Send mail digest", \ - value = str(mailconnection.DIGEST)) - field.add_option(label = "Retrieve mail", \ - value = str(mailconnection.RETRIEVE)) - - field = self.__reg_form_init.add_field(type = "list-single", \ - label = "Action when state is 'Do not Disturb'", \ - var = "dnd_action", \ - value = str(account.dnd_action)) - field.add_option(label = "Do nothing", \ - value = str(mailconnection.DO_NOTHING)) - field.add_option(label = "Send mail digest", \ - value = str(mailconnection.DIGEST)) - field.add_option(label = "Retrieve mail", \ - value = str(mailconnection.RETRIEVE)) - - field = self.__reg_form_init.add_field(type = "list-single", \ - label = "Action when state is 'Offline'", \ - var = "offline_action", \ - value = str(account.offline_action)) - field.add_option(label = "Do nothing", \ - value = str(mailconnection.DO_NOTHING)) - field.add_option(label = "Send mail digest", \ - value = str(mailconnection.DIGEST)) - field.add_option(label = "Retrieve mail", \ - value = str(mailconnection.RETRIEVE)) - - self.__reg_form_init.add_field(type = "text-single", \ - label = "Mail check interval (in minutes)", \ - var = "interval", \ - value = str(account.interval)) - else: - self.__reg_form_init.fields["login"].value = account.login - self.__reg_form_init.fields["password"].value = account.password - self.__reg_form_init.fields["host"].value = account.host - self.__reg_form_init.fields["port"].value = str(account.port) - self.__reg_form_init.fields["type"].value = account.get_type() - self.__reg_form_init.fields["chat_action"].value = str(account.chat_action) - self.__reg_form_init.fields["online_action"].value = str(account.online_action) - self.__reg_form_init.fields["away_action"].value = str(account.away_action) - self.__reg_form_init.fields["xa_action"].value = str(account.xa_action) - self.__reg_form_init.fields["dnd_action"].value = str(account.dnd_action) - self.__reg_form_init.fields["offline_action"].value = str(account.offline_action) - self.__reg_form_init.fields["interval"].value = str(account.interval) - + reg_form_init = X() + reg_form_init.xmlns = "jabber:x:data" + reg_form_init.title = lang_class.update_title + reg_form_init.instructions = lang_class.update_instructions + \ + name + reg_form_init.type = "form" + + reg_form_init.add_field(type = "fixed", \ + label = lang_class.account_name, \ + var = "name", \ + value = name) + + reg_form_init.add_field(type = "text-single", \ + label = lang_class.account_login, \ + var = "login", \ + value = account.login) + + reg_form_init.add_field(type = "text-private", \ + label = lang_class.account_password, \ + var = "password", \ + value = account.password) + + reg_form_init.add_field(type = "text-single", \ + label = lang_class.account_host, \ + var = "host", \ + value = account.host) + + reg_form_init.add_field(type = "text-single", \ + label = lang_class.account_port, \ + var = "port", \ + value = unicode(account.port)) + + field = reg_form_init.add_field(type = "list-single", \ + label = lang_class.account_type, \ + var = "type", \ + value = account.get_type()) + field.add_option(label = "POP3", \ + value = "pop3") + field.add_option(label = "POP3S", \ + value = "pop3s") + field.add_option(label = "IMAP", \ + value = "imap") + field.add_option(label = "IMAPS", \ + value = "imaps") + + reg_form_init.add_field(type = "text-single", \ + label = lang_class.account_mailbox, \ + var = "mailbox") + + field = reg_form_init.add_field(type = "list-single", \ + label = lang_class.account_ffc_action, \ + var = "chat_action", \ + value = str(account.chat_action)) + field.add_option(label = lang_class.action_nothing, \ + value = str(mailconnection.DO_NOTHING)) + field.add_option(label = lang_class.action_digest, \ + value = str(mailconnection.DIGEST)) + field.add_option(label = lang_class.action_retrieve, \ + value = str(mailconnection.RETRIEVE)) + + field = reg_form_init.add_field(type = "list-single", \ + label = lang_class.account_online_action, \ + var = "online_action", \ + value = str(account.online_action)) + field.add_option(label = lang_class.action_nothing, \ + value = str(mailconnection.DO_NOTHING)) + field.add_option(label = lang_class.action_digest, \ + value = str(mailconnection.DIGEST)) + field.add_option(label = lang_class.action_retrieve, \ + value = str(mailconnection.RETRIEVE)) + + field = reg_form_init.add_field(type = "list-single", \ + label = lang_class.account_away_action, \ + var = "away_action", \ + value = str(account.away_action)) + field.add_option(label = lang_class.action_nothing, \ + value = str(mailconnection.DO_NOTHING)) + field.add_option(label = lang_class.action_digest, \ + value = str(mailconnection.DIGEST)) + field.add_option(label = lang_class.action_retrieve, \ + value = str(mailconnection.RETRIEVE)) + + field = reg_form_init.add_field(type = "list-single", \ + label = lang_class.account_xa_action, \ + var = "xa_action", \ + value = str(account.xa_action)) + field.add_option(label = lang_class.action_nothing, \ + value = str(mailconnection.DO_NOTHING)) + field.add_option(label = lang_class.action_digest, \ + value = str(mailconnection.DIGEST)) + field.add_option(label = lang_class.action_retrieve, \ + value = str(mailconnection.RETRIEVE)) + + field = reg_form_init.add_field(type = "list-single", \ + label = lang_class.account_dnd_action, \ + var = "dnd_action", \ + value = str(account.dnd_action)) + field.add_option(label = lang_class.action_nothing, \ + value = str(mailconnection.DO_NOTHING)) + field.add_option(label = lang_class.action_digest, \ + value = str(mailconnection.DIGEST)) + field.add_option(label = lang_class.action_retrieve, \ + value = str(mailconnection.RETRIEVE)) + + field = reg_form_init.add_field(type = "list-single", \ + label = lang_class.account_offline_action, \ + var = "offline_action", \ + value = str(account.offline_action)) + field.add_option(label = lang_class.action_nothing, \ + value = str(mailconnection.DO_NOTHING)) + field.add_option(label = lang_class.action_digest, \ + value = str(mailconnection.DIGEST)) + field.add_option(label = lang_class.action_retrieve, \ + value = str(mailconnection.RETRIEVE)) + + reg_form_init.add_field(type = "text-single", \ + label = lang_class.account_check_interval, \ + var = "interval", \ + value = str(account.interval)) + if account.get_type()[0:4] == "imap": - self.__reg_form_init.fields["mailbox"].value = account.mailbox + reg_form_init.fields["mailbox"].value = account.mailbox else: - self.__reg_form_init.fields["mailbox"].value = "INBOX" + reg_form_init.fields["mailbox"].value = u"INBOX" - return self.__reg_form_init + return reg_form_init """ Looping method """ def run(self, timeout): @@ -475,12 +472,13 @@ class MailComponent(Component): """ Discovery get nested nodes handler """ def disco_get_items(self, node, iq): self.__logger.debug("DISCO_GET_ITEMS") + lang_class = self.get_lang_class(self.get_lang(iq.get_node())) base_from_jid = unicode(iq.get_from().bare()) di = DiscoItems() if not node: for name in self.__storage.keys((base_from_jid,)): account = self.__storage[(base_from_jid, name)] - str_name = account.get_type() + " connection " + name + str_name = account.get_type() + lang_class.connection + name if account.get_type()[0:4] == "imap": str_name += " (" + account.mailbox + ")" DiscoItem(di, JID(name + "@" + unicode(self.jid)), \ @@ -500,20 +498,24 @@ class MailComponent(Component): """ Send back register form to user """ def get_register(self, iq): self.__logger.debug("GET_REGISTER") + lang_class = self.get_lang_class(self.get_lang(iq.get_node())) base_from_jid = unicode(iq.get_from().bare()) to = iq.get_to() iq = iq.make_result_response() q = iq.new_query("jabber:iq:register") if to and to != self.jid: - self.get_reg_form_init(base_from_jid, to.node).attach_xml(q) + self.get_reg_form_init(lang_class, + base_from_jid, + to.node).attach_xml(q) else: - self.get_reg_form().attach_xml(q) + self.get_reg_form(lang_class).attach_xml(q) self.stream.send(iq) return 1 """ Handle user registration response """ def set_register(self, iq): self.__logger.debug("SET_REGISTER") + lang_class = self.get_lang_class(self.get_lang(iq.get_node())) to = iq.get_to() from_jid = iq.get_from() base_from_jid = unicode(from_jid.bare()) @@ -633,15 +635,13 @@ class MailComponent(Component): if self.__storage.has_key((base_from_jid, name)): m = Message(from_jid = self.jid, to_jid = from_jid, \ stanza_type = "message", \ - body = u"Updated %s connection '%s': Registered with "\ - "username '%s' and password '%s' on '%s'" \ + body = lang_class.update_account_message \ % (type, name, login, password, socket)) self.stream.send(m) else: m = Message(from_jid = self.jid, to_jid = from_jid, \ stanza_type = "message", \ - body = u"New %s connection '%s': Registered with " \ - "username '%s' and password '%s' on '%s'" \ + body = lang_class.new_account_message \ % (type, name, login, password, socket)) self.stream.send(m) p = Presence(from_jid = name + "@" + unicode(self.jid), \ @@ -836,6 +836,7 @@ class MailComponent(Component): self.stream.send(mesg) account.disconnect() except Exception,e: + # TODO : Send error message to the user self.__logger.debug("Error while checking mail : %s" \ % (e)) diff --git a/jabber/lang.py b/jabber/lang.py new file mode 100644 index 0000000..2d2ab37 --- /dev/null +++ b/jabber/lang.py @@ -0,0 +1,82 @@ +## +## lang.py +## Login : David Rousselie +## Started on Sat Jan 28 16:37:11 2006 David Rousselie +## $Id$ +## +## Copyright (C) 2006 David Rousselie +## This program is free software; you can redistribute it and/or modify +## it under the terms of the GNU General Public License as published by +## the Free Software Foundation; either version 2 of the License, or +## (at your option) any later version. +## +## This program is distributed in the hope that it will be useful, +## but WITHOUT ANY WARRANTY; without even the implied warranty of +## MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the +## GNU General Public License for more details. +## +## You should have received a copy of the GNU General Public License +## along with this program; if not, write to the Free Software +## Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA +## + + +class Lang: + class en: + register_title = u"Jabber Mail connection registration" + register_instructions = u"Enter connection parameters" + account_name = u"Connection name" + account_login = u"Login" + account_password = u"Password" + account_host = u"Host" + account_port = u"Port" + account_type = u"Mail serveur 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)" + 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 " + connection = u" connection " + update_account_message = u"Updated %s connection '%s': Registered with "\ + "username '%s' and password '%s' on '%s'" + new_account_message = u"New %s connection '%s': Registered with " \ + "username '%s' and password '%s' on '%s'" + + class fr: + register_title = u"Enregistrement d'une nouvelle connexion à un serveur email." + register_instructions = u"Entrer les paramètres de connexion" + # TODO + account_name = u"Connection name" + account_login = u"Login" + account_password = u"Password" + account_host = u"Host" + account_port = u"Port" + account_type = u"Mail serveur 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)" + 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 " + connection = u" connection " + update_account_message = u"Updated %s connection '%s': Registered with "\ + "username '%s' and password '%s' on '%s'" + new_account_message = u"New %s connection '%s': Registered with " \ + "username '%s' and password '%s' on '%s'" + + diff --git a/jmc.py b/jmc.py index 9cde31b..17a060c 100755 --- a/jmc.py +++ b/jmc.py @@ -31,6 +31,9 @@ from jabber.config import Config def main(config_file = "jmc.xml", isDebug = 0): try: + reload(sys) + sys.setdefaultencoding('utf-8') + del sys.setdefaultencoding logger = logging.getLogger() logger.addHandler(logging.StreamHandler()) if isDebug > 0: diff --git a/tests/jmc-test.xml b/tests/jmc-test.xml index 134cd3b..1fbe4c9 100644 --- a/tests/jmc-test.xml +++ b/tests/jmc-test.xml @@ -5,7 +5,7 @@ secret jmc.localhost 5 - fr + en Jabber Mail Component A Jabber mail server component