43
43
from OFS .SimpleItem import SimpleItem
44
44
from Persistence import PersistentMapping
45
45
from ZPublisher import HTTPRequest
46
- from zope .i18n .interfaces import ITranslationDomain
47
- from zope .interface import implements
48
46
from zope .component import getSiteManager
49
47
from zope .i18n import interpolate
48
+ from zope .i18n .interfaces import ITranslationDomain
49
+ from zope .interface import implements
50
50
51
51
# Import from Localizer
52
+ from interfaces import IMessageCatalog
52
53
from LanguageManager import LanguageManager
53
54
from LocalFiles import LocalDTMLFile
54
55
from utils import charsets , lang_negotiator , _
@@ -146,11 +147,14 @@ def manage_addMessageCatalog(self, id, title, languages, sourcelang=None,
146
147
return self .manage_main (self , REQUEST )
147
148
148
149
150
+
149
151
class MessageCatalog (LanguageManager , ObjectManager , SimpleItem ):
150
152
"""Stores messages and their translations...
151
153
"""
152
154
153
155
meta_type = 'MessageCatalog'
156
+ implements (IMessageCatalog )
157
+
154
158
155
159
security = ClassSecurityInfo ()
156
160
@@ -177,8 +181,6 @@ def __init__(self, id, title, sourcelang, languages):
177
181
# ITranslationDomain interface
178
182
# zope.i18n.interfaces.ITranslationDomain
179
183
#######################################################################
180
- implements (ITranslationDomain )
181
-
182
184
@property
183
185
def domain (self ):
184
186
""" """
@@ -192,18 +194,6 @@ def translate(self, msgid, mapping=None, context=None,
192
194
return interpolate (msgstr , mapping )
193
195
194
196
195
- def manage_afterAdd (self , item , container ):
196
- if item is self :
197
- sm = getSiteManager (container )
198
- sm .registerUtility (self , ITranslationDomain , self .domain )
199
-
200
-
201
- def manage_beforeDelete (self , item , container ):
202
- if item is self :
203
- sm = getSiteManager (container )
204
- sm .unregisterUtility (self , ITranslationDomain , self .domain )
205
-
206
-
207
197
#######################################################################
208
198
# Private API
209
199
#######################################################################
@@ -919,3 +909,19 @@ def PUT(self, REQUEST, RESPONSE):
919
909
920
910
InitializeClass (MessageCatalog )
921
911
InitializeClass (POFile )
912
+
913
+
914
+
915
+ def MessageCatalog_moved (object , event ):
916
+ # FIXME This does not work if what we move is the folder that contains
917
+ # the message catalog
918
+ container = event .oldParent
919
+ if container :
920
+ sm = getSiteManager (container )
921
+ sm .unregisterUtility (object , ITranslationDomain , event .oldName )
922
+
923
+ container = event .newParent
924
+ if container :
925
+ sm = getSiteManager (container )
926
+ sm .registerUtility (object , ITranslationDomain , event .newName )
927
+
0 commit comments