Merge lp:~camptocamp/web-addons/7.0-web_translate_dialog_page into lp:~webaddons-core-editors/web-addons/7.0
- 7.0-web_translate_dialog_page
- Merge into 7.0
Status: | Merged |
---|---|
Approved by: | Pedro Manuel Baeza |
Approved revision: | 33 |
Merged at revision: | 20 |
Proposed branch: | lp:~camptocamp/web-addons/7.0-web_translate_dialog_page |
Merge into: | lp:~webaddons-core-editors/web-addons/7.0 |
Diff against target: |
450 lines (+404/-0) 8 files modified
web_translate_dialog/__init__.py (+1/-0) web_translate_dialog/__openerp__.py (+44/-0) web_translate_dialog/i18n/es.po (+36/-0) web_translate_dialog/i18n/fr.po (+36/-0) web_translate_dialog/i18n/web_translate_dialog.pot (+36/-0) web_translate_dialog/static/src/css/base.css (+6/-0) web_translate_dialog/static/src/js/web_translate_dialog.js (+211/-0) web_translate_dialog/static/src/xml/base.xml (+34/-0) |
To merge this branch: | bzr merge lp:~camptocamp/web-addons/7.0-web_translate_dialog_page |
Related bugs: |
Reviewer | Review Type | Date Requested | Status |
---|---|---|---|
Pedro Manuel Baeza | code review and test | Approve | |
Holger Brunn (Therp) | code review | Approve | |
Joël Grand-Guillaume @ camptocamp | code review, no tests | Approve | |
Review via email: mp+198063@code.launchpad.net |
Commit message
[ADD] web_translate_
Description of the change
Hello,
Here is a replacement for the translations, restoring a dialog more or less like the 6.1 one.
It also support the HTML fields.
Pedro Manuel Baeza (pedro.baeza) wrote : | # |
- 28. By Guewen Baconnier @ Camptocamp
-
[FIX] display title
- 29. By Guewen Baconnier @ Camptocamp
-
[ADD] pot file
Guewen Baconnier @ Camptocamp (gbaconnier-c2c) wrote : | # |
Thanks for the test and review.
Regarding the scrollbar, it happens only on Chrome, and not on Firefox. I have to admit that I have no idea how to fix that.
I included the .pot file, but the only term that should be translated ('Translations') does not appear in the file.
Does anyone have an idea for theses 2 issues?
Joël Grand-Guillaume @ camptocamp (jgrandguillaume-c2c) wrote : | # |
Hi,
Unfortunately, I do not have any idea about those 2 troubles. I've tested the solution and it really works like a charm. I had the same trouble than Pedro reported on Chrome, but no idea why... Though the mouse wheel does the trick, so I see no reason to block that MP.
That's why I'm approving it.
Pedro Manuel Baeza (pedro.baeza) wrote : | # |
I have manually extracted translatable strings and make an MP with the corresponding files: https:/
There's is another last thing that it would be desirable to have to complete i18n: languages appear in english and in the native language, but not in the interface language. This can be for the context passed to the method that retrieves res.lang, but I have tried to change it and I got lost on JS code. Can you please see if you can improve this?
Thank you.
Regards.
- 30. By Pedro Manuel Baeza
-
[IMP] Translations files
- 31. By Guewen Baconnier @ Camptocamp
-
[ADD] fr translation
Guewen Baconnier @ Camptocamp (gbaconnier-c2c) wrote : | # |
> I have manually extracted translatable strings and make an MP with the
> corresponding files: https:/
> addons/
>
Thanks for the translation files, that's great. I added the french translation as well.
> There's is another last thing that it would be desirable to have to complete
> i18n: languages appear in english and in the native language, but not in the
> interface language. This can be for the context passed to the method that
> retrieves res.lang, but I have tried to change it and I got lost on JS code.
> Can you please see if you can improve this?
What do you mean by interface language?
Actually, it displays all the languages having the "translatable" boolean to True.
Pedro Manuel Baeza (pedro.baeza) wrote : | # |
I mean that in my interface (spanish) it appears:
English , Spanish/Español, French/Français, German/Deutsch ...
That it's to say: Language in english/Language in native language, where it should be:
Inglés/English, Español, Francés,/Français, Alemán/Deutsch ...
Do you understand me now?
Regards.
Guewen Baconnier @ Camptocamp (gbaconnier-c2c) wrote : | # |
> I mean that in my interface (spanish) it appears:
>
> English , Spanish/Español, French/Français, German/Deutsch ...
>
> That it's to say: Language in english/Language in native language, where it
> should be:
>
> Inglés/English, Español, Francés,/Français, Alemán/Deutsch ...
>
> Do you understand me now?
>
> Regards.
Oh yes I got you, thanks for the precision. I first understood that a language *column* was missing ;-)
I will check that.
Holger Brunn (Therp) (hbrunn) wrote : | # |
small nits:
#368, #370: trad* seem to be frenchisms to me, maybe change that to 'translation'?
- 32. By Guewen Baconnier @ Camptocamp
-
merge from main
Guewen Baconnier @ Camptocamp (gbaconnier-c2c) wrote : | # |
> I mean that in my interface (spanish) it appears:
>
> English , Spanish/Español, French/Français, German/Deutsch ...
>
> That it's to say: Language in english/Language in native language, where it
> should be:
>
> Inglés/English, Español, Francés,/Français, Alemán/Deutsch ...
>
> Do you understand me now?
>
> Regards.
I checked this remark that I kept overdue for too long time.
In fact this has nothing to do with the translations.
The name on the top of the column is `res_lang.name` that is *not* a translatable field. I think that's why OpenERP put things like Spanish/Español. This is an issue that is global to OpenERP and I won't fix it there.
In my case I renamed the languages to appear only in the language's language (English / Français / Deutsch).
Can you review again so we can move forward with this proposal? Thanks
- 33. By Guewen Baconnier @ Camptocamp
-
Rename the frenchisms 'word' trads to translation
Guewen Baconnier @ Camptocamp (gbaconnier-c2c) wrote : | # |
> small nits:
>
> #368, #370: trad* seem to be frenchisms to me, maybe change that to
> 'translation'?
For sure. That's done.
Guewen Baconnier @ Camptocamp (gbaconnier-c2c) wrote : | # |
Pedro, you still have a Needs Fixing vote. Can you review again please?
Pedro Manuel Baeza (pedro.baeza) wrote : | # |
Sorry, you have my approval, because there's nothing we can do with language names as you have remarked.
I'm going to proceed with the merge.
Thanks again for this contribution.
Regards.
Preview Diff
1 | === added directory 'web_translate_dialog' |
2 | === added file 'web_translate_dialog/__init__.py' |
3 | --- web_translate_dialog/__init__.py 1970-01-01 00:00:00 +0000 |
4 | +++ web_translate_dialog/__init__.py 2014-02-25 14:30:24 +0000 |
5 | @@ -0,0 +1,1 @@ |
6 | +# -*- coding: utf-8 -*- |
7 | |
8 | === added file 'web_translate_dialog/__openerp__.py' |
9 | --- web_translate_dialog/__openerp__.py 1970-01-01 00:00:00 +0000 |
10 | +++ web_translate_dialog/__openerp__.py 2014-02-25 14:30:24 +0000 |
11 | @@ -0,0 +1,44 @@ |
12 | +# -*- coding: utf-8 -*- |
13 | +############################################################################## |
14 | +# |
15 | +# Author: Guewen Baconnier |
16 | +# Copyright 2012 Camptocamp SA |
17 | +# |
18 | +# This program is free software: you can redistribute it and/or modify |
19 | +# it under the terms of the GNU Affero General Public License as |
20 | +# published by the Free Software Foundation, either version 3 of the |
21 | +# License, or (at your option) any later version. |
22 | +# |
23 | +# This program is distributed in the hope that it will be useful, |
24 | +# but WITHOUT ANY WARRANTY; without even the implied warranty of |
25 | +# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the |
26 | +# GNU Affero General Public License for more details. |
27 | +# |
28 | +# You should have received a copy of the GNU Affero General Public License |
29 | +# along with this program. If not, see <http://www.gnu.org/licenses/>. |
30 | +# |
31 | +############################################################################## |
32 | + |
33 | +{"name": "Web Translate Dialog", |
34 | + "category": "Hidden", |
35 | + "description": """ |
36 | +Replace the standard translation view by an alternative one: |
37 | + |
38 | + * Add a "Translate" button item in the "More" menu |
39 | + * The translations are displayed in a dialog (much like the OpenERP |
40 | + 6.1's one) |
41 | + * Support HTML fields |
42 | + * Autosize the textareas to the size of the content |
43 | + |
44 | +""", |
45 | + "version": "1.0", |
46 | + "depends": ['web', |
47 | + ], |
48 | + 'js': ['static/src/js/web_translate_dialog.js', |
49 | + ], |
50 | + 'css': ['static/src/css/base.css', |
51 | + ], |
52 | + 'qweb': ["static/src/xml/base.xml", |
53 | + ], |
54 | + 'auto_install': False, |
55 | + } |
56 | |
57 | === added directory 'web_translate_dialog/i18n' |
58 | === added file 'web_translate_dialog/i18n/es.po' |
59 | --- web_translate_dialog/i18n/es.po 1970-01-01 00:00:00 +0000 |
60 | +++ web_translate_dialog/i18n/es.po 2014-02-25 14:30:24 +0000 |
61 | @@ -0,0 +1,36 @@ |
62 | +# Translation of OpenERP Server. |
63 | +# This file contains the translation of the following modules: |
64 | +# |
65 | +msgid "" |
66 | +msgstr "" |
67 | +"Project-Id-Version: OpenERP Server 7.0\n" |
68 | +"Report-Msgid-Bugs-To: \n" |
69 | +"POT-Creation-Date: 2013-12-09 07:15+0000\n" |
70 | +"PO-Revision-Date: 2013-12-13 14:09+0100\n" |
71 | +"Last-Translator: Pedro Manuel Baeza <pedro.baeza@serviciosbaeza.com>\n" |
72 | +"Language-Team: \n" |
73 | +"MIME-Version: 1.0\n" |
74 | +"Content-Type: text/plain; charset=UTF-8\n" |
75 | +"Content-Transfer-Encoding: 8bit\n" |
76 | +"Plural-Forms: \n" |
77 | + |
78 | +#. module: web_translate_dialog |
79 | +#. openerp-web |
80 | +#: code:addons/web_translate_dialog/static/src/js/web_translate_dialog.js:15 |
81 | +#, python-format |
82 | +msgid "Translate" |
83 | +msgstr "Traducir" |
84 | + |
85 | +#. module: web_translate_dialog |
86 | +#. openerp-web |
87 | +#: code:addons/web_translate_dialog/static/src/js/web_translate_dialog.js:37 |
88 | +#, python-format |
89 | +msgid "Translations" |
90 | +msgstr "Traducciones" |
91 | + |
92 | +#. module: web_translate_dialog |
93 | +#. openerp-web |
94 | +#: code:addons/web_translate_dialog/static/src/xml/base.xml:7 |
95 | +#, python-format |
96 | +msgid "Field" |
97 | +msgstr "Campo" |
98 | |
99 | === added file 'web_translate_dialog/i18n/fr.po' |
100 | --- web_translate_dialog/i18n/fr.po 1970-01-01 00:00:00 +0000 |
101 | +++ web_translate_dialog/i18n/fr.po 2014-02-25 14:30:24 +0000 |
102 | @@ -0,0 +1,36 @@ |
103 | +# Translation of OpenERP Server. |
104 | +# This file contains the translation of the following modules: |
105 | +# |
106 | +msgid "" |
107 | +msgstr "" |
108 | +"Project-Id-Version: OpenERP Server 7.0\n" |
109 | +"Report-Msgid-Bugs-To: \n" |
110 | +"POT-Creation-Date: 2013-12-09 07:15+0000\n" |
111 | +"PO-Revision-Date: 2013-12-18 09:41+0100\n" |
112 | +"Last-Translator: Guewen Baconnier <guewen.baconnier@camptocamp.com>\n" |
113 | +"Language-Team: \n" |
114 | +"MIME-Version: 1.0\n" |
115 | +"Content-Type: text/plain; charset=UTF-8\n" |
116 | +"Content-Transfer-Encoding: 8bit\n" |
117 | +"Plural-Forms: \n" |
118 | + |
119 | +#. module: web_translate_dialog |
120 | +#. openerp-web |
121 | +#: code:addons/web_translate_dialog/static/src/js/web_translate_dialog.js:15 |
122 | +#, python-format |
123 | +msgid "Translate" |
124 | +msgstr "Traduire" |
125 | + |
126 | +#. module: web_translate_dialog |
127 | +#. openerp-web |
128 | +#: code:addons/web_translate_dialog/static/src/js/web_translate_dialog.js:37 |
129 | +#, python-format |
130 | +msgid "Translations" |
131 | +msgstr "Traductions" |
132 | + |
133 | +#. module: web_translate_dialog |
134 | +#. openerp-web |
135 | +#: code:addons/web_translate_dialog/static/src/xml/base.xml:7 |
136 | +#, python-format |
137 | +msgid "Field" |
138 | +msgstr "Champ" |
139 | |
140 | === added file 'web_translate_dialog/i18n/web_translate_dialog.pot' |
141 | --- web_translate_dialog/i18n/web_translate_dialog.pot 1970-01-01 00:00:00 +0000 |
142 | +++ web_translate_dialog/i18n/web_translate_dialog.pot 2014-02-25 14:30:24 +0000 |
143 | @@ -0,0 +1,36 @@ |
144 | +# Translation of OpenERP Server. |
145 | +# This file contains the translation of the following modules: |
146 | +# |
147 | +msgid "" |
148 | +msgstr "" |
149 | +"Project-Id-Version: OpenERP Server 7.0\n" |
150 | +"Report-Msgid-Bugs-To: \n" |
151 | +"POT-Creation-Date: 2013-12-09 07:15+0000\n" |
152 | +"PO-Revision-Date: 2013-12-09 07:15+0000\n" |
153 | +"Last-Translator: <>\n" |
154 | +"Language-Team: \n" |
155 | +"MIME-Version: 1.0\n" |
156 | +"Content-Type: text/plain; charset=UTF-8\n" |
157 | +"Content-Transfer-Encoding: \n" |
158 | +"Plural-Forms: \n" |
159 | + |
160 | +#. module: web_translate_dialog |
161 | +#. openerp-web |
162 | +#: code:addons/web_translate_dialog/static/src/js/web_translate_dialog.js:15 |
163 | +#, python-format |
164 | +msgid "Translate" |
165 | +msgstr "" |
166 | + |
167 | +#. module: web_translate_dialog |
168 | +#. openerp-web |
169 | +#: code:addons/web_translate_dialog/static/src/js/web_translate_dialog.js:37 |
170 | +#, python-format |
171 | +msgid "Translations" |
172 | +msgstr "" |
173 | + |
174 | +#. module: web_translate_dialog |
175 | +#. openerp-web |
176 | +#: code:addons/web_translate_dialog/static/src/xml/base.xml:7 |
177 | +#, python-format |
178 | +msgid "Field" |
179 | +msgstr "" |
180 | |
181 | === added directory 'web_translate_dialog/static' |
182 | === added directory 'web_translate_dialog/static/src' |
183 | === added directory 'web_translate_dialog/static/src/css' |
184 | === added file 'web_translate_dialog/static/src/css/base.css' |
185 | --- web_translate_dialog/static/src/css/base.css 1970-01-01 00:00:00 +0000 |
186 | +++ web_translate_dialog/static/src/css/base.css 2014-02-25 14:30:24 +0000 |
187 | @@ -0,0 +1,6 @@ |
188 | +.openerp .oe_translation_field { |
189 | + width: 95%; |
190 | +} |
191 | +.openerp .oe_translation_field.touched { |
192 | + border: 1px solid green !important; |
193 | +} |
194 | |
195 | === added directory 'web_translate_dialog/static/src/js' |
196 | === added file 'web_translate_dialog/static/src/js/web_translate_dialog.js' |
197 | --- web_translate_dialog/static/src/js/web_translate_dialog.js 1970-01-01 00:00:00 +0000 |
198 | +++ web_translate_dialog/static/src/js/web_translate_dialog.js 2014-02-25 14:30:24 +0000 |
199 | @@ -0,0 +1,211 @@ |
200 | +openerp.web_translate_dialog = function (instance) { |
201 | + |
202 | + "use strict"; |
203 | + |
204 | + var QWeb = instance.web.qweb, |
205 | + _t = instance.web._t, |
206 | + _lt = instance.web._lt; |
207 | + |
208 | + instance.web.FormView.include({ |
209 | + load_form: function(data) { |
210 | + var self = this; |
211 | + this._super(data); |
212 | + if (this.sidebar) { |
213 | + this.sidebar.add_items('other', _.compact([ |
214 | + self.is_action_enabled('edit') && { label: _t('Translate'), callback: self.on_button_translate }, |
215 | + ])); |
216 | + } |
217 | + }, |
218 | + on_button_translate: function() { |
219 | + var self = this; |
220 | + $.when(this.has_been_loaded).then(function() { |
221 | + self.open_translate_dialog(this); |
222 | + }); |
223 | + }, |
224 | + }); |
225 | + |
226 | + instance.web.View.include({ |
227 | + open_translate_dialog: function() { |
228 | + new instance.web_translate_dialog.TranslateDialog(this).open(); |
229 | + } |
230 | + }); |
231 | + |
232 | + instance.web_translate_dialog.TranslateDialog = instance.web.Dialog.extend({ |
233 | + template: "TranslateDialog", |
234 | + init: function(parent, options, content) { |
235 | + this._super(parent, |
236 | + {title: _t("Translations"), |
237 | + width: '90%', |
238 | + height: '80%'}, |
239 | + content); |
240 | + this.view_language = this.session.user_context.lang; |
241 | + this.view = parent; |
242 | + this.view_type = parent.fields_view.type || ''; |
243 | + this.$view_form = null; |
244 | + this.$sidebar_form = null; |
245 | + this.translatable_fields_keys = _.map(this.view.translatable_fields || [], function(i) { return i.name;}); |
246 | + this.languages = null; |
247 | + this.languages_loaded = $.Deferred(); |
248 | + (new instance.web.DataSetSearch(this, |
249 | + 'res.lang', |
250 | + this.view.dataset.get_context(), |
251 | + [['translatable', '=', '1']])) |
252 | + .read_slice(['code', 'name'], { sort: 'id' }) |
253 | + .then(this.on_languages_loaded); |
254 | + }, |
255 | + on_languages_loaded: function(langs) { |
256 | + this.languages = langs; |
257 | + this.languages_loaded.resolve(); |
258 | + }, |
259 | + open: function() { |
260 | + var self = this, |
261 | + sup = this._super; |
262 | + // the template needs the languages |
263 | + $.when(this.languages_loaded).then(function() { |
264 | + return sup.call(self); |
265 | + }); |
266 | + }, |
267 | + start: function() { |
268 | + var self = this; |
269 | + this.$el.find('.oe_translation_field').change(function() { |
270 | + $(this).toggleClass('touched', ($(this).val() != $(this).attr('data-value'))); |
271 | + }); |
272 | + this.$buttons.html(QWeb.render("TranslateDialog.buttons")); |
273 | + this.$buttons.find(".oe_form_translate_dialog_save_button").click(function(){ |
274 | + self.on_button_save(); |
275 | + self.on_button_close(); |
276 | + }); |
277 | + this.$buttons.find(".oe_form_translate_dialog_cancel_button").click(function(){ |
278 | + self.on_button_close(); |
279 | + }); |
280 | + this.initialize_html_fields(); |
281 | + |
282 | + this.do_load_fields_values(); |
283 | + }, |
284 | + initialize_html_fields: function() { |
285 | + this.$el.find('.oe_form_field_html textarea').each(function() { |
286 | + var $textarea = $(this); |
287 | + var width = 100; // forced to fixed size on initialization |
288 | + // will be changed to percentage right after |
289 | + // the creation |
290 | + var height = 250; |
291 | + $textarea.cleditor({ |
292 | + width: width, // width not including margins, borders or padding |
293 | + height: height, // height not including margins, borders or padding |
294 | + controls: // controls to add to the toolbar |
295 | + "bold italic underline strikethrough " + |
296 | + "| removeformat | bullets numbering | outdent " + |
297 | + "indent | link unlink | source", |
298 | + bodyStyle: // style to assign to document body contained within the editor |
299 | + "margin:4px; color:#4c4c4c; font-size:13px; font-family:'Lucida Grande',Helvetica,Verdana,Arial,sans-serif; cursor:text" |
300 | + }); |
301 | + |
302 | + var $cleditor = $textarea.cleditor()[0]; |
303 | + // Down to -- end, this is a workaround for the bug |
304 | + // https://bugs.launchpad.net/openerp-web/+bug/1258463 |
305 | + // The editor is initially created with a fixed size so |
306 | + // the buggy event is not bound to $(window), then we restore |
307 | + // a percentage width and bind the "normal" event without the |
308 | + // CHM's buggy change. |
309 | + $cleditor.$main.width('95%'); |
310 | + $cleditor.options.width = '95%'; |
311 | + $(window).resize(function() { |
312 | + //Forcefully blurred iframe contentWindow, chrome, IE, safari doesn't trigger blur on window resize and due to which text disappears |
313 | + var contentWindow = $cleditor.$frame[0].contentWindow; |
314 | + if(!$.browser.mozilla && contentWindow){ |
315 | + $(contentWindow).trigger('blur'); |
316 | + } |
317 | + }); |
318 | + $cleditor.refresh(); |
319 | + // -- end |
320 | + |
321 | + $cleditor.change(function() { |
322 | + this.updateTextArea(); |
323 | + this.$area.toggleClass('touched', |
324 | + (this.$area.val() != this.$area.attr('data-value'))); |
325 | + }); |
326 | + }); |
327 | + }, |
328 | + // use a `read_translations` method instead of a `read` |
329 | + // this latter leave the fields empty if there is no |
330 | + // translation for a field instead of taking the src field |
331 | + do_load_fields_values: function(callback) { |
332 | + var self = this, |
333 | + deferred = []; |
334 | + |
335 | + this.$el.find('.oe_translation_field').val('').removeClass('touched'); |
336 | + _.each(self.languages, function(lg) { |
337 | + var deff = $.Deferred(); |
338 | + deferred.push(deff); |
339 | + var callback = function(values) { |
340 | + }; |
341 | + self.view.dataset.call( |
342 | + 'read', |
343 | + [[self.view.datarecord.id], |
344 | + self.translatable_fields_keys, |
345 | + self.view.dataset.get_context({ |
346 | + 'lang': lg.code |
347 | + })]).done(function (values) { |
348 | + _.each(self.translatable_fields_keys, function(f) { |
349 | + self.$el.find('.oe_translation_field[name="' + lg.code + '-' + f + '"]') |
350 | + .val(values[0][f] || '') |
351 | + .attr('data-value', values[0][f] || ''); |
352 | + |
353 | + var $tarea = self.$el.find('.oe_form_field_html .oe_translation_field[name="' + lg.code + '-' + f + '"]'); |
354 | + if ($tarea.length) { |
355 | + $tarea.cleditor()[0].updateFrame(); |
356 | + } |
357 | + }); |
358 | + var $textarea = self.$el.find('textarea.oe_translation_field'); |
359 | + $textarea.css({minHeight:'100px'}); |
360 | + $textarea.autosize(); |
361 | + $(window).resize(); // triggers the autosize |
362 | + deff.resolve(); |
363 | + }); |
364 | + }); |
365 | + return deferred; |
366 | + }, |
367 | + on_button_save: function() { |
368 | + var translations = {}, |
369 | + self = this, |
370 | + translation_mutex = new $.Mutex(); |
371 | + self.$el.find('.oe_translation_field.touched').each(function() { |
372 | + var field = $(this).attr('name').split('-'); |
373 | + if (!translations[field[0]]) { |
374 | + translations[field[0]] = {}; |
375 | + } |
376 | + translations[field[0]][field[1]] = $(this).val(); |
377 | + }); |
378 | + _.each(translations, function(data, code) { |
379 | + if (code === self.view_language) { |
380 | + _.each(data, function(value, field) { |
381 | + var view_field = self.view.fields[field]; |
382 | + var is_dirty = view_field.view.$el.hasClass('oe_form_dirty'); |
383 | + // update the field on the view |
384 | + view_field.set_value(value); |
385 | + if ( !is_dirty ) { |
386 | + // Avoid to set the view dirty when not necessary: |
387 | + // values have already been saved. |
388 | + view_field.view.$el.removeClass('oe_form_dirty'); |
389 | + } |
390 | + }); |
391 | + } |
392 | + translation_mutex.exec(function() { |
393 | + return new instance.web.DataSet(self, self.view.dataset.model, self.view.dataset.get_context()).write(self.view.datarecord.id, data, { context : { 'lang': code }}); |
394 | + }); |
395 | + }); |
396 | + this.close(); |
397 | + }, |
398 | + on_button_close: function() { |
399 | + this.close(); |
400 | + }, |
401 | + |
402 | + }); |
403 | + |
404 | + instance.web.form.AbstractField.include({ |
405 | + on_translate: function() { |
406 | + // the image next to the fields opens the translate dialog |
407 | + this.view.open_translate_dialog(); |
408 | + }, |
409 | + }); |
410 | +}; |
411 | |
412 | === added directory 'web_translate_dialog/static/src/xml' |
413 | === added file 'web_translate_dialog/static/src/xml/base.xml' |
414 | --- web_translate_dialog/static/src/xml/base.xml 1970-01-01 00:00:00 +0000 |
415 | +++ web_translate_dialog/static/src/xml/base.xml 2014-02-25 14:30:24 +0000 |
416 | @@ -0,0 +1,34 @@ |
417 | +<templates> |
418 | + |
419 | + <t t-name="TranslateDialog"> |
420 | + <table t-if="widget.view.translatable_fields" class="oe_frame oe_forms oe_translation_form" border="0" cellpadding="0" cellspacing="0" width="100%"> |
421 | + <tr> |
422 | + <td class="oe_form_separator" width="1%" nowrap="nowrap"> |
423 | + <div class="separator horizontal">Field</div> |
424 | + </td> |
425 | + <th t-foreach="widget.languages" align="left"> |
426 | + <div class="separator horizontal"><t t-esc="name"/></div> |
427 | + </th> |
428 | + </tr> |
429 | + <tr t-foreach="widget.view.translatable_fields" t-as="field" t-att-data-field="field.name"> |
430 | + <td class="oe_form_frame_cell" width="1%" nowrap="nowrap"> |
431 | + <label class="oe_label"><t t-esc="field.string"/>:</label> |
432 | + </td> |
433 | + <td t-foreach="widget.languages" t-as="lg" class="oe_form_frame_cell"> |
434 | + <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"/> |
435 | + <textarea t-if="field.field.type == 'text'" t-attf-name="#{lg.code}-#{field.name}" data-value="" class="oe_translation_field" ></textarea> |
436 | + <div t-if="field.field.type == 'html'" class="oe_form_field_html"> |
437 | + <textarea class="oe_translation_field oe_form_field" t-attf-name="#{lg.code}-#{field.name}" data-value=""/> |
438 | + </div> |
439 | + </td> |
440 | + </tr> |
441 | + </table> |
442 | + </t> |
443 | + |
444 | + <t t-name="TranslateDialog.buttons"> |
445 | + <button class="oe_form_translate_dialog_save_button oe_button oe_highlight">Save</button> |
446 | + <button class="oe_form_translate_dialog_cancel_button oe_button">Cancel</button> |
447 | + </t> |
448 | + |
449 | +</templates> |
450 | + |
Guewen, what a great addition! I don't know why OpenERP changes this behaviour to an ugly one, but here it's again the community to fix it!
I have extensively tested the module and it seems to work perfectly (large texts, multiple translatable fields, three or more languages, etc). The only problem I have found is that when the height of the popup is higher than the screen height, it's not possible to make click on scrollbars. You can only scroll with the mouse scroll wheel. Is there any possibility to fix this? BTW, excelent job.
Another thing you can do is to include translation template file.
Regards.