appy.pod: added .docx and .xlsx as conversion formats for converter.py. appy.gen: translation system: if not message is present, the label itself is used for the message.
This commit is contained in:
parent
e5cef2b8a4
commit
41fbedd279
4 changed files with 36 additions and 12 deletions
|
@ -1088,9 +1088,13 @@ class BaseMixin:
|
|||
# Fallback to 'en'.
|
||||
translation = getattr(tool, 'en').appy()
|
||||
res = getattr(translation, label, '')
|
||||
# Perform replacements if needed
|
||||
for name, repl in mapping.iteritems():
|
||||
res = res.replace('${%s}' % name, repl)
|
||||
# If still no result, put the label instead of a translated message
|
||||
if not res: res = label
|
||||
else:
|
||||
# Perform replacements
|
||||
res = res.replace('\r\n', '<br/>').replace('\n', '<br/>')
|
||||
for name, repl in mapping.iteritems():
|
||||
res = res.replace('${%s}' % name, repl)
|
||||
return res
|
||||
|
||||
def getPageLayout(self, layoutType):
|
||||
|
|
|
@ -1,4 +1,7 @@
|
|||
# ------------------------------------------------------------------------------
|
||||
import os.path
|
||||
import appy
|
||||
from appy.shared.utils import executeCommand
|
||||
from appy.gen.plone25.wrappers import AbstractWrapper
|
||||
|
||||
# ------------------------------------------------------------------------------
|
||||
|
@ -109,4 +112,14 @@ class ToolWrapper(AbstractWrapper):
|
|||
def getAvailableLanguages(self):
|
||||
'''Returns the list of available languages for this application.'''
|
||||
return [(t.id, t.title) for t in self.translations]
|
||||
|
||||
def convert(self, fileName, format):
|
||||
'''Launches a UNO-enabled Python interpreter as defined in the self for
|
||||
converting, using OpenOffice in server mode, a file named p_fileName
|
||||
into an output p_format.'''
|
||||
convScript = '%s/pod/converter.py' % os.path.dirname(appy.__file__)
|
||||
cmd = '%s %s "%s" %s -p%d' % (self.unoEnabledPython, convScript,
|
||||
fileName, format, self.openOfficePort)
|
||||
self.log('Executing %s...' % cmd)
|
||||
return executeCommand(cmd) # The result can contain an error message
|
||||
# ------------------------------------------------------------------------------
|
||||
|
|
|
@ -291,10 +291,7 @@ class FileWrapper:
|
|||
if format:
|
||||
if not tool: return
|
||||
# Convert the dumped file using OpenOffice
|
||||
convScript = '%s/converter.py' % os.path.dirname(appy.pod.__file__)
|
||||
cmd = '%s %s "%s" %s -p%d' % (tool.unoEnabledPython, convScript,
|
||||
filePath, format, tool.openOfficePort)
|
||||
errorMessage = executeCommand(cmd)
|
||||
errorMessage = tool.convert(filePath, format)
|
||||
# Even if we have an "error" message, it could be a simple warning.
|
||||
# So we will continue here and, as a subsequent check for knowing if
|
||||
# an error occurred or not, we will test the existence of the
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue