21 |
""" |
""" |
22 |
|
|
23 |
from gettext import GNUTranslations |
from gettext import GNUTranslations |
24 |
import os |
import os, types, codecs |
|
import codecs |
|
25 |
from types import DictType, StringType, UnicodeType |
from types import DictType, StringType, UnicodeType |
26 |
from OFS.Traversable import Traversable |
from OFS.Traversable import Traversable |
27 |
from Persistence import Persistent |
from Persistence import Persistent |
32 |
try: |
try: |
33 |
from Products.OpenPT.OpenPTFile import OpenPTFile as ptFile |
from Products.OpenPT.OpenPTFile import OpenPTFile as ptFile |
34 |
except ImportError: |
except ImportError: |
35 |
#FIXME: ZPT |
from Products.PageTemplates.PageTemplateFile import PageTemplateFile |
36 |
ptFile = None |
from Globals import package_home |
37 |
|
def ptFile(id, *filename): |
38 |
|
if type(filename[0]) is types.DictType: |
39 |
|
filename = list(filename) |
40 |
|
filename[0] = package_home(filename[0]) |
41 |
|
filename = os.path.join(*filename) |
42 |
|
if not os.path.splitext(filename)[1]: |
43 |
|
filename = filename + '.pt' |
44 |
|
return PageTemplateFile(filename, '', __name__=id) |
45 |
|
|
46 |
# template to use to write missing entries to .missing |
# template to use to write missing entries to .missing |
47 |
missing_template = u"""msgid "%(id)s" |
missing_template = u"""msgid "%(id)s" |
63 |
meta_type = title = 'Gettext Message Catalog' |
meta_type = title = 'Gettext Message Catalog' |
64 |
icon = 'misc_/PlacelessTranslationService/GettextMessageCatalog.png' |
icon = 'misc_/PlacelessTranslationService/GettextMessageCatalog.png' |
65 |
__roles__=('Manager',) |
__roles__=('Manager',) |
66 |
|
title__roles__=__roles__ |
67 |
|
|
68 |
def __init__(self, path_to_file): |
def __init__(self, path_to_file): |
69 |
"""Initialize the message catalog""" |
"""Initialize the message catalog""" |
174 |
""" |
""" |
175 |
return self.__translation_object._info.get(name, None) |
return self.__translation_object._info.get(name, None) |
176 |
|
|
177 |
|
Title__roles__ = __roles__ |
178 |
|
def Title(self): |
179 |
|
return self.title |
180 |
|
|
181 |
############################################################ |
############################################################ |
182 |
# Zope/OFS integration |
# Zope/OFS integration |
183 |
|
|
194 |
|
|
195 |
zmi_test = ptFile('zmi_test', globals(), 'www', 'catalog_test') |
zmi_test = ptFile('zmi_test', globals(), 'www', 'catalog_test') |
196 |
|
|
197 |
|
file_exists__roles__ = __roles__ |
198 |
def file_exists(self): |
def file_exists(self): |
199 |
try: |
try: |
200 |
file = open(self._path_to_file, 'rb') |
file = open(self._path_to_file, 'rb') |
202 |
return False |
return False |
203 |
return True |
return True |
204 |
|
|
205 |
|
displayInfo__roles__ = __roles__ |
206 |
def displayInfo(self): |
def displayInfo(self): |
207 |
self._prepareTranslations() |
self._prepareTranslations() |
208 |
info = self.__translation_object._info |
info = self.__translation_object._info |