[ADD] added website_gengo module
bzr revid: pga@tinyerp.com-20140318133036-j1hcrz7bybolw44u
This commit is contained in:
parent
5196cd6e8c
commit
c49befd59f
|
@ -74,6 +74,7 @@ class base_gengo_translations(osv.osv_memory):
|
||||||
gengo = MyGengo(
|
gengo = MyGengo(
|
||||||
public_key=user.company_id.gengo_public_key.encode('ascii'),
|
public_key=user.company_id.gengo_public_key.encode('ascii'),
|
||||||
private_key=user.company_id.gengo_private_key.encode('ascii'),
|
private_key=user.company_id.gengo_private_key.encode('ascii'),
|
||||||
|
sandbox = True,
|
||||||
)
|
)
|
||||||
gengo.getAccountStats()
|
gengo.getAccountStats()
|
||||||
return (True, gengo)
|
return (True, gengo)
|
||||||
|
|
|
@ -240,6 +240,8 @@ class Website(openerp.addons.web.controllers.main.Home):
|
||||||
'source': initial_content,
|
'source': initial_content,
|
||||||
'value': new_content,
|
'value': new_content,
|
||||||
}
|
}
|
||||||
|
if t.get('gengo_translation'):
|
||||||
|
new_trans['gengo_translation'] = t.get('gengo_translation')
|
||||||
irt.create(request.cr, request.uid, new_trans)
|
irt.create(request.cr, request.uid, new_trans)
|
||||||
return True
|
return True
|
||||||
|
|
||||||
|
|
|
@ -120,7 +120,9 @@
|
||||||
} else {
|
} else {
|
||||||
node.className += ' oe_translatable_todo';
|
node.className += ' oe_translatable_todo';
|
||||||
}
|
}
|
||||||
node.contentEditable = true;
|
if(!this.gengo_translate){
|
||||||
|
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;
|
||||||
|
|
|
@ -0,0 +1,21 @@
|
||||||
|
# -*- coding: utf-8 -*-
|
||||||
|
##############################################################################
|
||||||
|
#
|
||||||
|
# OpenERP, Open Source Management Solution
|
||||||
|
# Copyright (C) 2013-Today OpenERP S.A. (<http://www.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/>.
|
||||||
|
#
|
||||||
|
##############################################################################
|
||||||
|
|
|
@ -0,0 +1,40 @@
|
||||||
|
# -*- coding: utf-8 -*-
|
||||||
|
##############################################################################
|
||||||
|
#
|
||||||
|
# OpenERP, Open Source Management Solution
|
||||||
|
# Copyright (C) 2013-Today OpenERP S.A. (<http://www.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/>.
|
||||||
|
#
|
||||||
|
##############################################################################
|
||||||
|
|
||||||
|
{
|
||||||
|
'name': 'Website Gengo Translator',
|
||||||
|
'category': 'Website',
|
||||||
|
'version': '1.0',
|
||||||
|
'description': """
|
||||||
|
Website Gengo Translator
|
||||||
|
========================
|
||||||
|
""",
|
||||||
|
'author': 'OpenERP SA',
|
||||||
|
'depends': [
|
||||||
|
'website',
|
||||||
|
'base_gengo'
|
||||||
|
],
|
||||||
|
'data': [
|
||||||
|
'views/website_gengo.xml',
|
||||||
|
],
|
||||||
|
'qweb': [],
|
||||||
|
'installable': True,
|
||||||
|
}
|
|
@ -0,0 +1 @@
|
||||||
|
import main
|
|
@ -0,0 +1,91 @@
|
||||||
|
(function () {
|
||||||
|
'use strict';
|
||||||
|
|
||||||
|
var website = openerp.website;
|
||||||
|
website.add_template_file('/website_gengo/static/src/xml/website.gengo.xml');
|
||||||
|
|
||||||
|
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',
|
||||||
|
}),
|
||||||
|
start: function () {
|
||||||
|
this.gengo_translate = false;
|
||||||
|
this._super.apply(this, arguments);
|
||||||
|
var self = this;
|
||||||
|
self.$('button[data-action=edit]')
|
||||||
|
.after(openerp.qweb.render('website.ButtonGengoTranslator'));
|
||||||
|
},
|
||||||
|
translation_gengo: function () {
|
||||||
|
var self = this;
|
||||||
|
var dialog = new website.GengoTranslatorDialog();
|
||||||
|
dialog.appendTo($(document.body));
|
||||||
|
self.gengo_translate = true;
|
||||||
|
dialog.on('activate', this, function () {
|
||||||
|
dialog.$el.modal('hide');
|
||||||
|
self.translate().then(function () {
|
||||||
|
self.gengo_translate = false;
|
||||||
|
self.$el.find('.gengo_translate').addClass("hidden");
|
||||||
|
self.$el.find('.gengo_post').removeClass("hidden");
|
||||||
|
});
|
||||||
|
});
|
||||||
|
|
||||||
|
},
|
||||||
|
translation_gengo_post: function () {
|
||||||
|
var self = this;
|
||||||
|
var translatable_list = $.find('.oe_translatable_todo');
|
||||||
|
var dialog = new website.GengoTranslatorPostDialog();
|
||||||
|
dialog.appendTo($(document.body));
|
||||||
|
dialog.on('service_level', this, function () {
|
||||||
|
var gengo_service_level = dialog.$el.find(".form-control").val();
|
||||||
|
dialog.$el.modal('hide');
|
||||||
|
var trans ={}
|
||||||
|
$('.oe_translatable_todo').each(function () {
|
||||||
|
var $node = $(this);
|
||||||
|
var data = $node.data();
|
||||||
|
if (!trans[data.oeTranslationViewId]) {
|
||||||
|
trans[data.oeTranslationViewId] = [];
|
||||||
|
}
|
||||||
|
trans[data.oeTranslationViewId].push({
|
||||||
|
initial_content: self.getInitialContent(this),
|
||||||
|
new_content:self.getInitialContent(this),
|
||||||
|
translation_id: data.oeTranslationId || null,
|
||||||
|
gengo_translation: gengo_service_level
|
||||||
|
});
|
||||||
|
});
|
||||||
|
openerp.jsonRpc('/website/set_translations', 'call', {
|
||||||
|
'data': trans,
|
||||||
|
'lang': website.get_context()['lang'],
|
||||||
|
});
|
||||||
|
});
|
||||||
|
|
||||||
|
},
|
||||||
|
});
|
||||||
|
|
||||||
|
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({
|
||||||
|
events: _.extend({}, website.EditorBar.prototype.events, {
|
||||||
|
'hidden.bs.modal': 'destroy',
|
||||||
|
'click button[data-action=service_level]': function (ev) {
|
||||||
|
this.trigger('service_level');
|
||||||
|
},
|
||||||
|
}),
|
||||||
|
template: 'website.GengoTranslatorPostDialog',
|
||||||
|
start: function () {
|
||||||
|
this.$el.modal();
|
||||||
|
},
|
||||||
|
});
|
||||||
|
|
||||||
|
})();
|
|
@ -0,0 +1,73 @@
|
||||||
|
<?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="#">Buy Translation</a>
|
||||||
|
<a class="btn btn-danger hidden gengo_post" data-action="translation_gengo_post" href="#">Post to Gengo</a>
|
||||||
|
</t>
|
||||||
|
<t t-name="website.GengoTranslatorDialog">
|
||||||
|
<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>
|
||||||
|
</div>
|
||||||
|
<div class="modal-body">
|
||||||
|
<section>
|
||||||
|
<p>
|
||||||
|
Here are the visuals used to help you translate efficiently:
|
||||||
|
<ul class="oe_translate_examples">
|
||||||
|
<li class="oe_translatable_todo">
|
||||||
|
Content will be posted to <b><a href="http://gengo.com/" >Gengo</a></b> for translation.
|
||||||
|
</li>
|
||||||
|
<li class="oe_translatable_text">
|
||||||
|
Already Translated content
|
||||||
|
</li>
|
||||||
|
</ul>
|
||||||
|
</p>
|
||||||
|
<p>
|
||||||
|
In this mode, highligted text will be posted to Gengo for translation.
|
||||||
|
To change the structure of the page, you must edit the
|
||||||
|
master page.
|
||||||
|
</p>
|
||||||
|
</section>
|
||||||
|
</div>
|
||||||
|
<div class="modal-footer">
|
||||||
|
<button type="button" data-action="activate" class="btn btn-primary">Ok</button>
|
||||||
|
or
|
||||||
|
<a data-action="discard" data-dismiss="modal" href="#">Cancel</a>
|
||||||
|
</div>
|
||||||
|
</div>
|
||||||
|
</div>
|
||||||
|
</div>
|
||||||
|
</t>
|
||||||
|
|
||||||
|
<t t-name="website.GengoTranslatorPostDialog">
|
||||||
|
<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">Select Gengo Translation Service Level</h2>
|
||||||
|
</div>
|
||||||
|
<div class="modal-body">
|
||||||
|
<section>
|
||||||
|
<select class="form-control" required="required" autofocus="autofocus">
|
||||||
|
<option value="machine">Translation By Machine</option>
|
||||||
|
<option value="standard">Standard</option>
|
||||||
|
<option value="pro">Pro</option>
|
||||||
|
<option value="ultra">Ultra</option>
|
||||||
|
</select>
|
||||||
|
</section>
|
||||||
|
</div>
|
||||||
|
<div class="modal-footer">
|
||||||
|
<button type="button" data-action="service_level" class="btn btn-primary">Post</button>
|
||||||
|
or
|
||||||
|
<a data-action="discard" data-dismiss="modal" href="#">Cancel</a>
|
||||||
|
</div>
|
||||||
|
</div>
|
||||||
|
</div>
|
||||||
|
</div>
|
||||||
|
</t>
|
||||||
|
|
||||||
|
</templates>
|
|
@ -0,0 +1,12 @@
|
||||||
|
<?xml version="1.0" encoding="utf-8"?>
|
||||||
|
<openerp>
|
||||||
|
<data>
|
||||||
|
|
||||||
|
<template id="gengo_editor_head" inherit_id="website.layout" name="Editor" groups="base.group_website_publisher">
|
||||||
|
<xpath expr='//script[@src="/web/static/lib/bootstrap/js/bootstrap.js"]' position="after">
|
||||||
|
<script t-if="translatable" type="text/javascript" src="/website_gengo/static/src/js/website_gengo.js"></script>
|
||||||
|
</xpath>
|
||||||
|
</template>
|
||||||
|
|
||||||
|
</data>
|
||||||
|
</openerp>
|
Loading…
Reference in New Issue