Yes,
Good catch Heikki. Exceptions are a real issue with i18n in that libraries we leverage such as
Twisted etc return English 8-bit exception strings.

There is a ChandlerException which for example osaf.mail.errors.MailException inherits from. The ChandlerException has been designed with localization in mind and can be passed
localized Unicode strings.

For example:
raise ChandlerException(_(u"Localized Error Message Here"))

The ChandlerException or its inherited classes should always be used when raising Exceptions in
Chandler.

Of course this does not solve the case where the Exception is raised in Python or Twisted or Wx etc.
In those cases you have to catch the Exception and translate it.


On Mar 7, 2007, at 8:35 AM, Heikki Toivonen wrote:

[email protected] wrote:
Revision
13406 <http://viewcvs.osafoundation.org/chandler? view=rev&rev=13406>
Author
    vajda

         try:
             self.itsView.commit()
             activity.completed()
         except Exception, e:
             logger.exception("Commit failed")
+            self.setStatusMessage("Commit failed with %s" %(e))

The "Commit failed with %s" % (e) also needs to be wrapped in a MessageFactory. And in addition for all localizable strings we do not use the %s but instead use
lookup dicts to help give the translator sentence context.

So taking the above text literally, to localize would be:

from i18n import ChandlerMessageFactory as _
self.setStatusMessage(_(u"Commit failed with %(errorDescription)s") % {"errorDescription": e})

However, as Heikki pointed out the Exception is not localized so the better option would be:

from i18n import ChandlerMessageFactory as _
self.setStatusMessage(_(u"Commit failed, see log for details"))

-Brian




I don't think this is right, the message can not be localized AFAIK. The
exception could be anything, and almost certainly will contain English
text. Besides, exception messages are generally meant for programmers,
not end users.

I suggest showing just "Commit failed, see log for details", and log the
actual exception.

--
  Heikki Toivonen


_ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _

Open Source Applications Foundation "chandler-dev" mailing list
http://lists.osafoundation.org/mailman/listinfo/chandler-dev

_ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _

Open Source Applications Foundation "chandler-dev" mailing list
http://lists.osafoundation.org/mailman/listinfo/chandler-dev

Reply via email to