Hello, I tried the trick written in the Apertium wiki but this did not work because module “sys” doesn't have a “setdefaultencoding” function. Nevertheless after many tries, I finally had it work using temporary files instead of stdin/stdout to transfer text to and from Apertium. I modified the file “/usr/share/apertium/dbus-1/command_line.py” from package “apertium-dbus” and replaced the body of the first function “call” with this code:
############################## def call(cmdline, _in): import os, commands, tempfile # create temporary files fidin, tmpfilein = tempfile.mkstemp() os.close(fidin) fidout, tmpfileout = tempfile.mkstemp() os.close(fidout) # write text to be translated fidin = open(tmpfilein, "w") fidin.write(_in.encode('utf-8')) fidin.close() # call apertium cmdline.append(tmpfilein) cmdline.append(tmpfileout) err, out = commands.getstatusoutput(" ".join(cmdline)) os.remove(tmpfilein) # get translated text fidout = open(tmpfileout, "r") out = fidout.read() fidout.close() os.remove(tmpfileout) return out, err ############################## To test it you may have to restart the DBus interface first using the following command: $ dbus-send / org.apertium.General.QuitSignal This will reload the modified Python script. Regards, JM. Philippe
signature.asc
Description: OpenPGP digital signature