[IMP] added gengo statistics, displayed inprogress elements
bzr revid: pga@tinyerp.com-20140319133121-31umju0ea84sm93y
This commit is contained in:
parent
c49befd59f
commit
b8d87606f0
|
@ -206,7 +206,7 @@ class Website(openerp.addons.web.controllers.main.Home):
|
||||||
views_ids = [view.get('id') for view in views if view.get('active')]
|
views_ids = [view.get('id') for view in views if view.get('active')]
|
||||||
domain = [('type', '=', 'view'), ('res_id', 'in', views_ids), ('lang', '=', lang)]
|
domain = [('type', '=', 'view'), ('res_id', 'in', views_ids), ('lang', '=', lang)]
|
||||||
irt = request.registry.get('ir.translation')
|
irt = request.registry.get('ir.translation')
|
||||||
return irt.search_read(request.cr, request.uid, domain, ['id', 'res_id', 'value'], context=request.context)
|
return irt.search_read(request.cr, request.uid, domain, ['id', 'res_id', 'value','state'], context=request.context)
|
||||||
|
|
||||||
@http.route('/website/set_translations', type='json', auth='public', website=True)
|
@http.route('/website/set_translations', type='json', auth='public', website=True)
|
||||||
def set_translations(self, data, lang):
|
def set_translations(self, data, lang):
|
||||||
|
|
|
@ -145,6 +145,10 @@ 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,6 +115,8 @@ 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)
|
||||||
|
|
||||||
// }}}
|
// }}}
|
||||||
|
|
||||||
|
|
|
@ -115,8 +115,13 @@
|
||||||
var trans = this.translations.filter(function (t) {
|
var trans = this.translations.filter(function (t) {
|
||||||
return t.res_id === view_id && t.value === content;
|
return t.res_id === view_id && t.value === content;
|
||||||
});
|
});
|
||||||
|
console.log(trans);
|
||||||
|
console.log(this.translations);
|
||||||
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].state && trans[0].state == 'inprogress'){
|
||||||
|
node.className += ' oe_translatable_inprogress';
|
||||||
|
}
|
||||||
} else {
|
} else {
|
||||||
node.className += ' oe_translatable_todo';
|
node.className += ' oe_translatable_todo';
|
||||||
}
|
}
|
||||||
|
|
|
@ -19,3 +19,4 @@
|
||||||
#
|
#
|
||||||
##############################################################################
|
##############################################################################
|
||||||
|
|
||||||
|
import controllers
|
|
@ -0,0 +1,19 @@
|
||||||
|
# -*- coding: utf-8 -*-
|
||||||
|
|
||||||
|
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):
|
||||||
|
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'] += len(trans.source.split())
|
||||||
|
elif trans.state == 'inprogress':
|
||||||
|
result['inprogess'] += len(trans.source.split())
|
||||||
|
return result
|
|
@ -8,13 +8,19 @@
|
||||||
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]': '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',
|
||||||
}),
|
}),
|
||||||
start: function () {
|
start: function () {
|
||||||
this.gengo_translate = false;
|
this.gengo_translate = false;
|
||||||
this._super.apply(this, arguments);
|
this._super.apply(this, arguments);
|
||||||
var self = this;
|
var self = this;
|
||||||
self.$('button[data-action=edit]')
|
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"];
|
||||||
.after(openerp.qweb.render('website.ButtonGengoTranslator'));
|
if (gengo_langs.indexOf(website.get_context()['lang']) != -1)
|
||||||
|
{
|
||||||
|
self.$('button[data-action=edit]')
|
||||||
|
.after(openerp.qweb.render('website.ButtonGengoTranslator'));
|
||||||
|
|
||||||
|
}
|
||||||
},
|
},
|
||||||
translation_gengo: function () {
|
translation_gengo: function () {
|
||||||
var self = this;
|
var self = this;
|
||||||
|
@ -25,8 +31,15 @@
|
||||||
dialog.$el.modal('hide');
|
dialog.$el.modal('hide');
|
||||||
self.translate().then(function () {
|
self.translate().then(function () {
|
||||||
self.gengo_translate = false;
|
self.gengo_translate = false;
|
||||||
self.$el.find('.gengo_translate').addClass("hidden");
|
if($('.oe_translatable_todo').length > 0){
|
||||||
self.$el.find('.gengo_post').removeClass("hidden");
|
self.$el.find('.gengo_translate').addClass("hidden");
|
||||||
|
self.$el.find('.gengo_post').removeClass("hidden");
|
||||||
|
}
|
||||||
|
else{
|
||||||
|
self.$el.find('.gengo_translate').addClass("hidden");
|
||||||
|
self.$el.find('.gengo_inprogress').removeClass("hidden");
|
||||||
|
|
||||||
|
}
|
||||||
});
|
});
|
||||||
});
|
});
|
||||||
|
|
||||||
|
@ -39,6 +52,8 @@
|
||||||
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').addClass("hidden");
|
||||||
|
self.$el.find('.gengo_inprogress').removeClass("hidden");
|
||||||
var trans ={}
|
var trans ={}
|
||||||
$('.oe_translatable_todo').each(function () {
|
$('.oe_translatable_todo').each(function () {
|
||||||
var $node = $(this);
|
var $node = $(this);
|
||||||
|
@ -60,6 +75,18 @@
|
||||||
});
|
});
|
||||||
|
|
||||||
},
|
},
|
||||||
|
translation_gengo_info: function () {
|
||||||
|
var repr = $(document.documentElement).data('mainObject')
|
||||||
|
var view_id = repr.match(/.+\((.+), (\d+)\)/)[2];
|
||||||
|
openerp.jsonRpc('/website/get_gengo_info', 'call', {
|
||||||
|
'view_id': view_id,
|
||||||
|
'lang': website.get_context()['lang'],
|
||||||
|
}).done(function(res){
|
||||||
|
var dialog = new website.GengoTranslatorStatisticDialog(res);
|
||||||
|
dialog.appendTo($(document.body));
|
||||||
|
|
||||||
|
});
|
||||||
|
},
|
||||||
});
|
});
|
||||||
|
|
||||||
website.GengoTranslatorDialog = openerp.Widget.extend({
|
website.GengoTranslatorDialog = openerp.Widget.extend({
|
||||||
|
@ -87,5 +114,21 @@
|
||||||
this.$el.modal();
|
this.$el.modal();
|
||||||
},
|
},
|
||||||
});
|
});
|
||||||
|
|
||||||
|
website.GengoTranslatorStatisticDialog = openerp.Widget.extend({
|
||||||
|
events: _.extend({}, website.EditorBar.prototype.events, {
|
||||||
|
'hidden.bs.modal': 'destroy',
|
||||||
|
}),
|
||||||
|
template: 'website.GengoTranslatorStatisticDialog',
|
||||||
|
init:function(res){
|
||||||
|
this.total = res.total;
|
||||||
|
this.inprogess = res.inprogess;
|
||||||
|
this.done = res.done;
|
||||||
|
return this._super.apply(this, arguments);
|
||||||
|
},
|
||||||
|
start: function (res) {
|
||||||
|
this.$el.modal(this.res);
|
||||||
|
},
|
||||||
|
});
|
||||||
|
|
||||||
})();
|
})();
|
||||||
|
|
|
@ -1,8 +1,7 @@
|
||||||
<?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="#">Buy Translation</a>
|
<a class="btn btn-danger gengo_translate" data-action="translation_gengo" href="#">Buy 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_inprogress disabled" href="#"> <i class="fa fa-clock-o"></i> Translation in Progress</a><a class="btn btn-danger" 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>
|
|
||||||
</t>
|
</t>
|
||||||
<t t-name="website.GengoTranslatorDialog">
|
<t t-name="website.GengoTranslatorDialog">
|
||||||
<div class="modal fade oe_website_translator" tabindex="-1" role="dialog">
|
<div class="modal fade oe_website_translator" tabindex="-1" role="dialog">
|
||||||
|
@ -17,9 +16,12 @@
|
||||||
<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 class="oe_translatable_todo">
|
<li style="background:#ffffb6;">
|
||||||
Content will be posted to <b><a href="http://gengo.com/" >Gengo</a></b> for translation.
|
Content will be posted to <b><a href="http://gengo.com/" >Gengo</a></b> for translation.
|
||||||
</li>
|
</li>
|
||||||
|
<li class="oe_translatable_inprogress">
|
||||||
|
Translation in Process
|
||||||
|
</li>
|
||||||
<li class="oe_translatable_text">
|
<li class="oe_translatable_text">
|
||||||
Already Translated content
|
Already Translated content
|
||||||
</li>
|
</li>
|
||||||
|
@ -70,4 +72,28 @@
|
||||||
</div>
|
</div>
|
||||||
</t>
|
</t>
|
||||||
|
|
||||||
|
<t t-name="website.GengoTranslatorStatisticDialog">
|
||||||
|
<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">Gengo translator statistic for this page</h2>
|
||||||
|
</div>
|
||||||
|
<div class="modal-body">
|
||||||
|
<b><h3>
|
||||||
|
<div class="text-info mb8"> <i class="fa fa-align-left"></i> Words to translate <t t-esc="widget.total"></t></div>
|
||||||
|
<div class="text-warning mb8"> <i class="fa fa-cogs"></i> Words in progress <t t-esc="widget.inprogess"></t></div>
|
||||||
|
<div class="text-success mb8"> <i class="fa fa-check"></i> Translated words <t t-esc="widget.done"></t></div>
|
||||||
|
|
||||||
|
</h3></b>
|
||||||
|
</div>
|
||||||
|
<div class="modal-footer">
|
||||||
|
<a data-action="discard" data-dismiss="modal" href="#">Close</a>
|
||||||
|
</div>
|
||||||
|
</div>
|
||||||
|
</div>
|
||||||
|
</div>
|
||||||
|
</t>
|
||||||
|
|
||||||
</templates>
|
</templates>
|
Loading…
Reference in New Issue