Philipp von Weitershausen wrote:
You would inherit from the default implementation in
zope.publisher.browser.BrowserLanguages and override
getPreferredLanguages. Inside I presume you would get the current user
in the Zope 2 manner, getSecurityManager().getUser(), and do your
checks. If that won't lead to anything, you can simply return
super(...).getPreferredLanguages() to default to browser languages.

Cool, thanks. Once I've developed this component, how do I plug it in zcml-wise?

from Products.PageTemplates.GlobalTranslationService import \
      getGlobalTranslationService
ts = getGlobalTranslationService()
ts.translate(domain,
             msgid,
             context=self,
             target_language=target_language,
             default=default)

What's the equivalent in Z3 land or should I be looking to turn all
calls to the above into MessageID's? If I do, when and how do they get
translated?

1) We usually don't do manual translation in Python

What about sending notification mails and the like?

2) Instead we mark all user strings ("messages") as i18n messages (using
zope.i18nmessageid.MessageFactory). That also helps the automatic
extraction utility to find them.

Okay, but what translates these and when?

4) In case you *do* need manual translation in Python (sometimes it
happens), you can call zope.i18n.translate(msgid, context=REQUEST)
(notice the context is the request here).

Is msgid a string or a MessageID object there?

I've made calls to the following too:

name = ts.getLanguageName('en',self) #'en' is just an example

current = ts.negotiate_language(self,domain) or default

languages = [{'code':code,
             'name':ts.getLanguageName(code, self),
             'selected':current==code} for code in
             ts.getLanguages(self,domain)]

What are the new-world equivalents of these?

Why would you need this?

For UI. Showing language names in the UI and showing a list of available languages to let the user pick their own. How would would build these in Zope 3? (and, more importantly, in 2.9 with Five?)

Finally, Philipp's article suggests that people may want to write
message catalog implementations that do the automatic compilation to .mo
and/or capture and report untranslated message ids. Has anyone done
this? If not, I might well be up for it :-)

Hanno Schlichting will be working in similar areas, I've heard. Perhaps
you want to make friends with him :).

Where can I find him?

cheers,

Chris

--
Simplistix - Content Management, Zope & Python Consulting
           - http://www.simplistix.co.uk
_______________________________________________
Zope3-dev mailing list
Zope3-dev@zope.org
Unsub: http://mail.zope.org/mailman/options/zope3-dev/archive%40mail-archive.com

Reply via email to