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') |
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)) |
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(): |