/usr/share/lokalize/scripts/odf/xliff2odf.py is in lokalize 4:15.12.3-0ubuntu1.
This file is owned by root:root, with mode 0o644.
The actual contents of the file can be viewed below.
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 | # -*- coding: utf-8 -*-
import Kross
import Lokalize
import Project
import Editor
import sys,os,re
from translate.convert import xliff2odf
from translate.storage import factory
Lokalize.busyCursor(True)
class XliffInput:
def __init__(self, name, contents):
self.name=name
self.contents=contents
self.read=lambda: contents
def close(self): return
def convert():
if not Editor.isValid() or Editor.currentFile()=='': return
xliffpathname=Editor.currentFile()
(path, filename)=os.path.split(xliffpathname)
if not filename.endswith('.xlf'): return
store = factory.getobject(xliffpathname)
odfpathname=store.getfilenames()[0]
if odfpathname.startswith('NoName'):
print 'translate-toolkit is too old'
odfpathname=os.path.splitext(xliffpathname)[0]+'.odt'
if not os.path.exists(odfpathname): return
translatedodfpathname=os.path.splitext(odfpathname)[0]+'-'+Project.targetLangCode()+'.odt'
print 'translatedodfpathname %s' % translatedodfpathname
print 'odfpathname %s' % odfpathname
xliffinput=XliffInput(xliffpathname,Editor.currentFileContents())
odf=open(odfpathname,'rb')
xliff2odf.convertxliff(xliffinput, translatedodfpathname, odf)
ourpath=([p for p in sys.path if os.path.exists(p+'/xliff2odf.py')]+[''])[0]
os.system('python "'+ourpath+'/xliff2odf-standalone.py" "%s" "%s" &'%(translatedodfpathname, Editor.currentEntryId()))
try: convert()
except: print 'error occured'
Lokalize.busyCursor(False)
|