[Zope3-Users] I18N question

Frank Burkhardt fbo2 at gmx.net
Tue Jun 27 08:08:42 EDT 2006


Hi,

I need a vocabulary that presents i18n'd entries to the user.

That's not a problem, when only static data is used:

 from zope.app.i18n import MessageFactory
 _=MessageFactory('mpgsite')

 class MyVocabulary(SimpleVocabulary)
   def __init__(self):
      data={
         'foo':_(u'nice Foo'), 
         'bar':_(u'even better Bar')
      }
      terms=[SimpleTerm(short,title=title) for (short,title) in data.items()]
      SimpleVocabulary.__init__(self,terms)


The vocabulary's choices are i18n'd using the MessageFactory.
However, I need the vocabulary to be created from dynamic content like this:

 data={
    'foo':{
       'en':u"nice Foo",
       'de':u"schoener Foo"
    },
    'bar':{
       'en':u"even better Bar",
    }

How could I do this?

Regards,

Frank
       


More information about the Zope3-users mailing list