diff --git a/addons/base_gengo/wizard/base_gengo_translations.py b/addons/base_gengo/wizard/base_gengo_translations.py index bfd51480141..00c175e1450 100644 --- a/addons/base_gengo/wizard/base_gengo_translations.py +++ b/addons/base_gengo/wizard/base_gengo_translations.py @@ -74,6 +74,7 @@ class base_gengo_translations(osv.osv_memory): gengo = MyGengo( public_key=user.company_id.gengo_public_key.encode('ascii'), private_key=user.company_id.gengo_private_key.encode('ascii'), + sandbox = True, ) gengo.getAccountStats() return (True, gengo) diff --git a/addons/website/controllers/main.py b/addons/website/controllers/main.py index aee0997e4b4..4d20dd11d40 100644 --- a/addons/website/controllers/main.py +++ b/addons/website/controllers/main.py @@ -240,6 +240,8 @@ class Website(openerp.addons.web.controllers.main.Home): 'source': initial_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) return True diff --git a/addons/website/static/src/js/website.translator.js b/addons/website/static/src/js/website.translator.js index 399e5e731b2..c330d511170 100644 --- a/addons/website/static/src/js/website.translator.js +++ b/addons/website/static/src/js/website.translator.js @@ -120,7 +120,9 @@ } else { node.className += ' oe_translatable_todo'; } - node.contentEditable = true; + if(!this.gengo_translate){ + node.contentEditable = true; + } var nid = _.uniqueId(); $(node).attr('data-oe-nodeid', nid); this.initial_content[nid] = content; diff --git a/addons/website_gengo/__init__.py b/addons/website_gengo/__init__.py new file mode 100644 index 00000000000..654cb5b6b1a --- /dev/null +++ b/addons/website_gengo/__init__.py @@ -0,0 +1,21 @@ +# -*- coding: utf-8 -*- +############################################################################## +# +# OpenERP, Open Source Management Solution +# Copyright (C) 2013-Today OpenERP S.A. (). +# +# 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 . +# +############################################################################## + diff --git a/addons/website_gengo/__openerp__.py b/addons/website_gengo/__openerp__.py new file mode 100644 index 00000000000..6ebb5e8ed30 --- /dev/null +++ b/addons/website_gengo/__openerp__.py @@ -0,0 +1,40 @@ +# -*- coding: utf-8 -*- +############################################################################## +# +# OpenERP, Open Source Management Solution +# Copyright (C) 2013-Today OpenERP S.A. (). +# +# 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 . +# +############################################################################## + +{ + '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, +} diff --git a/addons/website_gengo/controllers/__init__.py b/addons/website_gengo/controllers/__init__.py new file mode 100644 index 00000000000..8ee9bae18d9 --- /dev/null +++ b/addons/website_gengo/controllers/__init__.py @@ -0,0 +1 @@ +import main diff --git a/addons/website_gengo/controllers/main.py b/addons/website_gengo/controllers/main.py new file mode 100644 index 00000000000..e69de29bb2d diff --git a/addons/website_gengo/static/src/js/website_gengo.js b/addons/website_gengo/static/src/js/website_gengo.js new file mode 100644 index 00000000000..6c5c2903dc6 --- /dev/null +++ b/addons/website_gengo/static/src/js/website_gengo.js @@ -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(); + }, + }); + +})(); diff --git a/addons/website_gengo/static/src/xml/website.gengo.xml b/addons/website_gengo/static/src/xml/website.gengo.xml new file mode 100644 index 00000000000..25d0cf8e44c --- /dev/null +++ b/addons/website_gengo/static/src/xml/website.gengo.xml @@ -0,0 +1,73 @@ + + + + Buy Translation + + + + + + + + + + + \ No newline at end of file diff --git a/addons/website_gengo/views/website_gengo.xml b/addons/website_gengo/views/website_gengo.xml new file mode 100644 index 00000000000..56681df4c42 --- /dev/null +++ b/addons/website_gengo/views/website_gengo.xml @@ -0,0 +1,12 @@ + + + + + + + +