/[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.18 by lalo, Mon Sep 29 14:49:12 2003 UTC revision 1.19 by lalo, Mon Sep 29 16:30:16 2003 UTC
# Line 74  def make_translation_service(cp): Line 74  def make_translation_service(cp):
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        return getattr(cp, cp_id)
78    
79  def initialize(context):  def initialize(context):
80      # hook into the Control Panel      # hook into the Control Panel
81      cp = context._ProductContext__app.Control_Panel # argh      cp = context._ProductContext__app.Control_Panel # argh
82      if cp_id not in cp.objectIds():      if cp_id in cp.objectIds():
83          make_translation_service(cp)          cp_ts = getattr(cp, cp_id)
84        else:
85            cp_ts = make_translation_service(cp)
86    
87      # 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)
88      instance_version = getattr(translation_service, '_instance_version', (0, 4, 0, 0))      instance_version = getattr(cp_ts, '_instance_version', (0, 4, 0, 0))
89      if instance_version < PlacelessTranslationService._class_version:      if instance_version < PlacelessTranslationService._class_version:
90          log('outdated translation service found, recreating',          log('outdated translation service found, recreating',
91              detail = '(found %s.%s.%s.%s)\n' % instance_version)              detail = '(found %s.%s.%s.%s)\n' % instance_version)
92          cp._delObject(cp_id)          cp._delObject(cp_id)
93          make_translation_service(cp)          cp_ts = make_translation_service(cp)
     ts_unwrapped = translation_service.aq_base  
94    
95      # sweep products      # sweep products
96      log('products: %r' % get_products(), zLOG.BLATHER)      log('products: %r' % get_products(), zLOG.BLATHER)
97      for prod in get_products():      for prod in get_products():
98          # prod is a tuple in the form:          # prod is a tuple in the form:
99          #(priority, dir_name, index, base_dir) for each Product directory          #(priority, dir_name, index, base_dir) for each Product directory
100          ts_unwrapped._load_dir(os.path.join(prod[3], prod[1], 'i18n'))          cp_ts._load_dir(os.path.join(prod[3], prod[1], 'i18n'))
101    
102      # sweep the i18n directory for local catalogs      # sweep the i18n directory for local catalogs
103      ts_unwrapped._load_dir(os.path.join(INSTANCE_HOME, 'i18n'))      cp_ts._load_dir(os.path.join(INSTANCE_HOME, 'i18n'))
104    
105      # didn't found any catalogs      # didn't found any catalogs
106      if not ts_unwrapped.objectIds():      if not cp_ts.objectIds():
107          log('no translations found!', zLOG.PROBLEM)          log('no translations found!', zLOG.PROBLEM)
108    
109      # notify anyone who needs it      # notify anyone who needs it

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

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