diff --git a/addons/account_test/i18n/sv.po b/addons/account_test/i18n/sv.po new file mode 100644 index 00000000000..78dea50f511 --- /dev/null +++ b/addons/account_test/i18n/sv.po @@ -0,0 +1,266 @@ +# Swedish translation for openobject-addons +# Copyright (c) 2014 Rosetta Contributors and Canonical Ltd 2014 +# This file is distributed under the same license as the openobject-addons package. +# FIRST AUTHOR , 2014. +# +msgid "" +msgstr "" +"Project-Id-Version: openobject-addons\n" +"Report-Msgid-Bugs-To: FULL NAME \n" +"POT-Creation-Date: 2012-12-21 17:05+0000\n" +"PO-Revision-Date: 2014-03-31 21:13+0000\n" +"Last-Translator: FULL NAME \n" +"Language-Team: Swedish \n" +"MIME-Version: 1.0\n" +"Content-Type: text/plain; charset=UTF-8\n" +"Content-Transfer-Encoding: 8bit\n" +"X-Launchpad-Export-Date: 2014-04-01 05:39+0000\n" +"X-Generator: Launchpad (build 16967)\n" + +#. module: account_test +#: view:accounting.assert.test:0 +msgid "" +"Code should always set a variable named `result` with the result of your " +"test, that can be a list or\n" +"a dictionary. If `result` is an empty list, it means that the test was " +"succesful. Otherwise it will\n" +"try to translate and print what is inside `result`.\n" +"\n" +"If the result of your test is a dictionary, you can set a variable named " +"`column_order` to choose in\n" +"what order you want to print `result`'s content.\n" +"\n" +"Should you need them, you can also use the following variables into your " +"code:\n" +" * cr: cursor to the database\n" +" * uid: ID of the current user\n" +"\n" +"In any ways, the code must be legal python statements with correct " +"indentation (if needed).\n" +"\n" +"Example: \n" +" sql = '''SELECT id, name, ref, date\n" +" FROM account_move_line \n" +" WHERE account_id IN (SELECT id FROM account_account WHERE type " +"= 'view')\n" +" '''\n" +" cr.execute(sql)\n" +" result = cr.dictfetchall()" +msgstr "" +"Kod ska alltid ställa en variabel med namnet `resultat` med resultatet av " +"ditt test, kan det vara en lista eller\n" +"en ordbok. Om `resultat` är en tom lista, betyder det att testet var lyckat. " +"Annars kommer\n" +"försöka översätta och skriva ut vad som finns i `resultat`.\n" +"\n" +"Om resultatet av testet är en ordbok kan du ställa in en variabel med namnet " +"`column_order` för att välja in\n" +"vilken ordning du vill skriva ut `resultat` s innehåll.\n" +"\n" +"Om du behöver dem, kan du även använda följande variabler i koden:\n" +" * Cr: markören till databasen\n" +" * Uid: ID för den aktuella användaren\n" +"\n" +"På något sätt måste koden vara lagliga python uttalanden med rätt indrag (om " +"det behövs).\n" +"\n" +"Exempel:\n" +" sql ='' 'SELECT id, namn, ref, datum\n" +" FRÅN account_move_line\n" +" VAR konto-IN (SELECT id FROM account_account WHERE typ = " +"\"Visa\")\n" +" '' '\n" +" cr.execute (SQL)\n" +" resultat = cr.dictfetchall ()" + +#. module: account_test +#: model:accounting.assert.test,name:account_test.account_test_02 +msgid "Test 2: Opening a fiscal year" +msgstr "" + +#. module: account_test +#: model:accounting.assert.test,desc:account_test.account_test_05 +msgid "" +"Check that reconciled invoice for Sales/Purchases has reconciled entries for " +"Payable and Receivable Accounts" +msgstr "" + +#. module: account_test +#: model:accounting.assert.test,desc:account_test.account_test_03 +msgid "" +"Check if movement lines are balanced and have the same date and period" +msgstr "" + +#. module: account_test +#: field:accounting.assert.test,name:0 +msgid "Test Name" +msgstr "Testnamn" + +#. module: account_test +#: report:account.test.assert.print:0 +msgid "Accouting tests on" +msgstr "" + +#. module: account_test +#: model:accounting.assert.test,name:account_test.account_test_01 +msgid "Test 1: General balance" +msgstr "" + +#. module: account_test +#: model:accounting.assert.test,desc:account_test.account_test_06 +msgid "Check that paid/reconciled invoices are not in 'Open' state" +msgstr "" + +#. module: account_test +#: model:accounting.assert.test,desc:account_test.account_test_05_2 +msgid "" +"Check that reconciled account moves, that define Payable and Receivable " +"accounts, are belonging to reconciled invoices" +msgstr "" + +#. module: account_test +#: view:accounting.assert.test:0 +msgid "Tests" +msgstr "Tester" + +#. module: account_test +#: field:accounting.assert.test,desc:0 +msgid "Test Description" +msgstr "" + +#. module: account_test +#: view:accounting.assert.test:0 +msgid "Description" +msgstr "" + +#. module: account_test +#: model:accounting.assert.test,desc:account_test.account_test_06_1 +msgid "Check that there's no move for any account with « View » account type" +msgstr "" + +#. module: account_test +#: model:accounting.assert.test,name:account_test.account_test_08 +msgid "Test 9 : Accounts and partners on account moves" +msgstr "" + +#. module: account_test +#: model:ir.actions.act_window,name:account_test.action_accounting_assert +#: model:ir.actions.report.xml,name:account_test.account_assert_test_report +#: model:ir.ui.menu,name:account_test.menu_action_license +msgid "Accounting Tests" +msgstr "" + +#. module: account_test +#: code:addons/account_test/report/account_test_report.py:74 +#, python-format +msgid "The test was passed successfully" +msgstr "" + +#. module: account_test +#: field:accounting.assert.test,active:0 +msgid "Active" +msgstr "" + +#. module: account_test +#: model:accounting.assert.test,name:account_test.account_test_06 +msgid "Test 6 : Invoices status" +msgstr "" + +#. module: account_test +#: model:ir.model,name:account_test.model_accounting_assert_test +msgid "accounting.assert.test" +msgstr "" + +#. module: account_test +#: model:accounting.assert.test,name:account_test.account_test_05 +msgid "" +"Test 5.1 : Payable and Receivable accountant lines of reconciled invoices" +msgstr "" + +#. module: account_test +#: field:accounting.assert.test,code_exec:0 +msgid "Python code" +msgstr "" + +#. module: account_test +#: model:accounting.assert.test,desc:account_test.account_test_07 +msgid "" +"Check on bank statement that the Closing Balance = Starting Balance + sum of " +"statement lines" +msgstr "" + +#. module: account_test +#: model:accounting.assert.test,name:account_test.account_test_07 +msgid "Test 8 : Closing balance on bank statements" +msgstr "" + +#. module: account_test +#: model:accounting.assert.test,name:account_test.account_test_03 +msgid "Test 3: Movement lines" +msgstr "" + +#. module: account_test +#: model:accounting.assert.test,name:account_test.account_test_05_2 +msgid "Test 5.2 : Reconcilied invoices and Payable/Receivable accounts" +msgstr "" + +#. module: account_test +#: view:accounting.assert.test:0 +msgid "Expression" +msgstr "" + +#. module: account_test +#: model:accounting.assert.test,name:account_test.account_test_04 +msgid "Test 4: Totally reconciled mouvements" +msgstr "" + +#. module: account_test +#: model:accounting.assert.test,desc:account_test.account_test_04 +msgid "Check if the totally reconciled movements are balanced" +msgstr "" + +#. module: account_test +#: field:accounting.assert.test,sequence:0 +msgid "Sequence" +msgstr "" + +#. module: account_test +#: model:accounting.assert.test,desc:account_test.account_test_02 +msgid "" +"Check if the balance of the new opened fiscal year matches with last year's " +"balance" +msgstr "" + +#. module: account_test +#: view:accounting.assert.test:0 +msgid "Python Code" +msgstr "" + +#. module: account_test +#: model:ir.actions.act_window,help:account_test.action_accounting_assert +msgid "" +"

\n" +" Click to create Accounting Test.\n" +"

\n" +" " +msgstr "" + +#. module: account_test +#: model:accounting.assert.test,desc:account_test.account_test_01 +msgid "Check the balance: Debit sum = Credit sum" +msgstr "" + +#. module: account_test +#: model:accounting.assert.test,desc:account_test.account_test_08 +msgid "Check that general accounts and partners on account moves are active" +msgstr "" + +#. module: account_test +#: model:accounting.assert.test,name:account_test.account_test_06_1 +msgid "Test 7: « View  » account type" +msgstr "" + +#. module: account_test +#: view:accounting.assert.test:0 +msgid "Code Help" +msgstr "" diff --git a/addons/analytic_contract_hr_expense/i18n/sv.po b/addons/analytic_contract_hr_expense/i18n/sv.po new file mode 100644 index 00000000000..acad6977b6a --- /dev/null +++ b/addons/analytic_contract_hr_expense/i18n/sv.po @@ -0,0 +1,72 @@ +# Swedish translation for openobject-addons +# Copyright (c) 2014 Rosetta Contributors and Canonical Ltd 2014 +# This file is distributed under the same license as the openobject-addons package. +# FIRST AUTHOR , 2014. +# +msgid "" +msgstr "" +"Project-Id-Version: openobject-addons\n" +"Report-Msgid-Bugs-To: FULL NAME \n" +"POT-Creation-Date: 2012-12-21 17:05+0000\n" +"PO-Revision-Date: 2014-03-31 21:25+0000\n" +"Last-Translator: FULL NAME \n" +"Language-Team: Swedish \n" +"MIME-Version: 1.0\n" +"Content-Type: text/plain; charset=UTF-8\n" +"Content-Transfer-Encoding: 8bit\n" +"X-Launchpad-Export-Date: 2014-04-01 05:39+0000\n" +"X-Generator: Launchpad (build 16967)\n" + +#. module: analytic_contract_hr_expense +#: view:account.analytic.account:0 +msgid "or view" +msgstr "eller visa" + +#. module: analytic_contract_hr_expense +#: view:account.analytic.account:0 +msgid "Nothing to invoice, create" +msgstr "Inget att fakturera, skapa" + +#. module: analytic_contract_hr_expense +#: view:account.analytic.account:0 +msgid "expenses" +msgstr "utlägg" + +#. module: analytic_contract_hr_expense +#: model:ir.model,name:analytic_contract_hr_expense.model_account_analytic_account +msgid "Analytic Account" +msgstr "Objektkonto" + +#. module: analytic_contract_hr_expense +#: code:addons/analytic_contract_hr_expense/analytic_contract_hr_expense.py:144 +#, python-format +msgid "Expenses to Invoice of %s" +msgstr "Utlägg att fakturera av %s" + +#. module: analytic_contract_hr_expense +#: code:addons/analytic_contract_hr_expense/analytic_contract_hr_expense.py:136 +#, python-format +msgid "Expenses of %s" +msgstr "Utlägg av %s" + +#. module: analytic_contract_hr_expense +#: field:account.analytic.account,expense_invoiced:0 +#: field:account.analytic.account,expense_to_invoice:0 +#: field:account.analytic.account,remaining_expense:0 +msgid "unknown" +msgstr "okänd" + +#. module: analytic_contract_hr_expense +#: field:account.analytic.account,est_expenses:0 +msgid "Estimation of Expenses to Invoice" +msgstr "Uppskattning av utlägg att fakturera" + +#. module: analytic_contract_hr_expense +#: field:account.analytic.account,charge_expenses:0 +msgid "Charge Expenses" +msgstr "Debitera utläggen" + +#. module: analytic_contract_hr_expense +#: view:account.analytic.account:0 +msgid "⇒ Invoice" +msgstr "⇒ Faktura" diff --git a/addons/base_gengo/gengo_sync_schedular_data.xml b/addons/base_gengo/gengo_sync_schedular_data.xml index baf2a639cff..e55066e0e74 100644 --- a/addons/base_gengo/gengo_sync_schedular_data.xml +++ b/addons/base_gengo/gengo_sync_schedular_data.xml @@ -4,7 +4,7 @@ Gengo Sync Translation (Response) - + 20 minutes -1 @@ -16,7 +16,7 @@ Gengo Sync Translation (Request) - + 20 minutes -1 diff --git a/addons/base_gengo/i18n/sv.po b/addons/base_gengo/i18n/sv.po new file mode 100644 index 00000000000..79d7d7dd96c --- /dev/null +++ b/addons/base_gengo/i18n/sv.po @@ -0,0 +1,249 @@ +# Swedish translation for openobject-addons +# Copyright (c) 2014 Rosetta Contributors and Canonical Ltd 2014 +# This file is distributed under the same license as the openobject-addons package. +# FIRST AUTHOR , 2014. +# +msgid "" +msgstr "" +"Project-Id-Version: openobject-addons\n" +"Report-Msgid-Bugs-To: FULL NAME \n" +"POT-Creation-Date: 2012-12-21 17:05+0000\n" +"PO-Revision-Date: 2014-03-31 16:36+0000\n" +"Last-Translator: FULL NAME \n" +"Language-Team: Swedish \n" +"MIME-Version: 1.0\n" +"Content-Type: text/plain; charset=UTF-8\n" +"Content-Transfer-Encoding: 8bit\n" +"X-Launchpad-Export-Date: 2014-04-01 05:39+0000\n" +"X-Generator: Launchpad (build 16967)\n" + +#. module: base_gengo +#: view:res.company:0 +msgid "Comments for Translator" +msgstr "" + +#. module: base_gengo +#: field:ir.translation,job_id:0 +msgid "Gengo Job ID" +msgstr "" + +#. module: base_gengo +#: code:addons/base_gengo/wizard/base_gengo_translations.py:114 +#, python-format +msgid "This language is not supported by the Gengo translation services." +msgstr "" + +#. module: base_gengo +#: field:res.company,gengo_comment:0 +msgid "Comments" +msgstr "Kommentarer" + +#. module: base_gengo +#: field:res.company,gengo_private_key:0 +msgid "Gengo Private Key" +msgstr "" + +#. module: base_gengo +#: model:ir.model,name:base_gengo.model_base_gengo_translations +msgid "base.gengo.translations" +msgstr "base.gengo.translations" + +#. module: base_gengo +#: help:res.company,gengo_auto_approve:0 +msgid "Jobs are Automatically Approved by Gengo." +msgstr "" + +#. module: base_gengo +#: field:base.gengo.translations,lang_id:0 +msgid "Language" +msgstr "" + +#. module: base_gengo +#: field:ir.translation,gengo_comment:0 +msgid "Comments & Activity Linked to Gengo" +msgstr "" + +#. module: base_gengo +#: code:addons/base_gengo/wizard/base_gengo_translations.py:124 +#, python-format +msgid "Gengo Sync Translation (Response)" +msgstr "" + +#. module: base_gengo +#: code:addons/base_gengo/wizard/base_gengo_translations.py:72 +#, python-format +msgid "" +"Gengo `Public Key` or `Private Key` are missing. Enter your Gengo " +"authentication parameters under `Settings > Companies > Gengo Parameters`." +msgstr "" + +#. module: base_gengo +#: selection:ir.translation,gengo_translation:0 +msgid "Translation By Machine" +msgstr "" + +#. module: base_gengo +#: code:addons/base_gengo/wizard/base_gengo_translations.py:155 +#, python-format +msgid "" +"%s\n" +"\n" +"--\n" +" Commented on %s by %s." +msgstr "" + +#. module: base_gengo +#: field:ir.translation,gengo_translation:0 +msgid "Gengo Translation Service Level" +msgstr "" + +#. module: base_gengo +#: constraint:ir.translation:0 +msgid "" +"The Gengo translation service selected is not supported for this language." +msgstr "" + +#. module: base_gengo +#: selection:ir.translation,gengo_translation:0 +msgid "Standard" +msgstr "" + +#. module: base_gengo +#: help:ir.translation,gengo_translation:0 +msgid "" +"You can select here the service level you want for an automatic translation " +"using Gengo." +msgstr "" + +#. module: base_gengo +#: field:base.gengo.translations,restart_send_job:0 +msgid "Restart Sending Job" +msgstr "" + +#. module: base_gengo +#: view:ir.translation:0 +msgid "To Approve In Gengo" +msgstr "" + +#. module: base_gengo +#: view:res.company:0 +msgid "Private Key" +msgstr "" + +#. module: base_gengo +#: view:res.company:0 +msgid "Public Key" +msgstr "" + +#. module: base_gengo +#: field:res.company,gengo_public_key:0 +msgid "Gengo Public Key" +msgstr "" + +#. module: base_gengo +#: code:addons/base_gengo/wizard/base_gengo_translations.py:123 +#, python-format +msgid "Gengo Sync Translation (Request)" +msgstr "" + +#. module: base_gengo +#: view:ir.translation:0 +msgid "Translations" +msgstr "" + +#. module: base_gengo +#: field:res.company,gengo_auto_approve:0 +msgid "Auto Approve Translation ?" +msgstr "" + +#. module: base_gengo +#: model:ir.actions.act_window,name:base_gengo.action_wizard_base_gengo_translations +#: model:ir.ui.menu,name:base_gengo.menu_action_wizard_base_gengo_translations +msgid "Gengo: Manual Request of Translation" +msgstr "" + +#. module: base_gengo +#: code:addons/base_gengo/ir_translation.py:62 +#: code:addons/base_gengo/wizard/base_gengo_translations.py:109 +#, python-format +msgid "Gengo Authentication Error" +msgstr "" + +#. module: base_gengo +#: model:ir.model,name:base_gengo.model_res_company +msgid "Companies" +msgstr "" + +#. module: base_gengo +#: view:ir.translation:0 +msgid "" +"Note: If the translation state is 'In Progress', it means that the " +"translation has to be approved to be uploaded in this system. You are " +"supposed to do that directly by using your Gengo Account" +msgstr "" + +#. module: base_gengo +#: code:addons/base_gengo/wizard/base_gengo_translations.py:82 +#, python-format +msgid "" +"Gengo connection failed with this message:\n" +"``%s``" +msgstr "" + +#. module: base_gengo +#: view:res.company:0 +msgid "Gengo Parameters" +msgstr "" + +#. module: base_gengo +#: view:base.gengo.translations:0 +msgid "Send" +msgstr "" + +#. module: base_gengo +#: selection:ir.translation,gengo_translation:0 +msgid "Ultra" +msgstr "" + +#. module: base_gengo +#: model:ir.model,name:base_gengo.model_ir_translation +msgid "ir.translation" +msgstr "" + +#. module: base_gengo +#: view:ir.translation:0 +msgid "Gengo Translation Service" +msgstr "" + +#. module: base_gengo +#: selection:ir.translation,gengo_translation:0 +msgid "Pro" +msgstr "" + +#. module: base_gengo +#: view:base.gengo.translations:0 +msgid "Gengo Request Form" +msgstr "" + +#. module: base_gengo +#: code:addons/base_gengo/wizard/base_gengo_translations.py:114 +#, python-format +msgid "Warning" +msgstr "" + +#. module: base_gengo +#: help:res.company,gengo_comment:0 +msgid "" +"This comment will be automatically be enclosed in each an every request sent " +"to Gengo" +msgstr "" + +#. module: base_gengo +#: view:base.gengo.translations:0 +msgid "Cancel" +msgstr "" + +#. module: base_gengo +#: view:base.gengo.translations:0 +msgid "or" +msgstr "" diff --git a/addons/base_gengo/ir_translation.py b/addons/base_gengo/ir_translation.py index 0ade9c54625..306516878cc 100644 --- a/addons/base_gengo/ir_translation.py +++ b/addons/base_gengo/ir_translation.py @@ -23,7 +23,7 @@ from openerp.osv import fields, osv from openerp.tools.translate import _ LANG_CODE_MAPPING = { - 'ar_SA': ('ar', 'Arabic'), + 'ar_SY': ('ar', 'Arabic'), 'id_ID': ('id', 'Indonesian'), 'nl_NL': ('nl', 'Dutch'), 'fr_CA': ('fr-ca', 'French (Canada)'), @@ -41,7 +41,19 @@ LANG_CODE_MAPPING = { 'fr_BE': ('fr', 'French'), 'ru_RU': ('ru', 'Russian'), 'it_IT': ('it', 'Italian'), - 'pt_BR': ('pt-br', 'Portuguese (Brazil)') + 'pt_BR': ('pt-br', 'Portuguese (Brazil)'), + 'th_TH': ('th', 'Thai'), + 'nb_NO': ('no', 'Norwegian'), + 'ro_RO': ('ro', 'Romanian'), + 'tr_TR': ('tr', 'Turkish'), + 'bg_BG': ('bg', 'Bulgarian'), + 'da_DK': ('da', 'Danish'), + 'en_GB': ('en-gb', 'English (British)'), + 'el_GR': ('el', 'Greek'), + 'vi_VN': ('vi', 'Vietnamese'), + 'he_IL': ('he', 'Hebrew'), + 'hu_HU': ('hu', 'Hungarian'), + 'fi_FI': ('fi', 'Finnish') } class ir_translation(osv.Model): @@ -71,18 +83,3 @@ class ir_translation(osv.Model): def _get_gengo_corresponding_language(cr, lang): return lang in LANG_CODE_MAPPING and LANG_CODE_MAPPING[lang][0] or lang - - def _check_lang_support(self, cr, uid, ids, context=None): - for term in self.browse(cr, uid, ids, context=context): - if term.gengo_translation: - supported_langs = self._get_all_supported_languages(cr, uid, context=context) - if supported_langs: - tier = "nonprofit" if term.gengo_translation == 'machine' else term.gengo_translation - language = self._get_gengo_corresponding_language(term.lang) - if tier not in supported_langs.get(language,[]): - return False - return True - - _constraints = [ - (_check_lang_support, 'The Gengo translation service selected is not supported for this language.', ['gengo_translation']) - ] diff --git a/addons/base_gengo/res_company.py b/addons/base_gengo/res_company.py index 3d038ac0813..1b083ecf5a2 100644 --- a/addons/base_gengo/res_company.py +++ b/addons/base_gengo/res_company.py @@ -30,6 +30,7 @@ class res_company(osv.Model): "gengo_public_key": fields.text("Gengo Public Key"), "gengo_comment": fields.text("Comments", help="This comment will be automatically be enclosed in each an every request sent to Gengo"), "gengo_auto_approve": fields.boolean("Auto Approve Translation ?", help="Jobs are Automatically Approved by Gengo."), + "gengo_sandbox": fields.boolean("Sandbox Mode", help="Check this box if you're using the sandbox mode of Gengo, mainly used for testing purpose."), } _defaults = { diff --git a/addons/base_gengo/res_company_view.xml b/addons/base_gengo/res_company_view.xml index 0f99efc8ad0..d08d809eb9c 100644 --- a/addons/base_gengo/res_company_view.xml +++ b/addons/base_gengo/res_company_view.xml @@ -17,8 +17,13 @@ - - + + + + + + + diff --git a/addons/base_gengo/wizard/base_gengo_translations.py b/addons/base_gengo/wizard/base_gengo_translations.py index bfd51480141..ecfb696fddc 100644 --- a/addons/base_gengo/wizard/base_gengo_translations.py +++ b/addons/base_gengo/wizard/base_gengo_translations.py @@ -40,22 +40,19 @@ except ImportError: GENGO_DEFAULT_LIMIT = 20 -DEFAULT_CRON_VALS = { - 'active': True, - 'interval_number': 20, - 'interval_type': 'minutes', - 'model': "'base.gengo.translations'", - 'args': "'(%s,)'" % (str(GENGO_DEFAULT_LIMIT)), -} - class base_gengo_translations(osv.osv_memory): _name = 'base.gengo.translations' _columns = { - 'restart_send_job': fields.boolean("Restart Sending Job"), + 'sync_type': fields.selection([('send', 'Send New Terms'), + ('receive', 'Receive Translation'), + ('both', 'Both')], "Sync Type"), 'lang_id': fields.many2one('res.lang', 'Language', required=True), + 'sync_limit': fields.integer("No. of terms to sync"), } - + _defaults = {'sync_type' : 'both', + 'sync_limit' : 20 + } def gengo_authentication(self, cr, uid, context=None): ''' This method tries to open a connection with Gengo. For that, it uses the Public and Private @@ -74,6 +71,7 @@ class base_gengo_translations(osv.osv_memory): gengo = MyGengo( public_key=user.company_id.gengo_public_key.encode('ascii'), private_key=user.company_id.gengo_private_key.encode('ascii'), + sandbox = user.company_id.gengo_sandbox, ) gengo.getAccountStats() return (True, gengo) @@ -81,22 +79,6 @@ class base_gengo_translations(osv.osv_memory): _logger.exception('Gengo connection failed') return (False, _("Gengo connection failed with this message:\n``%s``") % e) - def do_check_schedular(self, cr, uid, xml_id, name, fn, context=None): - """ - This function is used to reset a cron to its default values, or to recreate it if it was deleted. - """ - cron_pool = self.pool.get('ir.cron') - cron_vals = DEFAULT_CRON_VALS.copy() - cron_vals.update({'name': name, "function": fn}) - try: - res = [] - _, res = self.pool.get('ir.model.data').get_object_reference(cr, uid, 'base_gengo', xml_id) - cron_pool.write(cr, uid, [res], cron_vals, context=context) - except: - #the cron job was not found, probably deleted previously, so we create it again using default values - cron_vals.update({'numbercall': -1}) - return cron_pool.create(cr, uid, cron_vals, context=context) - def act_update(self, cr, uid, ids, context=None): ''' Function called by the wizard. @@ -113,15 +95,14 @@ class base_gengo_translations(osv.osv_memory): if language not in supported_langs: raise osv.except_osv(_("Warning"), _('This language is not supported by the Gengo translation services.')) - #send immediately a new request for the selected language (if any) ctx = context.copy() ctx['gengo_language'] = wizard.lang_id.id - self._sync_request(cr, uid, limit=GENGO_DEFAULT_LIMIT, context=ctx) - self._sync_response( cr, uid, limit=GENGO_DEFAULT_LIMIT, context=ctx) - #check the cron jobs and eventually restart/recreate them - if wizard.restart_send_job: - self.do_check_schedular(cr, uid, 'gengo_sync_send_request_scheduler', _('Gengo Sync Translation (Request)'), '_sync_request', context=context) - self.do_check_schedular(cr, uid, 'gengo_sync_receive_request_scheduler', _('Gengo Sync Translation (Response)'), '_sync_response', context=context) + if wizard.sync_limit > 200 or wizard.sync_limit < 1: + raise osv.except_osv(_("Warning"), _('Sync limit should between 1 to 200 for Gengo translation services.')) + if wizard.sync_type in ['send','both']: + self._sync_request(cr, uid, wizard.sync_limit, context=ctx) + if wizard.sync_type in ['receive','both']: + self._sync_response( cr, uid, wizard.sync_limit, context=ctx) return {'type': 'ir.actions.act_window_close'} def _sync_response(self, cr, uid, limit=GENGO_DEFAULT_LIMIT, context=None): @@ -135,31 +116,31 @@ class base_gengo_translations(osv.osv_memory): if not flag: _logger.warning("%s", gengo) else: - translation_id = translation_pool.search(cr, uid, [('state', '=', 'inprogress'), ('gengo_translation', 'in', ('machine','standard','pro','ultra'))], limit=limit, context=context) - for term in translation_pool.browse(cr, uid, translation_id, context=context): - up_term = up_comment = 0 - if term.job_id: - vals={} - job_response = gengo.getTranslationJob(id=term.job_id) - if job_response['opstat'] != 'ok': - _logger.warning("Invalid Response! Skipping translation Terms with `id` %s." % (term.job_id)) - continue - if job_response['response']['job']['status'] == 'approved': - vals.update({'state': 'translated', - 'value': job_response['response']['job']['body_tgt']}) - up_term += 1 - job_comment = gengo.getTranslationJobComments(id=term.job_id) - if job_comment['opstat']=='ok': - gengo_comments="" - for comment in job_comment['response']['thread']: - gengo_comments += _('%s\n\n--\n Commented on %s by %s.') % (comment['body'], time.ctime(comment['ctime']), comment['author']) - vals.update({'gengo_comment': gengo_comments}) - up_comment += 1 - if vals: - translation_pool.write(cr, uid, term.id, vals) - _logger.info("Successfully Updated `%d` terms and %d Comments." % (up_term, up_comment )) - else: - _logger.warning("%s", 'Cannot retrieve the Gengo job ID for translation %s: %s' % (term.id, term.src)) + translation_id = translation_pool.search(cr, uid, [('state', '=', 'inprogress'), ('gengo_translation', 'in', ('machine','standard','pro','ultra')), ('job_id', "!=",False)], limit=limit, context=context) + translation_terms = translation_pool.browse(cr, uid, translation_id, context=context) + gengo_job_id = [term.job_id for term in translation_terms] + if gengo_job_id: + gengo_ids = ','.join(gengo_job_id) + job_response = gengo.getTranslationJobBatch(id=gengo_ids) + if job_response['opstat'] == 'ok': + job_response_dict = dict([(job['job_id'],job) for job in job_response['response']['jobs']]) + for term in translation_terms: + up_term = up_comment = 0 + vals={} + if job_response_dict[term.job_id]['status'] == 'approved': + vals.update({'state': 'translated', + 'value': job_response_dict[term.job_id]['body_tgt']}) + up_term += 1 + job_comment = gengo.getTranslationJobComments(id=term.job_id) + if job_comment['opstat']=='ok': + gengo_comments="" + for comment in job_comment['response']['thread']: + gengo_comments += _('%s\n-- Commented on %s by %s.\n\n') % (comment['body'], time.ctime(comment['ctime']), comment['author']) + vals.update({'gengo_comment': gengo_comments}) + up_comment += 1 + if vals: + translation_pool.write(cr, uid, term.id, vals) + _logger.info("Successfully Updated `%d` terms and %d Comments." % (up_term, up_comment )) return True def _update_terms(self, cr, uid, response, context=None): @@ -200,7 +181,8 @@ class base_gengo_translations(osv.osv_memory): 'lc_src': 'en', 'lc_tgt': translation_pool._get_gengo_corresponding_language(term.lang), 'auto_approve': auto_approve, - 'comment': user.company_id.gengo_comment, + 'comment': user.company_id.gengo_comment and "%s %s"%(user.company_id.gengo_comment,term.gengo_comment) or term.gengo_comment, + 'callback_url': self.pool.get('ir.config_parameter').get_param(cr, uid,'web.base.url') + '/website/gengo_callback/' + str(term.id) } return {'jobs': jobs} @@ -242,7 +224,7 @@ class base_gengo_translations(osv.osv_memory): lang_ids = [context.get('gengo_language')] langs = [lang.code for lang in language_pool.browse(cr, uid, lang_ids, context=context)] #search for the n first terms to translate - term_ids = translation_pool.search(cr, uid, [('state', '=', 'to_translate'), ('gengo_translation', 'in', ('machine','standard','pro','ultra')), ('lang', 'in', langs)], limit=limit, context=context) + term_ids = translation_pool.search(cr, uid, [('state', '=', 'to_translate'), ('gengo_translation', 'in', ('machine','standard','pro','ultra')), ('lang', 'in', langs),('job_id',"=",False)], limit=limit, context=context) if term_ids: self._send_translation_terms(cr, uid, term_ids, context=context) _logger.info("%s Translation terms have been posted to Gengo successfully", len(term_ids)) diff --git a/addons/base_gengo/wizard/base_gengo_translations_view.xml b/addons/base_gengo/wizard/base_gengo_translations_view.xml index 7b6be31d042..f1d77730c47 100644 --- a/addons/base_gengo/wizard/base_gengo_translations_view.xml +++ b/addons/base_gengo/wizard/base_gengo_translations_view.xml @@ -8,7 +8,14 @@
- + + + + + + + +