[gen] Added boolean Tool.loadTranslationsAtStartup that, if False, prevents to overwrite, on a production site, translations edited through-the-web by users. If True, at every Zope startup, Translation objects are overwritten by the content of their corresponding po files on disk.
This commit is contained in:
parent
8f57163c2a
commit
5b255ce55d
3 changed files with 24 additions and 19 deletions
|
@ -326,23 +326,26 @@ class ZopeInstaller:
|
|||
appyTool.create('translations', noSecurity=True,
|
||||
id=language, title=title)
|
||||
appyTool.log('Translation object created for "%s".' % language)
|
||||
# Now, we synchronise every Translation object with the corresponding
|
||||
# "po" file on disk.
|
||||
appFolder = self.config.diskFolder
|
||||
appName = self.config.PROJECTNAME
|
||||
i18nFolder = os.path.join(appFolder, 'tr')
|
||||
for translation in appyTool.translations:
|
||||
# Get the "po" file
|
||||
poName = '%s-%s.po' % (appName, translation.id)
|
||||
poFile = PoParser(os.path.join(i18nFolder, poName)).parse()
|
||||
for message in poFile.messages:
|
||||
setattr(translation, message.id, message.getMessage())
|
||||
appyTool.log('Translation "%s" updated from "%s".' % \
|
||||
(translation.id, poName))
|
||||
|
||||
# Execute custom installation code if any
|
||||
if hasattr(appyTool, 'onInstall'): appyTool.onInstall()
|
||||
|
||||
# Now, if required, we synchronise every Translation object with the
|
||||
# corresponding "po" file on disk.
|
||||
if appyTool.loadTranslationsAtStartup:
|
||||
appFolder = self.config.diskFolder
|
||||
appName = self.config.PROJECTNAME
|
||||
i18nFolder = os.path.join(appFolder, 'tr')
|
||||
for translation in appyTool.translations:
|
||||
# Get the "po" file
|
||||
poName = '%s-%s.po' % (appName, translation.id)
|
||||
poFile = PoParser(os.path.join(i18nFolder, poName)).parse()
|
||||
for message in poFile.messages:
|
||||
setattr(translation, message.id, message.getMessage())
|
||||
appyTool.log('Translation "%s" updated from "%s".' % \
|
||||
(translation.id, poName))
|
||||
|
||||
|
||||
def configureSessions(self):
|
||||
'''Configure the session machinery.'''
|
||||
# Register a function warning us when a session object is deleted. When
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue