[gen] One can now specify a different source language for every translation.
This commit is contained in:
parent
6ee3d6ded9
commit
f091b25c98
|
@ -183,12 +183,13 @@ class Group(ModelClass):
|
||||||
|
|
||||||
# The Translation class --------------------------------------------------------
|
# The Translation class --------------------------------------------------------
|
||||||
class Translation(ModelClass):
|
class Translation(ModelClass):
|
||||||
_appy_attributes = ['po', 'title']
|
_appy_attributes = ['po', 'title', 'sourceLanguage']
|
||||||
# All methods defined below are fake. Real versions are in the wrapper.
|
# All methods defined below are fake. Real versions are in the wrapper.
|
||||||
|
actionsPage = gen.Page('actions')
|
||||||
def getPoFile(self): pass
|
def getPoFile(self): pass
|
||||||
po = gen.Action(action=getPoFile, page=gen.Page('actions', show='view'),
|
po = gen.Action(action=getPoFile, page=actionsPage, result='filetmp')
|
||||||
result='filetmp')
|
sourceLanguage = gen.String(page=actionsPage, width=4)
|
||||||
title = gen.String(show=False, indexed=True)
|
title = gen.String(show=False, indexed=True, page=actionsPage)
|
||||||
def label(self): pass
|
def label(self): pass
|
||||||
def show(self, name): pass
|
def show(self, name): pass
|
||||||
|
|
||||||
|
|
|
@ -10,7 +10,11 @@ class TranslationWrapper(AbstractWrapper):
|
||||||
'''The label for a text to translate displays the text of the
|
'''The label for a text to translate displays the text of the
|
||||||
corresponding message in the source translation.'''
|
corresponding message in the source translation.'''
|
||||||
tool = self.tool
|
tool = self.tool
|
||||||
sourceLanguage = self.o.getProductConfig().sourceLanguage
|
# Get the source language: either defined on the translation itself,
|
||||||
|
# either from the config object.
|
||||||
|
sourceLanguage = self.sourceLanguage
|
||||||
|
if not sourceLanguage:
|
||||||
|
sourceLanguage = self.o.getProductConfig().sourceLanguage
|
||||||
sourceTranslation = getattr(tool.o, sourceLanguage).appy()
|
sourceTranslation = getattr(tool.o, sourceLanguage).appy()
|
||||||
# p_field is the Computed field. We need to get the name of the
|
# p_field is the Computed field. We need to get the name of the
|
||||||
# corresponding field holding the translation message.
|
# corresponding field holding the translation message.
|
||||||
|
@ -28,9 +32,9 @@ class TranslationWrapper(AbstractWrapper):
|
||||||
if url.endswith('/ui/edit') or url.endswith('/do'):
|
if url.endswith('/ui/edit') or url.endswith('/do'):
|
||||||
sourceMsg = sourceMsg.replace('<','<').replace('>','>')
|
sourceMsg = sourceMsg.replace('<','<').replace('>','>')
|
||||||
sourceMsg = sourceMsg.replace('\n', '<br/>')
|
sourceMsg = sourceMsg.replace('\n', '<br/>')
|
||||||
return '<div class="translationLabel"><acronym title="%s">' \
|
return '<div class="translationLabel"><acronym title="%s" ' \
|
||||||
'<img src="ui/help.png"/></acronym>%s</div>' % \
|
'style="margin-right: 5px"><img src="ui/help.png"/></acronym>' \
|
||||||
(fieldName, sourceMsg)
|
'%s</div>' % (fieldName, sourceMsg)
|
||||||
|
|
||||||
def show(self, field):
|
def show(self, field):
|
||||||
'''We show a field (or its label) only if the corresponding source
|
'''We show a field (or its label) only if the corresponding source
|
||||||
|
@ -54,7 +58,9 @@ class TranslationWrapper(AbstractWrapper):
|
||||||
'%s-%s.po' % (tool.o.getAppName(), self.id))
|
'%s-%s.po' % (tool.o.getAppName(), self.id))
|
||||||
poFile = PoFile(fileName)
|
poFile = PoFile(fileName)
|
||||||
for field in self.fields:
|
for field in self.fields:
|
||||||
if (field.name == 'title') or (field.type != 'String'): continue
|
# Ignore labels and appy-specific fields in page 'actions'.
|
||||||
|
if (field.page.name == 'actions') or (field.type != 'String'):
|
||||||
|
continue
|
||||||
# Adds the PO message corresponding to this field
|
# Adds the PO message corresponding to this field
|
||||||
msg = field.getValue(self.o) or ''
|
msg = field.getValue(self.o) or ''
|
||||||
for old, new in self.poReplacements:
|
for old, new in self.poReplacements:
|
||||||
|
|
Loading…
Reference in a new issue