26 |
26 |
from wcs.blocks import BlockDef
|
27 |
27 |
from wcs.carddef import CardDef
|
28 |
28 |
from wcs.categories import Category
|
29 |
|
from wcs.formdef import FormDef
|
|
29 |
from wcs.formdef import FormDef, UpdateDigestAfterJob
|
30 |
30 |
from wcs.mail_templates import MailTemplate
|
31 |
31 |
from wcs.qommon import _, errors, get_cfg, misc, ods, template
|
32 |
32 |
from wcs.qommon.afterjobs import AfterJob
|
... | ... | |
216 |
216 |
if form.is_submitted() and not form.has_errors():
|
217 |
217 |
setattr(self.msg, attr, form.get_widget('translation').parse())
|
218 |
218 |
self.msg.store()
|
|
219 |
update_digests()
|
219 |
220 |
return redirect('../../?' + get_request().get_query())
|
220 |
221 |
|
221 |
222 |
html_top('i18n', title=_('Multilinguism'))
|
... | ... | |
376 |
377 |
source = cells[0].find('{urn:oasis:names:tc:opendocument:xmlns:text:1.0}p').text
|
377 |
378 |
target = cells[1].find('{urn:oasis:names:tc:opendocument:xmlns:text:1.0}p').text
|
378 |
379 |
self.add_string(source, target)
|
|
380 |
update_digests()
|
379 |
381 |
elif b'urn:oasis:names:tc:xliff:document' in self.file_content[:1000]:
|
380 |
382 |
doc = ET.parse(io.BytesIO(self.file_content))
|
381 |
383 |
segments = doc.findall('.//{urn:oasis:names:tc:xliff:document:2.0}segment')
|
... | ... | |
385 |
387 |
source = segment.find('{urn:oasis:names:tc:xliff:document:2.0}source').text
|
386 |
388 |
target = segment.find('{urn:oasis:names:tc:xliff:document:2.0}target').text
|
387 |
389 |
self.add_string(source, target)
|
|
390 |
update_digests()
|
388 |
391 |
else:
|
389 |
392 |
self.status = 'failed'
|
390 |
393 |
self.failure_label = str(_('Unknown file format'))
|
... | ... | |
397 |
400 |
|
398 |
401 |
def done_button_attributes(self):
|
399 |
402 |
return {'data-redirect-auto': 'true'}
|
|
403 |
|
|
404 |
|
|
405 |
def update_digests():
|
|
406 |
# for all carddefs, check if |translate in digest templates, and rebuild if necessary.
|
|
407 |
carddefs = []
|
|
408 |
for carddef in CardDef.select():
|
|
409 |
for template in (carddef.digest_templates or {}).values():
|
|
410 |
if '|translate' in template:
|
|
411 |
carddefs.append(carddef)
|
|
412 |
break
|
|
413 |
if carddefs and get_response():
|
|
414 |
get_response().add_after_job(UpdateDigestAfterJob(formdefs=carddefs))
|
|
415 |
elif carddefs:
|
|
416 |
UpdateDigestAfterJob(formdefs=carddefs).execute()
|
400 |
|
-
|