|
Revision 944
(checked in by crchemist, 1 year ago)
|
Fix zope-2.9.8 bug in MessageFactory? function.
|
- Property svn:eol-style set to
native
|
| Line | |
|---|
| 1 |
from Products.CMFCore.DirectoryView import registerDirectory |
|---|
| 2 |
from App.version_txt import getZopeVersion |
|---|
| 3 |
from Products.CMFCore.utils import ToolInit |
|---|
| 4 |
import logging |
|---|
| 5 |
from AccessControl import allow_module, ModuleSecurityInfo |
|---|
| 6 |
import config |
|---|
| 7 |
import CaptchaTool |
|---|
| 8 |
|
|---|
| 9 |
allow_module('Products.qPloneCaptchas.utils') |
|---|
| 10 |
allow_module('Products.qPloneCaptchas.config') |
|---|
| 11 |
registerDirectory('skins', config.GLOBALS) |
|---|
| 12 |
|
|---|
| 13 |
tools = (CaptchaTool.CaptchaTool, ) |
|---|
| 14 |
def initialize(context): |
|---|
| 15 |
ToolInit(meta_type="CaptchaTool", |
|---|
| 16 |
tools=tools, |
|---|
| 17 |
product_name=config.PRODUCT_NAME, |
|---|
| 18 |
icon=config.TOOL_ICON,).initialize(context) |
|---|
| 19 |
|
|---|
| 20 |
def MessageFactory(projectname): |
|---|
| 21 |
"Get a i18n message factory" |
|---|
| 22 |
MessageFactory = lambda x: lambda y: y |
|---|
| 23 |
try: |
|---|
| 24 |
from zope.i18nmessageid import MessageFactory |
|---|
| 25 |
except ImportError: |
|---|
| 26 |
try: |
|---|
| 27 |
from zope.i18nmessageid import MessageIDFactory as MessageFactory |
|---|
| 28 |
except ImportError: |
|---|
| 29 |
try: |
|---|
| 30 |
from Products.PlacelessTranslationService.MessageID import MessageIDFactory as MessageFactory |
|---|
| 31 |
except: |
|---|
| 32 |
logging.info("[qPloneCaptchas] No i18n Message Factory found -> cannot provide translations!") |
|---|
| 33 |
return MessageFactory(projectname.lower()) |
|---|
| 34 |
|
|---|
| 35 |
ProductMessageFactory = MessageFactory('%s' % config.PRODUCT_NAME) |
|---|
| 36 |
ModuleSecurityInfo('Products.%s' % config.PRODUCT_NAME).declarePublic("ProductMessageFactory") |
|---|