mirror of
https://github.com/NaN-tic/trytond-translate_apertium.git
synced 2023-12-14 02:03:02 +01:00
Process Popen force utf-8
This commit is contained in:
parent
fa6fd8d807
commit
f8f3063ce1
1 changed files with 8 additions and 3 deletions
11
translate.py
11
translate.py
|
@ -35,9 +35,14 @@ class TranslateWizardTranslation:
|
|||
|
||||
@classmethod
|
||||
def get_translation_from_apertium(cls, text, source_lang, target_lang):
|
||||
proccess = Popen('echo "%s" | apertium %s-%s' %
|
||||
(text, source_lang[:2], target_lang[:2]),
|
||||
shell=True, stdout=PIPE, stderr=PIPE)
|
||||
cmd = 'echo "%s" | apertium %s-%s' % (
|
||||
text,
|
||||
source_lang[:2],
|
||||
target_lang[:2],
|
||||
)
|
||||
# force utf8 - TypeError: execv() arg 2 must contain only strings
|
||||
cmd = cmd.encode('utf-8')
|
||||
proccess = Popen(cmd, shell=True, stdout=PIPE, stderr=PIPE)
|
||||
out, error = proccess.communicate()
|
||||
if error:
|
||||
cls.raise_user_error('error_translating', error_args=(text,))
|
||||
|
|
Loading…
Reference in a new issue