products/CPSonFive.old

changeset 13:7d6ae00e86bc

Updated the translation monkey to handle message ids
author lregebro
date Mon, 18 Jul 2005 14:16:16 +0000
parents 765295c2d375
children 7f76a3a981f8
files __init__.py
diffstat 1 files changed, 10 insertions(+), 4 deletions(-) [+]
line diff
     1.1 --- a/__init__.py
     1.2 +++ b/__init__.py
     1.3 @@ -21,7 +21,7 @@
     1.4  
     1.5  This product is the container for any reusable integration between CPS and Five.
     1.6  """
     1.7 -
     1.8 +from types import StringTypes
     1.9  from zope.schema.interfaces import ITitledTokenizedTerm
    1.10  
    1.11  # Zope3.0.0 doesn't translates dropdownboxes (that's a bug)
    1.12 @@ -38,10 +38,16 @@
    1.13      #     return self.translate(term.title)
    1.14      # return self.translate(term.token)
    1.15  
    1.16 -    # XXX: But with Five 1.0.x we need to call Localizer:
    1.17 +    # XXX: But with Five 1.0.x we need to call Localizer, and we also need to
    1.18 +    # make sure Localizer gets a string, and not a MessageID
    1.19      if ITitledTokenizedTerm.providedBy(term):
    1.20 -        return self.context.context.Localizer.default(term.title)
    1.21 -    return self.context.context.Localizer.default(term.token)
    1.22 +        message = term.title
    1.23 +    else:
    1.24 +        message = term.token
    1.25 +
    1.26 +    if type(message) not in StringTypes:
    1.27 +        message = str(message)
    1.28 +    return self.context.context.Localizer.default(message)
    1.29  
    1.30  
    1.31  def initialize(context):