[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):
|
||||
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'
|
||||
_columns = {
|
||||
'restart_send_job': fields.boolean("Restart Sending Job"),
|
||||
'sync_type': fields.selection([('send', 'Send New Terms'),
|
||||
('receive', 'Receive Translation'),
|
||||
('both', 'Both')], "Sync Type"),
|
||||
|
@ -125,9 +124,6 @@ class base_gengo_translations(osv.osv_memory):
|
|||
if wizard.sync_type in ['receive','both']:
|
||||
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)
|
||||
return {'type': 'ir.actions.act_window_close'}
|
||||
|
||||
def _sync_response(self, cr, uid, limit=GENGO_DEFAULT_LIMIT, context=None):
|
||||
|
|
|
@ -9,14 +9,9 @@
|
|||
<group>
|
||||
<field name="lang_id"/>
|
||||
</group>
|
||||
<group>
|
||||
<group>
|
||||
<field name="sync_type" widget="radio"/>
|
||||
</group>
|
||||
<group>
|
||||
<field name="restart_send_job"/>
|
||||
</group>
|
||||
</group>
|
||||
<footer>
|
||||
<button name="act_update" string="Send" type="object" class="oe_highlight"/>
|
||||
or
|
||||
|
|
|
@ -145,10 +145,6 @@ table.editorbar-panel td.selected {
|
|||
background: #ffffb6;
|
||||
}
|
||||
|
||||
.oe_translatable_inprogress {
|
||||
background: #b7e4ff;
|
||||
}
|
||||
|
||||
/* ---- MENU ---- {{{ */
|
||||
div.oe_menu_buttons {
|
||||
top: -8px;
|
||||
|
|
|
@ -115,8 +115,6 @@ table.editorbar-panel
|
|||
padding: 0 10px
|
||||
.oe_translatable_todo
|
||||
background: rgb(255, 255, 182)
|
||||
.oe_translatable_todo
|
||||
background: rgb(183, 228, 255)
|
||||
|
||||
// }}}
|
||||
|
||||
|
|
|
@ -34,11 +34,17 @@
|
|||
dialog.$el.modal('hide');
|
||||
self.translate().then(function () {
|
||||
mysuper.call(self);
|
||||
if(self.gengo_translate){
|
||||
self.translation_gengo_display()
|
||||
}
|
||||
});
|
||||
});
|
||||
} else {
|
||||
this.translate().then(function () {
|
||||
mysuper.call(self);
|
||||
if(self.gengo_translate){
|
||||
self.translation_gengo_display()
|
||||
}
|
||||
});
|
||||
}
|
||||
},
|
||||
|
@ -90,7 +96,7 @@
|
|||
self.sanitizeNode($node[0]);
|
||||
}
|
||||
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);
|
||||
});
|
||||
|
@ -118,19 +124,12 @@
|
|||
if (trans.length) {
|
||||
node.setAttribute('data-oe-translation-id', trans[0].id);
|
||||
if(trans[0].gengo_translation && (trans[0].state == 'inprogress' || trans[0].state == 'to_translate')){
|
||||
if(this.gengo_translate){
|
||||
node.className += ' oe_translatable_inprogress';
|
||||
}
|
||||
else{
|
||||
node.className += ' oe_translatable_todo';
|
||||
}
|
||||
}
|
||||
} else {
|
||||
node.className += ' oe_translatable_todo';
|
||||
}
|
||||
if(!this.gengo_translate){
|
||||
node.contentEditable = true;
|
||||
}
|
||||
var nid = _.uniqueId();
|
||||
$(node).attr('data-oe-nodeid', nid);
|
||||
this.initial_content[nid] = content;
|
||||
|
|
|
@ -4,16 +4,11 @@ from openerp.addons.web import http
|
|||
from openerp.addons.web.http import request
|
||||
class website_gengo(http.Controller):
|
||||
|
||||
@http.route('/website/get_gengo_info', type='json', auth='user', website=True)
|
||||
def get_gengo_info(self, view_id, lang):
|
||||
@http.route('/website/get_translated_length', type='json', auth='user', website=True)
|
||||
def get_translated_length(self, translated_ids, lang):
|
||||
ir_translation_obj = request.registry['ir.translation']
|
||||
res_lang_obj = request.registry['res.lang']
|
||||
translation_ids = ir_translation_obj.search(request.cr, request.uid, [('res_id','=',view_id),('gengo_translation','!=', False),('lang','=',lang)])
|
||||
result={"total":0,"inprogess":0,"done":0}
|
||||
for trans in ir_translation_obj.browse(request.cr, request.uid, translation_ids):
|
||||
result['total'] += len(trans.source.split())
|
||||
if trans.state == 'translated':
|
||||
result={"done":0}
|
||||
gengo_translation_ids = ir_translation_obj.search(request.cr, request.uid, [('id','in',translated_ids),('gengo_translation','!=', False)])
|
||||
for trans in ir_translation_obj.browse(request.cr, request.uid, gengo_translation_ids):
|
||||
result['done'] += len(trans.source.split())
|
||||
elif trans.state in ['inprogress','to_translate']:
|
||||
result['inprogess'] += len(trans.source.split())
|
||||
return result
|
||||
|
|
|
@ -0,0 +1,3 @@
|
|||
.oe_translatable_inprogress {
|
||||
background: #b7e4ff;
|
||||
}
|
|
@ -6,53 +6,25 @@
|
|||
|
||||
website.EditorBar.include({
|
||||
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_info]': 'translation_gengo_info',
|
||||
'click a[data-action=reload]': 'reload',
|
||||
}),
|
||||
start: function () {
|
||||
this.gengo_translate = false;
|
||||
edit:function () {
|
||||
this.gengo_translate = true;
|
||||
this._super.apply(this, arguments);
|
||||
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"];
|
||||
if (gengo_langs.indexOf(website.get_context()['lang']) != -1)
|
||||
{
|
||||
self.$('button[data-action=edit]')
|
||||
if (gengo_langs.indexOf(website.get_context()['lang']) != -1){
|
||||
self.$('button[data-action=save]')
|
||||
.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(){
|
||||
var self = this;
|
||||
self.translate().then(function () {
|
||||
self.gengo_translate = false;
|
||||
if($('.oe_translatable_todo').length > 0){
|
||||
self.$el.find('form.navbar-form.navbar-left > *').addClass("hidden");
|
||||
self.$el.find('.gengo_post,.gengo_info,.gengo_discard').removeClass("hidden");
|
||||
if($('.oe_translatable_todo').length == 0){
|
||||
self.$el.find('.gengo_post').addClass("hidden");
|
||||
self.$el.find('.gengo_inprogress').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 () {
|
||||
var self = this;
|
||||
|
@ -62,7 +34,7 @@
|
|||
dialog.on('service_level', this, function () {
|
||||
var gengo_service_level = dialog.$el.find(".form-control").val();
|
||||
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");
|
||||
var trans ={}
|
||||
$('.oe_translatable_todo').each(function () {
|
||||
|
@ -92,10 +64,14 @@
|
|||
|
||||
},
|
||||
translation_gengo_info: function () {
|
||||
var repr = $(document.documentElement).data('mainObject')
|
||||
var repr = $(document.documentElement).data('mainObject');
|
||||
var view_id = repr.match(/.+\((.+), (\d+)\)/)[2];
|
||||
openerp.jsonRpc('/website/get_gengo_info', 'call', {
|
||||
'view_id': view_id,
|
||||
var translated_ids = [];
|
||||
$('.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'],
|
||||
}).done(function(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({
|
||||
|
@ -141,13 +101,16 @@
|
|||
template: 'website.GengoTranslatorStatisticDialog',
|
||||
init:function(res){
|
||||
var self = this;
|
||||
this.total = res.total;
|
||||
this.inprogess = res.inprogess;
|
||||
this.done = res.done;
|
||||
this.inprogess = 0;
|
||||
this.new_words = 0;
|
||||
this.done = res.done;
|
||||
$('.oe_translatable_todo').each(function () {
|
||||
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);
|
||||
},
|
||||
start: function (res) {
|
||||
|
|
|
@ -1,28 +1,27 @@
|
|||
<?xml version="1.0" encoding="utf-8"?>
|
||||
<templates id="template" xml:space="preserve">
|
||||
<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 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>
|
||||
<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>
|
||||
</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-dialog">
|
||||
<div class="modal-content">
|
||||
<div class="modal-header">
|
||||
<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 class="modal-body">
|
||||
<section>
|
||||
<p>You are about to enter the translation mode.</p>
|
||||
<p>
|
||||
Here are the visuals used to help you translate efficiently:
|
||||
<ul class="oe_translate_examples">
|
||||
<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 class="oe_translatable_inprogress">
|
||||
Translation in Process
|
||||
Translation in Process (Gengo)
|
||||
</li>
|
||||
<li class="oe_translatable_text">
|
||||
Already Translated content
|
||||
|
@ -30,7 +29,7 @@
|
|||
</ul>
|
||||
</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
|
||||
master page.
|
||||
</p>
|
||||
|
|
|
@ -4,6 +4,7 @@
|
|||
|
||||
<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">
|
||||
<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>
|
||||
</xpath>
|
||||
</template>
|
||||
|
|
Loading…
Reference in New Issue