[IMP] merged gengo translator with main translator, removed 'Restart Job' from wizard,removed constraint from base_gengo
bzr revid: pga@tinyerp.com-20140324103631-j4cswrlk5huuibt5
This commit is contained in:
parent
2cf5e1a490
commit
bf0d35dbdd
|
@ -71,18 +71,3 @@ class ir_translation(osv.Model):
|
||||||
|
|
||||||
def _get_gengo_corresponding_language(cr, lang):
|
def _get_gengo_corresponding_language(cr, lang):
|
||||||
return lang in LANG_CODE_MAPPING and LANG_CODE_MAPPING[lang][0] or 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 and term.name != 'website':
|
|
||||||
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'])
|
|
||||||
]
|
|
||||||
|
|
|
@ -52,7 +52,6 @@ class base_gengo_translations(osv.osv_memory):
|
||||||
|
|
||||||
_name = 'base.gengo.translations'
|
_name = 'base.gengo.translations'
|
||||||
_columns = {
|
_columns = {
|
||||||
'restart_send_job': fields.boolean("Restart Sending Job"),
|
|
||||||
'sync_type': fields.selection([('send', 'Send New Terms'),
|
'sync_type': fields.selection([('send', 'Send New Terms'),
|
||||||
('receive', 'Receive Translation'),
|
('receive', 'Receive Translation'),
|
||||||
('both', 'Both')], "Sync Type"),
|
('both', 'Both')], "Sync Type"),
|
||||||
|
@ -125,9 +124,6 @@ class base_gengo_translations(osv.osv_memory):
|
||||||
if wizard.sync_type in ['receive','both']:
|
if wizard.sync_type in ['receive','both']:
|
||||||
self._sync_response( 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
|
#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)
|
|
||||||
return {'type': 'ir.actions.act_window_close'}
|
return {'type': 'ir.actions.act_window_close'}
|
||||||
|
|
||||||
def _sync_response(self, cr, uid, limit=GENGO_DEFAULT_LIMIT, context=None):
|
def _sync_response(self, cr, uid, limit=GENGO_DEFAULT_LIMIT, context=None):
|
||||||
|
|
|
@ -10,12 +10,7 @@
|
||||||
<field name="lang_id"/>
|
<field name="lang_id"/>
|
||||||
</group>
|
</group>
|
||||||
<group>
|
<group>
|
||||||
<group>
|
|
||||||
<field name="sync_type" widget="radio"/>
|
<field name="sync_type" widget="radio"/>
|
||||||
</group>
|
|
||||||
<group>
|
|
||||||
<field name="restart_send_job"/>
|
|
||||||
</group>
|
|
||||||
</group>
|
</group>
|
||||||
<footer>
|
<footer>
|
||||||
<button name="act_update" string="Send" type="object" class="oe_highlight"/>
|
<button name="act_update" string="Send" type="object" class="oe_highlight"/>
|
||||||
|
|
|
@ -145,10 +145,6 @@ table.editorbar-panel td.selected {
|
||||||
background: #ffffb6;
|
background: #ffffb6;
|
||||||
}
|
}
|
||||||
|
|
||||||
.oe_translatable_inprogress {
|
|
||||||
background: #b7e4ff;
|
|
||||||
}
|
|
||||||
|
|
||||||
/* ---- MENU ---- {{{ */
|
/* ---- MENU ---- {{{ */
|
||||||
div.oe_menu_buttons {
|
div.oe_menu_buttons {
|
||||||
top: -8px;
|
top: -8px;
|
||||||
|
|
|
@ -115,8 +115,6 @@ table.editorbar-panel
|
||||||
padding: 0 10px
|
padding: 0 10px
|
||||||
.oe_translatable_todo
|
.oe_translatable_todo
|
||||||
background: rgb(255, 255, 182)
|
background: rgb(255, 255, 182)
|
||||||
.oe_translatable_todo
|
|
||||||
background: rgb(183, 228, 255)
|
|
||||||
|
|
||||||
// }}}
|
// }}}
|
||||||
|
|
||||||
|
|
|
@ -34,11 +34,17 @@
|
||||||
dialog.$el.modal('hide');
|
dialog.$el.modal('hide');
|
||||||
self.translate().then(function () {
|
self.translate().then(function () {
|
||||||
mysuper.call(self);
|
mysuper.call(self);
|
||||||
|
if(self.gengo_translate){
|
||||||
|
self.translation_gengo_display()
|
||||||
|
}
|
||||||
});
|
});
|
||||||
});
|
});
|
||||||
} else {
|
} else {
|
||||||
this.translate().then(function () {
|
this.translate().then(function () {
|
||||||
mysuper.call(self);
|
mysuper.call(self);
|
||||||
|
if(self.gengo_translate){
|
||||||
|
self.translation_gengo_display()
|
||||||
|
}
|
||||||
});
|
});
|
||||||
}
|
}
|
||||||
},
|
},
|
||||||
|
@ -90,7 +96,7 @@
|
||||||
self.sanitizeNode($node[0]);
|
self.sanitizeNode($node[0]);
|
||||||
}
|
}
|
||||||
if (self.getInitialContent($node[0]) !== $node.text()) {
|
if (self.getInitialContent($node[0]) !== $node.text()) {
|
||||||
$node.addClass('oe_dirty').removeClass('oe_translatable_todo');
|
$node.addClass('oe_dirty').removeClass('oe_translatable_todo oe_translatable_inprogress');
|
||||||
}
|
}
|
||||||
}, 0);
|
}, 0);
|
||||||
});
|
});
|
||||||
|
@ -118,19 +124,12 @@
|
||||||
if (trans.length) {
|
if (trans.length) {
|
||||||
node.setAttribute('data-oe-translation-id', trans[0].id);
|
node.setAttribute('data-oe-translation-id', trans[0].id);
|
||||||
if(trans[0].gengo_translation && (trans[0].state == 'inprogress' || trans[0].state == 'to_translate')){
|
if(trans[0].gengo_translation && (trans[0].state == 'inprogress' || trans[0].state == 'to_translate')){
|
||||||
if(this.gengo_translate){
|
|
||||||
node.className += ' oe_translatable_inprogress';
|
node.className += ' oe_translatable_inprogress';
|
||||||
}
|
|
||||||
else{
|
|
||||||
node.className += ' oe_translatable_todo';
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
} else {
|
} else {
|
||||||
node.className += ' oe_translatable_todo';
|
node.className += ' oe_translatable_todo';
|
||||||
}
|
}
|
||||||
if(!this.gengo_translate){
|
node.contentEditable = true;
|
||||||
node.contentEditable = true;
|
|
||||||
}
|
|
||||||
var nid = _.uniqueId();
|
var nid = _.uniqueId();
|
||||||
$(node).attr('data-oe-nodeid', nid);
|
$(node).attr('data-oe-nodeid', nid);
|
||||||
this.initial_content[nid] = content;
|
this.initial_content[nid] = content;
|
||||||
|
|
|
@ -4,16 +4,11 @@ from openerp.addons.web import http
|
||||||
from openerp.addons.web.http import request
|
from openerp.addons.web.http import request
|
||||||
class website_gengo(http.Controller):
|
class website_gengo(http.Controller):
|
||||||
|
|
||||||
@http.route('/website/get_gengo_info', type='json', auth='user', website=True)
|
@http.route('/website/get_translated_length', type='json', auth='user', website=True)
|
||||||
def get_gengo_info(self, view_id, lang):
|
def get_translated_length(self, translated_ids, lang):
|
||||||
ir_translation_obj = request.registry['ir.translation']
|
ir_translation_obj = request.registry['ir.translation']
|
||||||
res_lang_obj = request.registry['res.lang']
|
result={"done":0}
|
||||||
translation_ids = ir_translation_obj.search(request.cr, request.uid, [('res_id','=',view_id),('gengo_translation','!=', False),('lang','=',lang)])
|
gengo_translation_ids = ir_translation_obj.search(request.cr, request.uid, [('id','in',translated_ids),('gengo_translation','!=', False)])
|
||||||
result={"total":0,"inprogess":0,"done":0}
|
for trans in ir_translation_obj.browse(request.cr, request.uid, gengo_translation_ids):
|
||||||
for trans in ir_translation_obj.browse(request.cr, request.uid, translation_ids):
|
result['done'] += len(trans.source.split())
|
||||||
result['total'] += len(trans.source.split())
|
|
||||||
if trans.state == 'translated':
|
|
||||||
result['done'] += len(trans.source.split())
|
|
||||||
elif trans.state in ['inprogress','to_translate']:
|
|
||||||
result['inprogess'] += len(trans.source.split())
|
|
||||||
return result
|
return result
|
||||||
|
|
|
@ -0,0 +1,3 @@
|
||||||
|
.oe_translatable_inprogress {
|
||||||
|
background: #b7e4ff;
|
||||||
|
}
|
|
@ -6,53 +6,25 @@
|
||||||
|
|
||||||
website.EditorBar.include({
|
website.EditorBar.include({
|
||||||
events: _.extend({}, website.EditorBar.prototype.events, {
|
events: _.extend({}, website.EditorBar.prototype.events, {
|
||||||
'click a[data-action=translation_gengo]': 'translation_gengo',
|
|
||||||
'click a[data-action=translation_gengo_post]': 'translation_gengo_post',
|
'click a[data-action=translation_gengo_post]': 'translation_gengo_post',
|
||||||
'click a[data-action=translation_gengo_info]': 'translation_gengo_info',
|
'click a[data-action=translation_gengo_info]': 'translation_gengo_info',
|
||||||
'click a[data-action=reload]': 'reload',
|
|
||||||
}),
|
}),
|
||||||
start: function () {
|
edit:function () {
|
||||||
this.gengo_translate = false;
|
this.gengo_translate = true;
|
||||||
this._super.apply(this, arguments);
|
this._super.apply(this, arguments);
|
||||||
var self = this;
|
var self = this;
|
||||||
var gengo_langs = ["ar_SA","id_ID","nl_NL","fr_CA","pl_PL","zh_TW","sv_SE","ko_KR","pt_PT","en_US","ja_JP","es_ES","zh_CN","de_DE","fr_FR","fr_BE","ru_RU","it_IT","pt_BR"];
|
var gengo_langs = ["ar_SA","id_ID","nl_NL","fr_CA","pl_PL","zh_TW","sv_SE","ko_KR","pt_PT","en_US","ja_JP","es_ES","zh_CN","de_DE","fr_FR","fr_BE","ru_RU","it_IT","pt_BR"];
|
||||||
if (gengo_langs.indexOf(website.get_context()['lang']) != -1)
|
if (gengo_langs.indexOf(website.get_context()['lang']) != -1){
|
||||||
{
|
self.$('button[data-action=save]')
|
||||||
self.$('button[data-action=edit]')
|
.after(openerp.qweb.render('website.ButtonGengoTranslator'));
|
||||||
.after(openerp.qweb.render('website.ButtonGengoTranslator'));
|
|
||||||
|
|
||||||
}
|
|
||||||
},
|
|
||||||
translation_gengo: function () {
|
|
||||||
var self = this;
|
|
||||||
if(!localStorage['website_gengo_nodialog']){
|
|
||||||
var dialog = new website.GengoTranslatorDialog();
|
|
||||||
dialog.appendTo($(document.body));
|
|
||||||
self.gengo_translate = true;
|
|
||||||
dialog.on('activate', this, function () {
|
|
||||||
localStorage['website_gengo_nodialog'] = dialog.$('input[name=do_not_show]').prop('checked') || '';
|
|
||||||
dialog.$el.modal('hide');
|
|
||||||
self.translation_gengo_display()
|
|
||||||
});
|
|
||||||
}
|
|
||||||
else{
|
|
||||||
self.gengo_translate = true;
|
|
||||||
self.translation_gengo_display()
|
|
||||||
}
|
}
|
||||||
},
|
},
|
||||||
translation_gengo_display:function(){
|
translation_gengo_display:function(){
|
||||||
var self = this;
|
var self = this;
|
||||||
self.translate().then(function () {
|
if($('.oe_translatable_todo').length == 0){
|
||||||
self.gengo_translate = false;
|
self.$el.find('.gengo_post').addClass("hidden");
|
||||||
if($('.oe_translatable_todo').length > 0){
|
self.$el.find('.gengo_inprogress').removeClass("hidden");
|
||||||
self.$el.find('form.navbar-form.navbar-left > *').addClass("hidden");
|
}
|
||||||
self.$el.find('.gengo_post,.gengo_info,.gengo_discard').removeClass("hidden");
|
|
||||||
}
|
|
||||||
else{
|
|
||||||
self.$el.find('form.navbar-form.navbar-left > *').addClass("hidden");
|
|
||||||
self.$el.find('.gengo_inprogress,.gengo_info,.gengo_discard').removeClass("hidden");
|
|
||||||
}
|
|
||||||
});
|
|
||||||
},
|
},
|
||||||
translation_gengo_post: function () {
|
translation_gengo_post: function () {
|
||||||
var self = this;
|
var self = this;
|
||||||
|
@ -62,7 +34,7 @@
|
||||||
dialog.on('service_level', this, function () {
|
dialog.on('service_level', this, function () {
|
||||||
var gengo_service_level = dialog.$el.find(".form-control").val();
|
var gengo_service_level = dialog.$el.find(".form-control").val();
|
||||||
dialog.$el.modal('hide');
|
dialog.$el.modal('hide');
|
||||||
self.$el.find('.gengo_post,.gengo_discard').addClass("hidden");
|
self.$el.find('.gengo_post').addClass("hidden");
|
||||||
self.$el.find('.gengo_wait').removeClass("hidden");
|
self.$el.find('.gengo_wait').removeClass("hidden");
|
||||||
var trans ={}
|
var trans ={}
|
||||||
$('.oe_translatable_todo').each(function () {
|
$('.oe_translatable_todo').each(function () {
|
||||||
|
@ -92,10 +64,14 @@
|
||||||
|
|
||||||
},
|
},
|
||||||
translation_gengo_info: function () {
|
translation_gengo_info: function () {
|
||||||
var repr = $(document.documentElement).data('mainObject')
|
var repr = $(document.documentElement).data('mainObject');
|
||||||
var view_id = repr.match(/.+\((.+), (\d+)\)/)[2];
|
var view_id = repr.match(/.+\((.+), (\d+)\)/)[2];
|
||||||
openerp.jsonRpc('/website/get_gengo_info', 'call', {
|
var translated_ids = [];
|
||||||
'view_id': view_id,
|
$('.oe_translatable_text').not(".oe_translatable_inprogress").each(function(){
|
||||||
|
translated_ids.push($(this).attr('data-oe-translation-id'));
|
||||||
|
});
|
||||||
|
openerp.jsonRpc('/website/get_translated_length', 'call', {
|
||||||
|
'translated_ids': translated_ids,
|
||||||
'lang': website.get_context()['lang'],
|
'lang': website.get_context()['lang'],
|
||||||
}).done(function(res){
|
}).done(function(res){
|
||||||
var dialog = new website.GengoTranslatorStatisticDialog(res);
|
var dialog = new website.GengoTranslatorStatisticDialog(res);
|
||||||
|
@ -103,22 +79,6 @@
|
||||||
|
|
||||||
});
|
});
|
||||||
},
|
},
|
||||||
reload: function () {
|
|
||||||
website.reload();
|
|
||||||
},
|
|
||||||
});
|
|
||||||
|
|
||||||
website.GengoTranslatorDialog = openerp.Widget.extend({
|
|
||||||
events: _.extend({}, website.EditorBar.prototype.events, {
|
|
||||||
'hidden.bs.modal': 'destroy',
|
|
||||||
'click button[data-action=activate]': function (ev) {
|
|
||||||
this.trigger('activate');
|
|
||||||
},
|
|
||||||
}),
|
|
||||||
template: 'website.GengoTranslatorDialog',
|
|
||||||
start: function () {
|
|
||||||
this.$el.modal();
|
|
||||||
},
|
|
||||||
});
|
});
|
||||||
|
|
||||||
website.GengoTranslatorPostDialog = openerp.Widget.extend({
|
website.GengoTranslatorPostDialog = openerp.Widget.extend({
|
||||||
|
@ -141,13 +101,16 @@
|
||||||
template: 'website.GengoTranslatorStatisticDialog',
|
template: 'website.GengoTranslatorStatisticDialog',
|
||||||
init:function(res){
|
init:function(res){
|
||||||
var self = this;
|
var self = this;
|
||||||
this.total = res.total;
|
this.inprogess = 0;
|
||||||
this.inprogess = res.inprogess;
|
|
||||||
this.done = res.done;
|
|
||||||
this.new_words = 0;
|
this.new_words = 0;
|
||||||
|
this.done = res.done;
|
||||||
$('.oe_translatable_todo').each(function () {
|
$('.oe_translatable_todo').each(function () {
|
||||||
self.new_words += $(this).text().trim().replace(/ +/g," ").split(" ").length;
|
self.new_words += $(this).text().trim().replace(/ +/g," ").split(" ").length;
|
||||||
});
|
});
|
||||||
|
$('.oe_translatable_inprogress').each(function () {
|
||||||
|
self.inprogess += $(this).text().trim().replace(/ +/g," ").split(" ").length;
|
||||||
|
});
|
||||||
|
this.total = this.done + this.inprogess;
|
||||||
return this._super.apply(this, arguments);
|
return this._super.apply(this, arguments);
|
||||||
},
|
},
|
||||||
start: function (res) {
|
start: function (res) {
|
||||||
|
|
|
@ -1,28 +1,27 @@
|
||||||
<?xml version="1.0" encoding="utf-8"?>
|
<?xml version="1.0" encoding="utf-8"?>
|
||||||
<templates id="template" xml:space="preserve">
|
<templates id="template" xml:space="preserve">
|
||||||
<t t-name="website.ButtonGengoTranslator">
|
<t t-name="website.ButtonGengoTranslator">
|
||||||
<a class="btn btn-danger gengo_translate" data-action="translation_gengo" href="#">Gengo Translation</a>
|
<a class="btn btn-danger gengo_post" data-action="translation_gengo_post" href="#">Post to Gengo</a><a class="btn btn-danger hidden gengo_wait disabled" href="#"> <i class="fa fa-spinner fa-spin"></i> Wait</a><a class="btn btn-danger hidden gengo_inprogress disabled" href="#"> <i class="fa fa-clock-o"></i> Translation in Progress</a><a class="btn btn-danger gengo_info" data-action="translation_gengo_info"><i class="fa fa-info-circle"></i></a>
|
||||||
<a class="btn btn-danger hidden gengo_post" data-action="translation_gengo_post" href="#">Post to Gengo</a><a class="btn btn-danger hidden gengo_wait disabled" href="#"> <i class="fa fa-spinner fa-spin"></i> Wait</a><a class="btn btn-danger hidden gengo_inprogress disabled" href="#"> <i class="fa fa-clock-o"></i> Translation in Progress</a><a class="btn btn-danger gengo_info hidden" data-action="translation_gengo_info"><i class="fa fa-info-circle"></i></a>
|
|
||||||
<span class="gengo_discard hidden"> or <a href="#" data-action="reload">Return</a></span>
|
|
||||||
</t>
|
</t>
|
||||||
<t t-name="website.GengoTranslatorDialog">
|
<t t-name="website.TranslatorDialog">
|
||||||
<div class="modal fade oe_website_translator" tabindex="-1" role="dialog">
|
<div class="modal fade oe_website_translator" tabindex="-1" role="dialog">
|
||||||
<div class="modal-dialog">
|
<div class="modal-dialog">
|
||||||
<div class="modal-content">
|
<div class="modal-content">
|
||||||
<div class="modal-header">
|
<div class="modal-header">
|
||||||
<button title="Close" type="button" class="close" data-dismiss="modal">×</button>
|
<button title="Close" type="button" class="close" data-dismiss="modal">×</button>
|
||||||
<h2 class="modal-title">Translate this page using gengo</h2>
|
<h2 class="modal-title">Translate this page</h2>
|
||||||
</div>
|
</div>
|
||||||
<div class="modal-body">
|
<div class="modal-body">
|
||||||
<section>
|
<section>
|
||||||
|
<p>You are about to enter the translation mode.</p>
|
||||||
<p>
|
<p>
|
||||||
Here are the visuals used to help you translate efficiently:
|
Here are the visuals used to help you translate efficiently:
|
||||||
<ul class="oe_translate_examples">
|
<ul class="oe_translate_examples">
|
||||||
<li style="background:#ffffb6;">
|
<li style="background:#ffffb6;">
|
||||||
Content will be posted to <b><a href="http://gengo.com/" >Gengo</a></b> for translation.
|
Content to translate or you can post them to <b><a href="http://gengo.com/" >Gengo</a></b> for translation.
|
||||||
</li>
|
</li>
|
||||||
<li class="oe_translatable_inprogress">
|
<li class="oe_translatable_inprogress">
|
||||||
Translation in Process
|
Translation in Process (Gengo)
|
||||||
</li>
|
</li>
|
||||||
<li class="oe_translatable_text">
|
<li class="oe_translatable_text">
|
||||||
Already Translated content
|
Already Translated content
|
||||||
|
@ -30,7 +29,7 @@
|
||||||
</ul>
|
</ul>
|
||||||
</p>
|
</p>
|
||||||
<p>
|
<p>
|
||||||
In this mode, highligted text will be posted to Gengo for translation.
|
In this mode, you can translate texts or post texts to Gengo for translation.
|
||||||
To change the structure of the page, you must edit the
|
To change the structure of the page, you must edit the
|
||||||
master page.
|
master page.
|
||||||
</p>
|
</p>
|
||||||
|
|
|
@ -4,6 +4,7 @@
|
||||||
|
|
||||||
<template id="gengo_editor_head" inherit_id="website.editor_head" name="Editor Head" groups="base.group_website_publisher">
|
<template id="gengo_editor_head" inherit_id="website.editor_head" name="Editor Head" groups="base.group_website_publisher">
|
||||||
<xpath expr='//script[@src="/website/static/src/js/website.translator.js"]' position="after">
|
<xpath expr='//script[@src="/website/static/src/js/website.translator.js"]' position="after">
|
||||||
|
<link rel="stylesheet" href="/website_gengo/static/src/css/website_gengo.css"></link>
|
||||||
<script t-if="translatable" type="text/javascript" src="/website_gengo/static/src/js/website_gengo.js"></script>
|
<script t-if="translatable" type="text/javascript" src="/website_gengo/static/src/js/website_gengo.js"></script>
|
||||||
</xpath>
|
</xpath>
|
||||||
</template>
|
</template>
|
||||||
|
|
Loading…
Reference in New Issue