/[opental]/opental/PlacelessTranslationService/__init__.py
ViewVC logotype

Diff of /opental/PlacelessTranslationService/__init__.py

Parent Directory Parent Directory | Revision Log Revision Log | View Patch Patch

revision 1.17 by lalo, Fri Sep 26 16:36:51 2003 UTC revision 1.18 by lalo, Mon Sep 29 14:49:12 2003 UTC
# Line 50  misc_ = { Line 50  misc_ = {
50      Globals.ImageFile('www/GettextMessageCatalog.png', globals()),      Globals.ImageFile('www/GettextMessageCatalog.png', globals()),
51      }      }
52    
53    # this is the module-level translation service
54    translation_service = PlacelessTranslationService('default')
55    
56    # set product-wide attrs for importing
57    translate = translation_service.translate
58    getLanguages = translation_service.getLanguages
59    getLanguageName = translation_service.getLanguageName
60    negotiate = translation_service.negotiate
61    
62  # import permissions  # import permissions
63  security = ModuleSecurityInfo('Products.PlacelessTranslationService')  security = ModuleSecurityInfo('Products.PlacelessTranslationService')
64  security.declarePublic('negotiate')  security.declarePublic('negotiate')
# Line 57  security.declarePublic('translate') Line 66  security.declarePublic('translate')
66  security.declarePublic('getLanguages')  security.declarePublic('getLanguages')
67  security.declarePublic('getLanguageName')  security.declarePublic('getLanguageName')
68    
69    # set ZPT's translation service
70    setGlobalTranslationService(translation_service)
71    
72  def make_translation_service(cp):  def make_translation_service(cp):
73      from Products import PlacelessTranslationService as pkg      # Control_Panel translation service
     # default (gettext) translation service  
74      translation_service = PlacelessTranslationService('default')      translation_service = PlacelessTranslationService('default')
75      translation_service.id = cp_id      translation_service.id = cp_id
76      cp._setObject(cp_id, translation_service)      cp._setObject(cp_id, translation_service)
77    
78  def initialize(context):  def initialize(context):
     from Products import PlacelessTranslationService as pkg  
   
79      # hook into the Control Panel      # hook into the Control Panel
80      cp = context._ProductContext__app.Control_Panel # argh      cp = context._ProductContext__app.Control_Panel # argh
81      if cp_id not in cp.objectIds():      if cp_id not in cp.objectIds():
82          make_translation_service(cp)          make_translation_service(cp)
     pkg.translation_service = getattr(cp, cp_id)  
83    
84      # don't touch - this is the last version that didn't have the attribute (0.4)      # don't touch - this is the last version that didn't have the attribute (0.4)
85      instance_version = getattr(translation_service, '_instance_version', (0, 4, 0, 0))      instance_version = getattr(translation_service, '_instance_version', (0, 4, 0, 0))
# Line 80  def initialize(context): Line 88  def initialize(context):
88              detail = '(found %s.%s.%s.%s)\n' % instance_version)              detail = '(found %s.%s.%s.%s)\n' % instance_version)
89          cp._delObject(cp_id)          cp._delObject(cp_id)
90          make_translation_service(cp)          make_translation_service(cp)
         pkg.translation_service = getattr(cp, cp_id)  
91      ts_unwrapped = translation_service.aq_base      ts_unwrapped = translation_service.aq_base
92    
     # set ZPT's translation service  
     setGlobalTranslationService(translation_service)  
   
     # set product-wide attrs for importing  
     pkg.translate = translation_service.translate  
     pkg.getLanguages = translation_service.getLanguages  
     pkg.getLanguageName = translation_service.getLanguageName  
     pkg.negotiate = translation_service.negotiate  
   
93      # sweep products      # sweep products
94      log('products: %r' % get_products(), zLOG.BLATHER)      log('products: %r' % get_products(), zLOG.BLATHER)
95      for prod in get_products():      for prod in get_products():

Legend:
Removed from v.1.17  
changed lines
  Added in v.1.18

savannah-hackers-public@gnu.org
ViewVC Help
Powered by ViewVC 1.1.26