committed by
Timon Tschanz
10 changed files with 0 additions and 482 deletions
-
1web_translate_dialog/__init__.py
-
44web_translate_dialog/__openerp__.py
-
37web_translate_dialog/i18n/es.po
-
37web_translate_dialog/i18n/fr.po
-
39web_translate_dialog/i18n/nl.po
-
39web_translate_dialog/i18n/tr.po
-
36web_translate_dialog/i18n/web_translate_dialog.pot
-
6web_translate_dialog/static/src/css/base.css
-
209web_translate_dialog/static/src/js/web_translate_dialog.js
-
34web_translate_dialog/static/src/xml/base.xml
@ -1 +0,0 @@ |
|||||
# -*- coding: utf-8 -*- |
|
@ -1,44 +0,0 @@ |
|||||
# -*- coding: utf-8 -*- |
|
||||
############################################################################## |
|
||||
# |
|
||||
# Author: Guewen Baconnier |
|
||||
# Copyright 2012 Camptocamp SA |
|
||||
# |
|
||||
# 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": "Web Translate Dialog", |
|
||||
"category": "Hidden", |
|
||||
"description": """ |
|
||||
Replace the standard translation view by an alternative one: |
|
||||
|
|
||||
* Add a "Translate" button item in the "More" menu |
|
||||
* The translations are displayed in a dialog (much like the OpenERP |
|
||||
6.1's one) |
|
||||
* Support HTML fields |
|
||||
* Autosize the textareas to the size of the content |
|
||||
|
|
||||
""", |
|
||||
"version": "1.0", |
|
||||
"depends": ['web', |
|
||||
], |
|
||||
'js': ['static/src/js/web_translate_dialog.js', |
|
||||
], |
|
||||
'css': ['static/src/css/base.css', |
|
||||
], |
|
||||
'qweb': ["static/src/xml/base.xml", |
|
||||
], |
|
||||
'auto_install': False, |
|
||||
} |
|
@ -1,37 +0,0 @@ |
|||||
# Translation of OpenERP Server. |
|
||||
# This file contains the translation of the following modules: |
|
||||
# |
|
||||
msgid "" |
|
||||
msgstr "" |
|
||||
"Project-Id-Version: OpenERP Server 7.0\n" |
|
||||
"Report-Msgid-Bugs-To: \n" |
|
||||
"POT-Creation-Date: 2013-12-09 07:15+0000\n" |
|
||||
"PO-Revision-Date: 2014-03-07 15:45+0000\n" |
|
||||
"Last-Translator: Pedro Manuel Baeza <pedro.baeza@gmail.com>\n" |
|
||||
"Language-Team: \n" |
|
||||
"MIME-Version: 1.0\n" |
|
||||
"Content-Type: text/plain; charset=UTF-8\n" |
|
||||
"Content-Transfer-Encoding: 8bit\n" |
|
||||
"X-Launchpad-Export-Date: 2014-06-28 06:02+0000\n" |
|
||||
"X-Generator: Launchpad (build 17077)\n" |
|
||||
|
|
||||
#. module: web_translate_dialog |
|
||||
#. openerp-web |
|
||||
#: code:addons/web_translate_dialog/static/src/js/web_translate_dialog.js:15 |
|
||||
#, python-format |
|
||||
msgid "Translate" |
|
||||
msgstr "Traducir" |
|
||||
|
|
||||
#. module: web_translate_dialog |
|
||||
#. openerp-web |
|
||||
#: code:addons/web_translate_dialog/static/src/js/web_translate_dialog.js:37 |
|
||||
#, python-format |
|
||||
msgid "Translations" |
|
||||
msgstr "Traducciones" |
|
||||
|
|
||||
#. module: web_translate_dialog |
|
||||
#. openerp-web |
|
||||
#: code:addons/web_translate_dialog/static/src/xml/base.xml:7 |
|
||||
#, python-format |
|
||||
msgid "Field" |
|
||||
msgstr "Campo" |
|
@ -1,37 +0,0 @@ |
|||||
# Translation of OpenERP Server. |
|
||||
# This file contains the translation of the following modules: |
|
||||
# |
|
||||
msgid "" |
|
||||
msgstr "" |
|
||||
"Project-Id-Version: OpenERP Server 7.0\n" |
|
||||
"Report-Msgid-Bugs-To: \n" |
|
||||
"POT-Creation-Date: 2013-12-09 07:15+0000\n" |
|
||||
"PO-Revision-Date: 2014-03-07 15:45+0000\n" |
|
||||
"Last-Translator: Guewen Baconnier @ Camptocamp <Unknown>\n" |
|
||||
"Language-Team: \n" |
|
||||
"MIME-Version: 1.0\n" |
|
||||
"Content-Type: text/plain; charset=UTF-8\n" |
|
||||
"Content-Transfer-Encoding: 8bit\n" |
|
||||
"X-Launchpad-Export-Date: 2014-06-28 06:02+0000\n" |
|
||||
"X-Generator: Launchpad (build 17077)\n" |
|
||||
|
|
||||
#. module: web_translate_dialog |
|
||||
#. openerp-web |
|
||||
#: code:addons/web_translate_dialog/static/src/js/web_translate_dialog.js:15 |
|
||||
#, python-format |
|
||||
msgid "Translate" |
|
||||
msgstr "Traduire" |
|
||||
|
|
||||
#. module: web_translate_dialog |
|
||||
#. openerp-web |
|
||||
#: code:addons/web_translate_dialog/static/src/js/web_translate_dialog.js:37 |
|
||||
#, python-format |
|
||||
msgid "Translations" |
|
||||
msgstr "Traductions" |
|
||||
|
|
||||
#. module: web_translate_dialog |
|
||||
#. openerp-web |
|
||||
#: code:addons/web_translate_dialog/static/src/xml/base.xml:7 |
|
||||
#, python-format |
|
||||
msgid "Field" |
|
||||
msgstr "Champ" |
|
@ -1,39 +0,0 @@ |
|||||
# Dutch translation for web-addons |
|
||||
# Copyright (c) 2014 Rosetta Contributors and Canonical Ltd 2014 |
|
||||
# This file is distributed under the same license as the web-addons package. |
|
||||
# FIRST AUTHOR <EMAIL@ADDRESS>, 2014. |
|
||||
# |
|
||||
msgid "" |
|
||||
msgstr "" |
|
||||
"Project-Id-Version: web-addons\n" |
|
||||
"Report-Msgid-Bugs-To: FULL NAME <EMAIL@ADDRESS>\n" |
|
||||
"POT-Creation-Date: 2013-12-09 07:15+0000\n" |
|
||||
"PO-Revision-Date: 2014-03-10 10:09+0000\n" |
|
||||
"Last-Translator: Erwin van der Ploeg (BAS Solutions) <Unknown>\n" |
|
||||
"Language-Team: Dutch <nl@li.org>\n" |
|
||||
"MIME-Version: 1.0\n" |
|
||||
"Content-Type: text/plain; charset=UTF-8\n" |
|
||||
"Content-Transfer-Encoding: 8bit\n" |
|
||||
"X-Launchpad-Export-Date: 2014-06-28 06:02+0000\n" |
|
||||
"X-Generator: Launchpad (build 17077)\n" |
|
||||
|
|
||||
#. module: web_translate_dialog |
|
||||
#. openerp-web |
|
||||
#: code:addons/web_translate_dialog/static/src/js/web_translate_dialog.js:15 |
|
||||
#, python-format |
|
||||
msgid "Translate" |
|
||||
msgstr "Vertalen" |
|
||||
|
|
||||
#. module: web_translate_dialog |
|
||||
#. openerp-web |
|
||||
#: code:addons/web_translate_dialog/static/src/js/web_translate_dialog.js:37 |
|
||||
#, python-format |
|
||||
msgid "Translations" |
|
||||
msgstr "Vertalingen" |
|
||||
|
|
||||
#. module: web_translate_dialog |
|
||||
#. openerp-web |
|
||||
#: code:addons/web_translate_dialog/static/src/xml/base.xml:7 |
|
||||
#, python-format |
|
||||
msgid "Field" |
|
||||
msgstr "Veld" |
|
@ -1,39 +0,0 @@ |
|||||
# Turkish translation for web-addons |
|
||||
# Copyright (c) 2014 Rosetta Contributors and Canonical Ltd 2014 |
|
||||
# This file is distributed under the same license as the web-addons package. |
|
||||
# FIRST AUTHOR <EMAIL@ADDRESS>, 2014. |
|
||||
# |
|
||||
msgid "" |
|
||||
msgstr "" |
|
||||
"Project-Id-Version: web-addons\n" |
|
||||
"Report-Msgid-Bugs-To: FULL NAME <EMAIL@ADDRESS>\n" |
|
||||
"POT-Creation-Date: 2013-12-09 07:15+0000\n" |
|
||||
"PO-Revision-Date: 2014-03-07 22:08+0000\n" |
|
||||
"Last-Translator: Ediz Duman <neps1192@gmail.com>\n" |
|
||||
"Language-Team: Turkish <tr@li.org>\n" |
|
||||
"MIME-Version: 1.0\n" |
|
||||
"Content-Type: text/plain; charset=UTF-8\n" |
|
||||
"Content-Transfer-Encoding: 8bit\n" |
|
||||
"X-Launchpad-Export-Date: 2014-06-28 06:02+0000\n" |
|
||||
"X-Generator: Launchpad (build 17077)\n" |
|
||||
|
|
||||
#. module: web_translate_dialog |
|
||||
#. openerp-web |
|
||||
#: code:addons/web_translate_dialog/static/src/js/web_translate_dialog.js:15 |
|
||||
#, python-format |
|
||||
msgid "Translate" |
|
||||
msgstr "Çeviri" |
|
||||
|
|
||||
#. module: web_translate_dialog |
|
||||
#. openerp-web |
|
||||
#: code:addons/web_translate_dialog/static/src/js/web_translate_dialog.js:37 |
|
||||
#, python-format |
|
||||
msgid "Translations" |
|
||||
msgstr "daha çevrilmedi" |
|
||||
|
|
||||
#. module: web_translate_dialog |
|
||||
#. openerp-web |
|
||||
#: code:addons/web_translate_dialog/static/src/xml/base.xml:7 |
|
||||
#, python-format |
|
||||
msgid "Field" |
|
||||
msgstr "Alan" |
|
@ -1,36 +0,0 @@ |
|||||
# Translation of OpenERP Server. |
|
||||
# This file contains the translation of the following modules: |
|
||||
# |
|
||||
msgid "" |
|
||||
msgstr "" |
|
||||
"Project-Id-Version: OpenERP Server 7.0\n" |
|
||||
"Report-Msgid-Bugs-To: \n" |
|
||||
"POT-Creation-Date: 2013-12-09 07:15+0000\n" |
|
||||
"PO-Revision-Date: 2013-12-09 07:15+0000\n" |
|
||||
"Last-Translator: <>\n" |
|
||||
"Language-Team: \n" |
|
||||
"MIME-Version: 1.0\n" |
|
||||
"Content-Type: text/plain; charset=UTF-8\n" |
|
||||
"Content-Transfer-Encoding: \n" |
|
||||
"Plural-Forms: \n" |
|
||||
|
|
||||
#. module: web_translate_dialog |
|
||||
#. openerp-web |
|
||||
#: code:addons/web_translate_dialog/static/src/js/web_translate_dialog.js:15 |
|
||||
#, python-format |
|
||||
msgid "Translate" |
|
||||
msgstr "" |
|
||||
|
|
||||
#. module: web_translate_dialog |
|
||||
#. openerp-web |
|
||||
#: code:addons/web_translate_dialog/static/src/js/web_translate_dialog.js:37 |
|
||||
#, python-format |
|
||||
msgid "Translations" |
|
||||
msgstr "" |
|
||||
|
|
||||
#. module: web_translate_dialog |
|
||||
#. openerp-web |
|
||||
#: code:addons/web_translate_dialog/static/src/xml/base.xml:7 |
|
||||
#, python-format |
|
||||
msgid "Field" |
|
||||
msgstr "" |
|
@ -1,6 +0,0 @@ |
|||||
.openerp .oe_translation_field { |
|
||||
width: 95%; |
|
||||
} |
|
||||
.openerp .oe_translation_field.touched { |
|
||||
border: 1px solid green !important; |
|
||||
} |
|
@ -1,209 +0,0 @@ |
|||||
openerp.web_translate_dialog = function (instance) { |
|
||||
|
|
||||
"use strict"; |
|
||||
|
|
||||
var QWeb = instance.web.qweb, |
|
||||
_t = instance.web._t, |
|
||||
_lt = instance.web._lt; |
|
||||
|
|
||||
instance.web.FormView.include({ |
|
||||
load_form: function(data) { |
|
||||
var self = this; |
|
||||
this._super(data); |
|
||||
if (this.sidebar) { |
|
||||
this.sidebar.add_items('other', _.compact([ |
|
||||
self.is_action_enabled('edit') && { label: _t('Translate'), callback: self.on_button_translate }, |
|
||||
])); |
|
||||
} |
|
||||
}, |
|
||||
on_button_translate: function() { |
|
||||
var self = this; |
|
||||
$.when(this.has_been_loaded).then(function() { |
|
||||
self.open_translate_dialog(this); |
|
||||
}); |
|
||||
}, |
|
||||
}); |
|
||||
|
|
||||
instance.web.View.include({ |
|
||||
open_translate_dialog: function() { |
|
||||
new instance.web_translate_dialog.TranslateDialog(this).open(); |
|
||||
} |
|
||||
}); |
|
||||
|
|
||||
instance.web_translate_dialog.TranslateDialog = instance.web.Dialog.extend({ |
|
||||
template: "TranslateDialog", |
|
||||
init: function(parent, options, content) { |
|
||||
this._super(parent, |
|
||||
{title: _t("Translations"), |
|
||||
width: '90%', |
|
||||
height: '80%'}, |
|
||||
content); |
|
||||
this.view_language = this.session.user_context.lang; |
|
||||
this.view = parent; |
|
||||
this.view_type = parent.fields_view.type || ''; |
|
||||
this.$view_form = null; |
|
||||
this.$sidebar_form = null; |
|
||||
this.translatable_fields_keys = _.map(this.view.translatable_fields || [], function(i) { return i.name;}); |
|
||||
this.languages = null; |
|
||||
this.languages_loaded = $.Deferred(); |
|
||||
(new instance.web.DataSetSearch(this, |
|
||||
'res.lang', |
|
||||
this.view.dataset.get_context(), |
|
||||
[['translatable', '=', '1']])) |
|
||||
.read_slice(['code', 'name'], { sort: 'id' }) |
|
||||
.then(this.on_languages_loaded); |
|
||||
}, |
|
||||
on_languages_loaded: function(langs) { |
|
||||
this.languages = langs; |
|
||||
this.languages_loaded.resolve(); |
|
||||
}, |
|
||||
open: function() { |
|
||||
var self = this, |
|
||||
sup = this._super; |
|
||||
// the template needs the languages
|
|
||||
$.when(this.languages_loaded).then(function() { |
|
||||
return sup.call(self); |
|
||||
}); |
|
||||
}, |
|
||||
start: function() { |
|
||||
var self = this; |
|
||||
this.$el.find('.oe_translation_field').change(function() { |
|
||||
$(this).toggleClass('touched', ($(this).val() != $(this).attr('data-value'))); |
|
||||
}); |
|
||||
this.$buttons.html(QWeb.render("TranslateDialog.buttons")); |
|
||||
this.$buttons.find(".oe_form_translate_dialog_save_button").click(function(){ |
|
||||
self.on_button_save(); |
|
||||
self.on_button_close(); |
|
||||
}); |
|
||||
this.$buttons.find(".oe_form_translate_dialog_cancel_button").click(function(){ |
|
||||
self.on_button_close(); |
|
||||
}); |
|
||||
this.initialize_html_fields(); |
|
||||
|
|
||||
this.do_load_fields_values(); |
|
||||
}, |
|
||||
initialize_html_fields: function() { |
|
||||
this.$el.find('.oe_form_field_html textarea').each(function() { |
|
||||
var $textarea = $(this); |
|
||||
var width = 100; // forced to fixed size on initialization
|
|
||||
// will be changed to percentage right after
|
|
||||
// the creation
|
|
||||
var height = 250; |
|
||||
$textarea.cleditor({ |
|
||||
width: width, // width not including margins, borders or padding
|
|
||||
height: height, // height not including margins, borders or padding
|
|
||||
controls: // controls to add to the toolbar
|
|
||||
"bold italic underline strikethrough " + |
|
||||
"| removeformat | bullets numbering | outdent " + |
|
||||
"indent | link unlink | source", |
|
||||
bodyStyle: // style to assign to document body contained within the editor
|
|
||||
"margin:4px; color:#4c4c4c; font-size:13px; font-family:'Lucida Grande',Helvetica,Verdana,Arial,sans-serif; cursor:text" |
|
||||
}); |
|
||||
|
|
||||
var $cleditor = $textarea.cleditor()[0]; |
|
||||
// Down to -- end, this is a workaround for the bug
|
|
||||
// https://bugs.launchpad.net/openerp-web/+bug/1258463
|
|
||||
// The editor is initially created with a fixed size so
|
|
||||
// the buggy event is not bound to $(window), then we restore
|
|
||||
// a percentage width and bind the "normal" event without the
|
|
||||
// CHM's buggy change.
|
|
||||
$cleditor.$main.width('95%'); |
|
||||
$cleditor.options.width = '95%'; |
|
||||
$(window).resize(function() { |
|
||||
//Forcefully blurred iframe contentWindow, chrome, IE, safari doesn't trigger blur on window resize and due to which text disappears
|
|
||||
var contentWindow = $cleditor.$frame[0].contentWindow; |
|
||||
if(!$.browser.mozilla && contentWindow){ |
|
||||
$(contentWindow).trigger('blur'); |
|
||||
} |
|
||||
}); |
|
||||
$cleditor.refresh(); |
|
||||
// -- end
|
|
||||
|
|
||||
$cleditor.change(function() { |
|
||||
this.updateTextArea(); |
|
||||
this.$area.toggleClass('touched', |
|
||||
(this.$area.val() != this.$area.attr('data-value'))); |
|
||||
}); |
|
||||
}); |
|
||||
}, |
|
||||
set_fields_values: function(lang, values) { |
|
||||
var self = this; |
|
||||
_.each(this.translatable_fields_keys, function(f) { |
|
||||
self.$el.find('.oe_translation_field[name="' + lang.code + '-' + f + '"]') |
|
||||
.val(values[f] || '') |
|
||||
.attr('data-value', values[f] || ''); |
|
||||
|
|
||||
var $tarea = self.$el.find('.oe_form_field_html .oe_translation_field[name="' + lang.code + '-' + f + '"]'); |
|
||||
if ($tarea.length) { |
|
||||
$tarea.cleditor()[0].updateFrame(); |
|
||||
} |
|
||||
}); |
|
||||
var $textarea = this.$el.find('textarea.oe_translation_field'); |
|
||||
$textarea.css({minHeight:'100px'}); |
|
||||
$textarea.autosize(); |
|
||||
$(window).resize(); // triggers the autosize
|
|
||||
}, |
|
||||
do_load_fields_values: function() { |
|
||||
var self = this, |
|
||||
deferred = []; |
|
||||
|
|
||||
this.$el.find('.oe_translation_field').val('').removeClass('touched'); |
|
||||
_.each(self.languages, function(lg) { |
|
||||
var deff = $.Deferred(); |
|
||||
deferred.push(deff); |
|
||||
if (lg.code === self.view_language) { |
|
||||
var values = {}; |
|
||||
_.each(self.translatable_fields_keys, function(field) { |
|
||||
values[field] = self.view.fields[field].get_value(); |
|
||||
}); |
|
||||
self.set_fields_values(lg, values); |
|
||||
deff.resolve(); |
|
||||
} else { |
|
||||
self.view.dataset.call( |
|
||||
'read', |
|
||||
[[self.view.datarecord.id], |
|
||||
self.translatable_fields_keys, |
|
||||
self.view.dataset.get_context({ |
|
||||
'lang': lg.code |
|
||||
})]).done(function (rows) { |
|
||||
self.set_fields_values(lg, rows[0]); |
|
||||
deff.resolve(); |
|
||||
}); |
|
||||
}; |
|
||||
}); |
|
||||
return deferred; |
|
||||
}, |
|
||||
on_button_save: function() { |
|
||||
var translations = {}, |
|
||||
self = this, |
|
||||
translation_mutex = new $.Mutex(); |
|
||||
self.$el.find('.oe_translation_field.touched').each(function() { |
|
||||
var field = $(this).attr('name').split('-'); |
|
||||
if (!translations[field[0]]) { |
|
||||
translations[field[0]] = {}; |
|
||||
} |
|
||||
translations[field[0]][field[1]] = $(this).val(); |
|
||||
}); |
|
||||
_.each(translations, function(data, code) { |
|
||||
if (code === self.view_language) { |
|
||||
self.view.set_values(data); |
|
||||
} |
|
||||
translation_mutex.exec(function() { |
|
||||
return new instance.web.DataSet(self, self.view.dataset.model, self.view.dataset.get_context()).write(self.view.datarecord.id, data, { context : { 'lang': code }}); |
|
||||
}); |
|
||||
}); |
|
||||
this.close(); |
|
||||
}, |
|
||||
on_button_close: function() { |
|
||||
this.close(); |
|
||||
}, |
|
||||
|
|
||||
}); |
|
||||
|
|
||||
instance.web.form.AbstractField.include({ |
|
||||
on_translate: function() { |
|
||||
// the image next to the fields opens the translate dialog
|
|
||||
this.view.open_translate_dialog(); |
|
||||
}, |
|
||||
}); |
|
||||
}; |
|
@ -1,34 +0,0 @@ |
|||||
<templates> |
|
||||
|
|
||||
<t t-name="TranslateDialog"> |
|
||||
<table t-if="widget.view.translatable_fields" class="oe_frame oe_forms oe_translation_form" border="0" cellpadding="0" cellspacing="0" width="100%"> |
|
||||
<tr> |
|
||||
<td class="oe_form_separator" width="1%" nowrap="nowrap"> |
|
||||
<div class="separator horizontal">Field</div> |
|
||||
</td> |
|
||||
<th t-foreach="widget.languages" align="left"> |
|
||||
<div class="separator horizontal"><t t-esc="name"/></div> |
|
||||
</th> |
|
||||
</tr> |
|
||||
<tr t-foreach="widget.view.translatable_fields" t-as="field" t-att-data-field="field.name"> |
|
||||
<td class="oe_form_frame_cell" width="1%" nowrap="nowrap"> |
|
||||
<label class="oe_label"><t t-esc="field.string"/>:</label> |
|
||||
</td> |
|
||||
<td t-foreach="widget.languages" t-as="lg" class="oe_form_frame_cell"> |
|
||||
<input t-if="field.field.type == 'char' || field.field.type == 'url'" type="text" t-attf-name="#{lg.code}-#{field.name}" value="" data-value="" class="oe_translation_field"/> |
|
||||
<textarea t-if="field.field.type == 'text'" t-attf-name="#{lg.code}-#{field.name}" data-value="" class="oe_translation_field" ></textarea> |
|
||||
<div t-if="field.field.type == 'html'" class="oe_form_field_html"> |
|
||||
<textarea class="oe_translation_field oe_form_field" t-attf-name="#{lg.code}-#{field.name}" data-value=""/> |
|
||||
</div> |
|
||||
</td> |
|
||||
</tr> |
|
||||
</table> |
|
||||
</t> |
|
||||
|
|
||||
<t t-name="TranslateDialog.buttons"> |
|
||||
<button class="oe_form_translate_dialog_save_button oe_button oe_highlight">Save</button> |
|
||||
<button class="oe_form_translate_dialog_cancel_button oe_button">Cancel</button> |
|
||||
</t> |
|
||||
|
|
||||
</templates> |
|
||||
|
|
Write
Preview
Loading…
Cancel
Save
Reference in new issue