mirror of
https://github.com/NaN-tic/trytond-translate_apertium.git
synced 2023-12-14 02:03:02 +01:00
Translate configuration unknown words
This commit is contained in:
parent
fc166dea56
commit
68a825a1fe
7 changed files with 50 additions and 2 deletions
|
@ -2,11 +2,12 @@
|
|||
# The COPYRIGHT file at the top level of this repository contains the full
|
||||
# copyright notices and license terms.
|
||||
from trytond.pool import Pool
|
||||
from .configuration import *
|
||||
from .translate import *
|
||||
|
||||
|
||||
def register():
|
||||
Pool.register(
|
||||
Configuration,
|
||||
TranslateWizardStart,
|
||||
TranslateWizardTranslation,
|
||||
module='translate_apertium', type_='model')
|
||||
|
|
14
configuration.py
Normal file
14
configuration.py
Normal file
|
@ -0,0 +1,14 @@
|
|||
#This file is part translate module for Tryton.
|
||||
#The COPYRIGHT file at the top level of this repository contains
|
||||
#the full copyright notices and license terms.
|
||||
from trytond.model import fields
|
||||
from trytond.pool import PoolMeta
|
||||
|
||||
__all__ = ['Configuration']
|
||||
__metaclass__ = PoolMeta
|
||||
|
||||
|
||||
class Configuration:
|
||||
__name__ = 'translate.configuration'
|
||||
apertium_unknown_words = fields.Boolean('Unknown Words',
|
||||
help='Dissable Apertium unknown words')
|
12
configuration.xml
Normal file
12
configuration.xml
Normal file
|
@ -0,0 +1,12 @@
|
|||
<?xml version="1.0"?>
|
||||
<!-- This file is part translate_apertium module for Tryton.
|
||||
The COPYRIGHT file at the top level of this repository contains the full copyright notices and license terms. -->
|
||||
<tryton>
|
||||
<data>
|
||||
<record model="ir.ui.view" id="translate_configuration_view_form">
|
||||
<field name="model">translate.configuration</field>
|
||||
<field name="inherit" ref="translate.translate_configuration_view_form"/>
|
||||
<field name="name">configuration_form</field>
|
||||
</record>
|
||||
</data>
|
||||
</tryton>
|
|
@ -13,6 +13,10 @@ class TranslateApertiumTestCase(unittest.TestCase):
|
|||
def setUp(self):
|
||||
trytond.tests.test_tryton.install_module('translate_apertium')
|
||||
|
||||
def test0005views(self):
|
||||
'Test views'
|
||||
test_view('translate')
|
||||
|
||||
def test0006depends(self):
|
||||
'Test depends'
|
||||
test_depends()
|
||||
|
|
|
@ -2,7 +2,7 @@
|
|||
# The COPYRIGHT file at the top level of this repository contains the full
|
||||
# copyright notices and license terms.
|
||||
import subprocess
|
||||
from trytond.pool import PoolMeta
|
||||
from trytond.pool import Pool, PoolMeta
|
||||
|
||||
__all__ = ['TranslateWizardStart', 'TranslateWizardTranslation']
|
||||
__metaclass__ = PoolMeta
|
||||
|
@ -43,8 +43,13 @@ class TranslateWizardTranslation:
|
|||
|
||||
@classmethod
|
||||
def get_translation_from_apertium(cls, text, source_lang, target_lang):
|
||||
Config = Pool().get('translate.configuration')
|
||||
trans_config = Config(1)
|
||||
|
||||
lang = '%s-%s' % (source_lang[:2], target_lang[:2])
|
||||
cmd = ['apertium', lang]
|
||||
if trans_config.apertium_unknown_words:
|
||||
cmd.append('-u')
|
||||
out, error = apertium_output(cmd, text)
|
||||
if error:
|
||||
cls.raise_user_error('error_translating', error_args=(text,))
|
||||
|
|
|
@ -4,3 +4,5 @@ depends:
|
|||
ir
|
||||
res
|
||||
translate
|
||||
xml:
|
||||
configuration.xml
|
||||
|
|
10
view/configuration_form.xml
Normal file
10
view/configuration_form.xml
Normal file
|
@ -0,0 +1,10 @@
|
|||
<?xml version="1.0"?>
|
||||
<!-- This file is part translate_apertium module for Tryton.
|
||||
The COPYRIGHT file at the top level of this repository contains the full copyright notices and license terms. -->
|
||||
<data>
|
||||
<xpath expr="/form" position="inside">
|
||||
<separator id="apertium" string="Apertium" colspan="6"/>
|
||||
<label name="apertium_unknown_words"/>
|
||||
<field name="apertium_unknown_words"/>
|
||||
</xpath>
|
||||
</data>
|
Loading…
Add table
Add a link
Reference in a new issue