ajay javiya (OpenERP) has proposed merging
lp:~openerp-dev/openobject-addons/trunk-base-gengo-comment-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-comment-aja/+merge/121399
Hello,
Get comment for translation from gengo API and add to the openerp.
Thank you
--
https://code.launchpad.net/~openerp-dev/openobject-addons/trunk-base-gengo-comment-aja/+merge/121399
Your team OpenERP R&D Team is subscribed to branch
lp:~openerp-dev/openobject-addons/trunk-base-gengo.
=== modified file 'base_gengo/wizard/gengo_update_translation.py'
--- base_gengo/wizard/gengo_update_translation.py 2012-08-27 09:41:37 +0000
+++ base_gengo/wizard/gengo_update_translation.py 2012-08-27 10:59:21 +0000
@@ -28,6 +28,7 @@
import logging
import tools
+import time
from tools.translate import _
_logger = logging.getLogger(__name__)
@@ -91,6 +92,9 @@
class base_update_translation(osv.osv_memory):
+ _name = 'base.update.translations'
+ _inherit = "base.update.translations"
+
def gengo_authentication(self, cr, uid, 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
@@ -227,19 +231,36 @@
}
def _sync_response(self, cr, uid, ids=False, context=None):
- """Scheduler will be call to get response from gengo and all term will get
- by scheduler which terms are in approved state"""
+ """
+ This method will be call by cron services to get translation from
+ gengo for translation terms which are posted to be translated. It will
+ read translated terms and comments from gengo and will update respective
+ translation in openerp """
translation_pool = self.pool.get('ir.translation')
flag, gengo = self.gengo_authentication(cr, uid, context)
if not flag:
_logger.warning("%s", gengo)
else:
translation_id = translation_pool.search(cr, uid, [('state', '=', 'inprogress'), ('gengo_translation', '=', True)], limit=LIMIT, context=context)
- for trns in translation_pool.browse(cr, uid, translation_id, context):
- if trns.job_id:
- job_response = gengo.getTranslationJob(id=trns.job_id)
+ for term in translation_pool.browse(cr, uid, translation_id, context):
+ if term.job_id:
+ vals={}
+ job_response = gengo.getTranslationJob(id=term.job_id)
+ if job_response['opstat'] != 'ok':
+ _logger.warning("Invalid Response Skeeping translation Terms for 'id' %s."%(term.job_id))
+ continue
if job_response['response']['job']['status'] == 'approved':
- translation_pool.write(cr, uid, trns.id, {'value': job_response['response']['job']['body_tgt'], 'state': 'translated', 'gengo_control': True})
+ vals.update({'state': 'translated',
+ 'value': job_response['response']['job']['body_tgt'],
+ 'gengo_control': True})
+ 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 by %s at %s. \n' %(comment['body'],comment['author'],time.ctime(comment['ctime']))
+ vals.update({'gengo_comment':gengo_comments})
+ if vals:
+ translation_pool.write(cr, uid, term.id,vals)
return True
def _sync_request(self, cr, uid, ids=False, context=None):
@@ -262,8 +283,4 @@
except Exception, e:
_logger.error("%s", e)
- _name = 'base.update.translations'
- _inherit = "base.update.translations"
-
-base_update_translation()
# 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