ajay javiya (OpenERP) has proposed merging 
lp:~openerp-dev/openobject-addons/trunk-base-gengo-resource-aja into 
lp:~openerp-dev/openobject-addons/trunk-base-gengo.

Requested reviews:
  Jigar Amin  (OpenERP) (jam-openerp)

For more details, see:
https://code.launchpad.net/~openerp-dev/openobject-addons/trunk-base-gengo-resource-aja/+merge/115128

Hello ,
Improve in view for res_company and ir_translation in base_gengo module.
Thank You.
-- 
https://code.launchpad.net/~openerp-dev/openobject-addons/trunk-base-gengo-resource-aja/+merge/115128
Your team OpenERP R&D Team is subscribed to branch 
lp:~openerp-dev/openobject-addons/trunk-base-gengo.
=== modified file 'base_gengo/__init__.py'
--- base_gengo/__init__.py	2012-07-11 05:30:16 +0000
+++ base_gengo/__init__.py	2012-08-23 13:54:38 +0000
@@ -11,7 +11,7 @@
 #
 #    This program is distributed in the hope that it will be useful,
 #    but WITHOUT ANY WARRANTY; without even the implied warranty of
-#    MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
+#    MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.See the
 #    GNU Affero General Public License for more details.
 #
 #    You should have received a copy of the GNU Affero General Public License
@@ -19,4 +19,8 @@
 #
 ##############################################################################
 
+import res_company
+import ir_translation
+import wizard
+import res_lang
 # vim:expandtab:smartindent:tabstop=4:softtabstop=4:shiftwidth=4:

=== modified file 'base_gengo/__openerp__.py'
--- base_gengo/__openerp__.py	2012-07-11 05:30:16 +0000
+++ base_gengo/__openerp__.py	2012-08-23 13:54:38 +0000
@@ -18,7 +18,6 @@
 #    along with this program.  If not, see <http://www.gnu.org/licenses/>.
 #
 ##############################################################################
-
 {
     'name': 'Automated Translations through Gengo API',
     'version': '0.1',
@@ -29,8 +28,14 @@
     'author': 'OpenERP SA',
     'website': 'http://www.openerp.com',
     'depends': ['base'],
-    'init_xml': [],
-    'update_xml': [],
+    'init_xml': ['gengo_sync_schedular_data.xml'],
+    'update_xml': [
+        'ir_translation.xml',
+        'res_company_view.xml',
+        'res_lang_view.xml',
+
+        'wizard/alert_message_gengo.xml',
+           ],
     'demo_xml': [],
     'test': [],
     'installable': True,

=== added file 'base_gengo/gengo_sync_schedular_data.xml'
--- base_gengo/gengo_sync_schedular_data.xml	1970-01-01 00:00:00 +0000
+++ base_gengo/gengo_sync_schedular_data.xml	2012-08-23 13:54:38 +0000
@@ -0,0 +1,26 @@
+<?xml version="1.0" encoding="utf-8"?>
+<openerp>
+    <data>
+        <!--Scheduler sync Receive Request-->
+        <record id="gengo_sync_receive_request_scheduler" model="ir.cron">
+            <field name="name" >Gengo Sync Translation (Response)</field>
+            <field eval="False" name="active"/>
+            <field name="interval_number">30</field>
+            <field name="interval_type">minutes</field>
+            <field name="numbercall">-1</field>
+            <field eval="'base.update.translations'" name="model"></field>
+            <field eval="'_sync_response'" name="function"/>
+        </record>
+
+        <!--Schedular Sync Send Request-->
+        <record id="gengo_sync_send_request_scheduler" model="ir.cron">
+            <field name="name" >Gengo Sync Translation (Request)</field>
+            <field eval="False" name="active"/>
+            <field name="interval_number">30</field>
+            <field name="interval_type">minutes</field>
+            <field name="numbercall">-1</field>
+            <field eval="'base.update.translations'" name="model"></field>
+            <field eval="'_sync_request'" name="function"/>
+        </record>
+    </data>
+</openerp>

=== added file 'base_gengo/ir_translation.py'
--- base_gengo/ir_translation.py	1970-01-01 00:00:00 +0000
+++ base_gengo/ir_translation.py	2012-08-23 13:54:38 +0000
@@ -0,0 +1,37 @@
+# -*- coding: utf-8 -*-
+##############################################################################
+#
+#    OpenERP, Open Source Business Applications
+#    Copyright (C) 2004-2012 OpenERP S.A. (<http://openerp.com>).
+#
+#    This program is free software: you can redistribute it and/or modify
+#    it under the terms of the GNU Affero General Public License as
+#    published by the Free Software Foundation, either version 3 of the
+#    License, or (at your option) any later version.
+#
+#    This program is distributed in the hope that it will be useful,
+#    but WITHOUT ANY WARRANTY; without even the implied warranty of
+#    MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.See the
+#    GNU Affero General Public License for more details.
+#
+#    You should have received a copy of the GNU Affero General Public License
+#    along with this program.  If not, see <http://www.gnu.org/licenses/>.
+#
+##############################################################################
+
+from osv import fields, osv
+
+
+class ir_translation(osv.Model):
+    _name = "ir.translation"
+    _inherit = "ir.translation"
+    _columns = {
+        'gengo_comment': fields.text("Comments"),
+        'gengo_translation': fields.boolean("Translation", help='This term has to be translated by Gengo automatically'),
+        'gengo_control': fields.boolean('Active'),
+        'job_id':fields.char('Gengo Job Id',size=32),
+    }
+
+    _defaults = {
+        'gengo_control': False,
+    }

=== added file 'base_gengo/ir_translation.xml'
--- base_gengo/ir_translation.xml	1970-01-01 00:00:00 +0000
+++ base_gengo/ir_translation.xml	2012-08-23 13:54:38 +0000
@@ -0,0 +1,36 @@
+<?xml version="1.0" encoding="utf-8"?>
+<openerp>
+    <data>
+        <record id="view_translation_search" model="ir.ui.view">
+            <field name="name">Translations</field>
+            <field name="model">ir.translation</field>
+            <field name="inherit_id" ref="base.view_translation_search"/>
+            <field name="type">search</field>
+            <field name="arch" type="xml">
+                <search string="Translations">
+                     <filter icon="terp-project" string="In Progress" domain="[('state','=','inprogress')]"></filter>
+                     <filter string="To Control" domain="[('state','=','translated')]"></filter>
+                </search>
+            </field>
+        </record>
+
+        <!-- ir.translation form view -->
+        <record model="ir.ui.view" id="view_ir_translation_inherit_base_gengo_form">
+            <field name="name">ir.translation.form.inherit</field>
+            <field name="inherit_id" ref="base.view_translation_form"/>
+            <field name="model">ir.translation</field>
+            <field name="type">form</field>
+            <field name="arch" type="xml">
+                 <xpath expr="//form[@string='Translations']/sheet" position="inside">
+                    <group string="comments" col="1">
+                        <field name="gengo_comment" nolabel="1" placeholder="Add Your comments here for Translation Job...."/>
+                    </group>
+                    <group col="4">
+                        <field name="gengo_translation" />
+                        <field name="gengo_control" />
+                    </group>
+                </xpath>
+            </field>
+        </record>
+    </data>
+</openerp>

=== added file 'base_gengo/res_company.py'
--- base_gengo/res_company.py	1970-01-01 00:00:00 +0000
+++ base_gengo/res_company.py	2012-08-23 13:54:38 +0000
@@ -0,0 +1,42 @@
+# -*- coding: utf-8 -*-
+##############################################################################
+#
+#    OpenERP, Open Source Business Applications
+#    Copyright (C) 2004-2012 OpenERP S.A. (<http://openerp.com>).
+#
+#    This program is free software: you can redistribute it and/or modify
+#    it under the terms of the GNU Affero General Public License as
+#    published by the Free Software Foundation, either version 3 of the
+#    License, or (at your option) any later version.
+#
+#    This program is distributed in the hope that it will be useful,
+#    but WITHOUT ANY WARRANTY; without even the implied warranty of
+#    MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
+#    GNU Affero General Public License for more details.
+#
+#    You should have received a copy of the GNU Affero General Public License
+#    along with this program.  If not, see <http://www.gnu.org/licenses/>.
+#
+##############################################################################
+
+from osv import fields, osv
+
+
+class res_company(osv.Model):
+    _name = "res.company"
+    _inherit = "res.company"
+    _columns = {
+           "gengo_private_key": fields.text("Gengo private key"),
+           "gengo_public_key": fields.text("Gengo public key"),
+           "gengo_tier": fields.selection([('machine', 'Machine'),
+                                          ('standard', 'Standard'),
+                                          ('pro', 'Pro'),
+                                          ('ultra', 'Ultra')], "Tier types", required=True),
+           "gengo_comment": fields.text("comments"),
+           "gengo_auto_approve": fields.boolean("Active", help="Jobs are Automatically Approved by Gengo."),
+           "fields_ids": fields.many2many('ir.model.fields', 'fields_company_rel', 'field_id', 'model_id', 'fields'),
+    }
+
+    _defaults = {
+        "gengo_tier": "machine",
+    }

=== added file 'base_gengo/res_company_view.xml'
--- base_gengo/res_company_view.xml	1970-01-01 00:00:00 +0000
+++ base_gengo/res_company_view.xml	2012-08-23 13:54:38 +0000
@@ -0,0 +1,37 @@
+<?xml version="1.0" encoding="UTF-8"?>
+<openerp>
+    <data>
+        <!-- res.company form view -->
+        <record model="ir.ui.view" id="view_company_inherit_base_gengo_form">
+            <field name="name">res.company.form.inherit</field>
+            <field name="inherit_id" ref="base.view_company_form"/>
+            <field name="model">res.company</field>
+            <field name="type">form</field>
+            <field name="arch" type="xml">
+                <xpath expr="//notebook[last()]" position="inside">
+                    <page string="Gengo Parameters">
+                        <group col="2">
+                            <group col="1" string="Private Key">
+                                <field name="gengo_private_key" nolabel="1"/>
+                            </group>
+                            <group col="1" string="Public Key">
+                                <field name="gengo_public_key" nolabel="1"/>
+                            </group>
+                        </group>
+                        <group col="4">
+                            <field name="gengo_tier" />
+                            <field name="gengo_auto_approve"/>
+                        </group>
+                        <group string="Comments" col="1">
+                            <field name="gengo_comment" nolabel="1" placeholder="Add Your comments here for Translator...."/>
+                        </group>
+                        <group col="1">
+                            <field name="fields_ids" nolabel="1"/>
+                        </group>
+                    </page>
+                </xpath>
+            </field>
+        </record>
+
+    </data>
+</openerp>

=== added file 'base_gengo/res_lang.py'
--- base_gengo/res_lang.py	1970-01-01 00:00:00 +0000
+++ base_gengo/res_lang.py	2012-08-23 13:54:38 +0000
@@ -0,0 +1,31 @@
+# -*- coding: utf-8 -*-
+##############################################################################
+#
+#    OpenERP, Open Source Business Applications
+#    Copyright (C) 2004-2012 OpenERP S.A. (<http://openerp.com>).
+#
+#    This program is free software: you can redistribute it and/or modify
+#    it under the terms of the GNU Affero General Public License as
+#    published by the Free Software Foundation, either version 3 of the
+#    License, or (at your option) any later version.
+#
+#    This program is distributed in the hope that it will be useful,
+#    but WITHOUT ANY WARRANTY; without even the implied warranty of
+#    MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
+#    GNU Affero General Public License for more details.
+#
+#    You should have received a copy of the GNU Affero General Public License
+#    along with this program.  If not, see <http://www.gnu.org/licenses/>.
+#
+##############################################################################
+
+from osv import fields, osv
+
+
+class res_company(osv.Model):
+    _name = "res.lang"
+    _inherit = "res.lang"
+
+    _columns = {
+        'gengo_sync': fields.boolean('Active', help='Synchronize Translation Periodically')
+    }

=== added file 'base_gengo/res_lang_view.xml'
--- base_gengo/res_lang_view.xml	1970-01-01 00:00:00 +0000
+++ base_gengo/res_lang_view.xml	2012-08-23 13:54:38 +0000
@@ -0,0 +1,17 @@
+<?xml version="1.0" encoding="UTF-8"?>
+<openerp>
+    <data>
+        <!-- res.company form view -->
+        <record model="ir.ui.view" id="view_language_inherit_base_gengo_form">
+            <field name="name">res.lang.form.inherit</field>
+            <field name="inherit_id" ref="base.res_lang_form"/>
+            <field name="model">res.lang</field>
+            <field name="type">form</field>
+            <field name="arch" type="xml">
+                <xpath expr="//sheet/group" position="inside">
+                    <field name="gengo_sync" />
+                </xpath>
+            </field>
+        </record>
+    </data>
+</openerp>

=== added directory 'base_gengo/wizard'
=== added file 'base_gengo/wizard/__init__.py'
--- base_gengo/wizard/__init__.py	1970-01-01 00:00:00 +0000
+++ base_gengo/wizard/__init__.py	2012-08-23 13:54:38 +0000
@@ -0,0 +1,25 @@
+# -*- coding: utf-8 -*-
+##############################################################################
+#
+#    OpenERP, Open Source Management Solution
+#    Copyright (C) 2004-2010 Tiny SPRL (<http://tiny.be>).
+#
+#    This program is free software: you can redistribute it and/or modify
+#    it under the terms of the GNU Affero General Public License as
+#    published by the Free Software Foundation, either version 3 of the
+#    License, or (at your option) any later version.
+#
+#    This program is distributed in the hope that it will be useful,
+#    but WITHOUT ANY WARRANTY; without even the implied warranty of
+#    MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
+#    GNU Affero General Public License for more details.
+#
+#    You should have received a copy of the GNU Affero General Public License
+#    along with this program.  If not, see <http://www.gnu.org/licenses/>.
+#
+##############################################################################
+
+import gengo_update_translation
+import wrap_object
+import gengo_update_message
+# vim:expandtab:smartindent:tabstop=4:softtabstop=4:shiftwidth=4:

=== added file 'base_gengo/wizard/alert_message_gengo.xml'
--- base_gengo/wizard/alert_message_gengo.xml	1970-01-01 00:00:00 +0000
+++ base_gengo/wizard/alert_message_gengo.xml	2012-08-23 13:54:38 +0000
@@ -0,0 +1,18 @@
+<?xml version="1.0" encoding="utf-8"?>
+<openerp>
+    <data>
+        <!-- Update Message Form View -->
+        <record model="ir.ui.view" id="update_translation_wizard_view_confirm">
+            <field name="name">gengo.update.message.form</field>
+            <field name="model">gengo.update.message</field>
+            <field name="type">form</field>
+            <field name="arch" type="xml">
+                <form string="Update Gengo Data" version="7.0">
+                    <group>
+                        <field name='name'/>
+                    </group>
+                </form>
+            </field>
+        </record>
+    </data>
+</openerp>

=== added file 'base_gengo/wizard/gengo_update_message.py'
--- base_gengo/wizard/gengo_update_message.py	1970-01-01 00:00:00 +0000
+++ base_gengo/wizard/gengo_update_message.py	2012-08-23 13:54:38 +0000
@@ -0,0 +1,44 @@
+# -*- coding: utf-8 -*-
+##############################################################################
+#
+#    OpenERP, Open Source Management Solution
+#    Copyright (C) 2004-2010 Tiny SPRL (<http://tiny.be>).
+#
+#    This program is free software: you can redistribute it and/or modify
+#    it under the terms of the GNU Affero General Public License as
+#    published by the Free Software Foundation, either version 3 of the
+#    License, or (at your option) any later version.
+#
+#    This program is distributed in the hope that it will be useful,
+#    but WITHOUT ANY WARRANTY; without even the implied warranty of
+#    MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
+#    GNU Affero General Public License for more details.
+#
+#    You should have received a copy of the GNU Affero General Public License
+#    along with this program.  If not, see <http://www.gnu.org/licenses/>.
+#
+##############################################################################
+
+from osv import osv
+from osv import fields
+
+
+class gengo_update_message(osv.osv):
+    """Update Message"""
+
+    _name = "gengo.update.message"
+    _description = "Update Message"
+    _columns = {
+        'name': fields.text('Message', readonly=True),
+        }
+
+    def default_get(self, cr, uid, fields, context=None):
+        if context == None:
+            context = {}
+        res = super(gengo_update_message, self).default_get(cr, uid, fields, context=context)
+        res.update({'name': context.get('message')})
+        return res
+
+gengo_update_message()
+
+# vim:expandtab:smartindent:tabstop=4:softtabstop=4:shiftwidth=4:

=== added file 'base_gengo/wizard/gengo_update_translation.py'
--- base_gengo/wizard/gengo_update_translation.py	1970-01-01 00:00:00 +0000
+++ base_gengo/wizard/gengo_update_translation.py	2012-08-23 13:54:38 +0000
@@ -0,0 +1,123 @@
+# -*- coding: utf-8 -*-
+##############################################################################
+#
+#    OpenERP, Open Source Business Applications
+#    Copyright (C) 2004-2012 OpenERP S.A. (<http://openerp.com>).
+#
+#    This program is free software: you can redistribute it and/or modify
+#    it under the terms of the GNU Affero General Public License as
+#    published by the Free Software Foundation, either version 3 of the
+#    License, or (at your option) any later version.
+#
+#    This program is distributed in the hope that it will be useful,
+#    but WITHOUT ANY WARRANTY; without even the implied warranty of
+#    MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.See the
+#    GNU Affero General Public License for more details.
+#
+#    You should have received a copy of the GNU Affero General Public License
+#    along with this program.  If not, see <http://www.gnu.org/licenses/>.
+#
+##############################################################################
+
+from osv import osv
+import wrap_object as local
+import logging
+_logger = logging.getLogger(__name__)
+
+cron_vals = {
+'name': 'Gengo Sync',
+'active': True,
+'interval_number': 30,
+'interval_type': 'minutes',
+'numbercall': -1,
+'model': "'base.update.translations'",
+'function': ""
+}
+
+
+class base_update_translation(osv.osv_memory):
+    def _update_terms(self, cr, uid, ids, response, tier, context):
+        translation_pool = self.pool.get('ir.translation')
+        for jobs in response['jobs']:
+            vals = {}
+            for t_id, res in jobs.items():
+                if tier == "machine":
+                    vals.update({'value': res['body_tgt'], 'state': 'translated'})
+                else:
+                    vals.update({'job_id': res['job_id'], 'state': 'inprogress'})
+                translation_pool.write(cr, uid, [t_id], vals, context)
+        return
+
+
+    def _send_translation_terms(self, cr, uid, ids, trg_lang, term_ids, context):
+        """
+        Lazy Polling will be perform when user or cron request for the trnalstion.
+        """
+        meta = self.pool.get('jobs.meta')
+        user = self.pool.get('res.users').browse(cr, uid, uid, context)
+        gengo = meta.gengo_authentication(cr, uid, ids, context)
+        request = meta.pack_jobs_request(cr, uid, term_ids, trg_lang, context)
+        result = gengo.postTranslationJobs(jobs=request)
+        if result['opstat'] == 'ok':
+            self._update_terms(cr, uid, ids, result['response'], user.company_id.gengo_tier, context)
+        return True
+
+    def do_check_schedular(self, cr, uid, xml_id, name, fn, context=None):
+        cron_pool = self.pool.get('ir.cron')
+        try:
+            res = self.pool.get('ir.model.data')._get_id(cr, uid, 'base_gengo', xml_id)
+            cron_pool.write(cr, uid, [res], {'active': True}, context)
+        except:
+            cron_vals.update({'name': name, "function": fn})
+            return cron_pool.create(cr, uid, cron_vals, context)
+
+    def act_update(self, cr, uid, ids, context=None):
+        if context == None:
+            context = {}
+        lang_pool = self.pool.get('res.lang')
+        for res in self.browse(cr, uid, ids, context):
+            lang_id = lang_pool.search(cr, uid, [('code', '=', res.lang)])
+            lang_pool.write(cr, uid, lang_id, {'gengo_sync': True})
+        res = super(base_update_translation, self).act_update(cr, uid, ids, context)
+        self.do_check_schedular(cr, uid, 'gengo_sync_send_request_scheduler', 'gengo_sync_send_request_scheduler', '_sync_request', context)
+        self.do_check_schedular(cr, uid, 'gengo_sync_receive_request_scheduler', 'gengo_sync_send_request_scheduler', '_sync_response', context)
+        return {}
+
+    def _sync_response(self, cr, uid, ids=0, context=None):
+        """Scheduler will be call to get response from gengo and all term will get
+        by scheduler which terms are in approved state"""
+        meta = self.pool.get('jobs.meta')
+        translation_pool = self.pool.get('ir.translation')
+        gengo = meta.gengo_authentication(cr, uid, ids, context)
+        translation_id = translation_pool.search(cr, uid, [('job_id', '!=', False), ('state', '=', 'inprogress'), ('gengo_translation', '=', True)], limit=local.LIMIT, context=context)
+        for trns in translation_pool.browse(cr, uid, translation_id, context):
+            job_response = gengo.getTranslationJob(id=trns.job_id)
+            if job_response['response']['job']['status'] == 'approved':
+                translation_pool.write(cr, uid, translation_id, {'value': job_response['response']['job']['body_tgt'], 'state': 'translated', 'gengo_control': True})
+        return True
+
+    def _sync_request(self, cr, uid, ids=0, context=None):
+        """This scheduler will send a job request to the gengo , which terms are
+        in translate state and gengo_translation is true"""
+        if context is None:
+            context = {}
+        try:
+            language_pool = self.pool.get('res.lang')
+            trg_lang = self.browse(cr, uid, ids)[0]
+            translation_pool = self.pool.get('ir.translation')
+            lang_search_id = language_pool.search(cr, uid, [('gengo_sync', '=', True), ('code', '=', trg_lang.lang)])
+            if not lang_search_id:
+                term_ids = translation_pool.search(cr, uid, [('state', '=', 'inprogress'), ('gengo_translation', '=', 'True'), ('lang', '=', trg_lang.lang)], limit=local.LIMIT)
+                self._send_translation_terms(cr, uid, ids, trg_lang.lang, term_ids, context)
+                msg = "Your Request has been Successfully Send to Gengo"
+            else:
+                msg = "This language is select as Active All Translation Request will be sent by System Automatically"
+            context.update({'message': msg})
+        except Exception, e:
+            _logger.warning("%s", e)
+
+    _name = 'base.update.translations'
+    _inherit = "base.update.translations"
+
+base_update_translation()
+# vim:expandtab:smartindent:tabstop=4:softtabstop=4:shiftwidth=4:

=== added file 'base_gengo/wizard/wrap_object.py'
--- base_gengo/wizard/wrap_object.py	1970-01-01 00:00:00 +0000
+++ base_gengo/wizard/wrap_object.py	2012-08-23 13:54:38 +0000
@@ -0,0 +1,148 @@
+# -*- coding: utf-8 -*-
+##############################################################################
+#
+#    OpenERP, Open Source Business Applications
+#    Copyright (C) 2004-2012 OpenERP S.A. (<http://openerp.com>).
+#
+#    This program is free software: you can redistribute it and/or modify
+#    it under the terms of the GNU Affero General Public License as
+#    published by the Free Software Foundation, either version 3 of the
+#    License, or (at your option) any later version.
+#
+#    This program is distributed in the hope that it will be useful,
+#    but WITHOUT ANY WARRANTY; without even the implied warranty of
+#    MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.See the
+#    GNU Affero General Public License for more details.
+#
+#    You should have received a copy of the GNU Affero General Public License
+#    along with this program.  If not, see <http://www.gnu.org/licenses/>.
+#
+##############################################################################
+
+from osv import orm, osv
+from tools.translate import _
+from mygengo import MyGengo
+import re
+
+LIMIT = 20
+
+LANG_MAPPING = {
+    'ar': 'Arabic',
+    'id': 'Indonesian',
+    'nl': 'Dutch',
+    'fr-ca': 'French (Canada)',
+    'pl': 'Polish',
+    'zh-tw': 'Chinese (Traditional)',
+    'sv': 'Swedish',
+    'ko': 'Korean',
+    'pt': 'Portuguese (Europe)',
+    'en': 'English',
+    'ja': 'Japanese',
+    'es': 'Spanish (Spain)',
+    'zh': 'Chinese (Simplified)',
+    'de': 'German',
+    'fr': 'French',
+    'ru': 'Russian',
+    'it': 'Italian',
+    'pt-br': 'Portuguese (Brazil)',
+}
+
+LANG_CODE_MAPPING = {
+    'ar_SA': 'ar',
+    'id_ID': 'id',
+    'nl_NL': 'nl',
+    'fr_CA': 'fr-ca',
+    'pl': 'pl',
+    'zh_TW': 'zh-tw',
+    'sv_SE': 'sv',
+    'ko_KR': 'ko',
+    'pt_PT': 'pt',
+    'en': 'en',
+    'ja_JP': 'ja',
+    'es_ES': 'es',
+    'zh_CN': 'zh',
+    'de_DE': 'de',
+    'fr_FR': 'fr',
+    'ru_RU': 'ru',
+    'it_IT': 'it',
+    'pt_BR': 'pt-br'
+}
+
+
+class gengo_response(object):
+    """
+    """
+    def __init__(self, jobs):
+        self._data = jobs
+
+    def __getitem__(self, name):
+        return self._data[name]
+
+    def __getattr__(self, name):
+        try:
+            return self[name]
+        except KeyError, e:
+            raise AttributeError(e)
+
+
+class gengo_job(object):
+    """
+    """
+    def __init__(self, job):
+        self._data = job
+
+    def __getitem__(self, name):
+        return self._data[name]
+
+    def __getattr__(self, name):
+        try:
+            return self[name]
+        except KeyError, e:
+            raise AttributeError(e)
+
+
+class JobsMeta(orm.AbstractModel):
+
+    _name = "jobs.meta"
+
+    def gengo_authentication(self, cr, uid, ids, context=None):
+        ''' To Send Request and Get Response from Gengo User needs Public and Private
+         key for that user need to signup to gengo and get public and private
+         key which is provided by gengo to authentic user '''
+
+        gengo_parameter_pool = self.pool.get('res.users').browse(cr, uid, uid, context)
+        try:
+            gengo = MyGengo(
+                public_key=gengo_parameter_pool.company_id.gengo_public_key.encode('ascii'),
+                private_key=gengo_parameter_pool.company_id.gengo_private_key.encode('ascii'),
+                sandbox=True,
+            )   
+            return gengo
+        except Exception, e:
+            raise osv.except_osv(_('Warning !'), _(e))
+
+    def pack_jobs_request(self, cr, uid, term_ids, trg_lang, context):
+        jobs = {}
+        auto_approve = 0
+        gengo_parameter_pool = self.pool.get('res.users').browse(cr, uid, uid, context)
+        translation_pool = self.pool.get('ir.translation')
+        if gengo_parameter_pool.company_id.gengo_auto_approve:
+            auto_approve = 1
+        g_lang = LANG_CODE_MAPPING.get(trg_lang)
+        if g_lang:
+            for terms in translation_pool.browse(cr, uid, term_ids, context):
+                #NOTE: Discard none string and only special char string 
+                if re.search(r"[a-z A-Z]", terms.src) and terms.src:
+                    job = {'type': 'text',
+                            'slug': 'single::English to' + LANG_MAPPING.get(g_lang),
+                            'tier': gengo_parameter_pool.company_id.gengo_tier,
+                            'body_src': terms.src,
+                            'lc_src': 'en',
+                            'lc_tgt': g_lang,
+                            'auto_approve': auto_approve,
+                            'comment': gengo_parameter_pool.company_id.gengo_comment,
+                            }
+                    jobs.update({terms.id: job})
+        return {'jobs': jobs}
+
+# vim:expandtab:smartindent:tabstop=4:softtabstop=4:shiftwidth=4:

_______________________________________________
Mailing list: https://launchpad.net/~openerp-dev-gtk
Post to     : [email protected]
Unsubscribe : https://launchpad.net/~openerp-dev-gtk
More help   : https://help.launchpad.net/ListHelp

Reply via email to