Browse Source

Rename the frenchisms 'word' trads to translation

pull/4/head
Guewen Baconnier 11 years ago
parent
commit
b1e393ffc3
  1. 4
      web_translate_dialog/static/src/css/base.css
  2. 26
      web_translate_dialog/static/src/js/web_translate_dialog.js
  3. 6
      web_translate_dialog/static/src/xml/base.xml

4
web_translate_dialog/static/src/css/base.css

@ -1,6 +1,6 @@
.openerp .oe_trad_field {
.openerp .oe_translation_field {
width: 95%;
}
.openerp .oe_trad_field.touched {
.openerp .oe_translation_field.touched {
border: 1px solid green !important;
}

26
web_translate_dialog/static/src/js/web_translate_dialog.js

@ -67,7 +67,7 @@ openerp.web_translate_dialog = function (instance) {
},
start: function() {
var self = this;
this.$el.find('.oe_trad_field').change(function() {
this.$el.find('.oe_translation_field').change(function() {
$(this).toggleClass('touched', ($(this).val() != $(this).attr('data-value')));
});
this.$buttons.html(QWeb.render("TranslateDialog.buttons"));
@ -133,7 +133,7 @@ openerp.web_translate_dialog = function (instance) {
var self = this,
deferred = [];
this.$el.find('.oe_trad_field').val('').removeClass('touched');
this.$el.find('.oe_translation_field').val('').removeClass('touched');
_.each(self.languages, function(lg) {
var deff = $.Deferred();
deferred.push(deff);
@ -147,16 +147,16 @@ openerp.web_translate_dialog = function (instance) {
'lang': lg.code
})]).done(function (values) {
_.each(self.translatable_fields_keys, function(f) {
self.$el.find('.oe_trad_field[name="' + lg.code + '-' + f + '"]')
self.$el.find('.oe_translation_field[name="' + lg.code + '-' + f + '"]')
.val(values[0][f] || '')
.attr('data-value', values[0][f] || '');
var $tarea = self.$el.find('.oe_form_field_html .oe_trad_field[name="' + lg.code + '-' + f + '"]');
var $tarea = self.$el.find('.oe_form_field_html .oe_translation_field[name="' + lg.code + '-' + f + '"]');
if ($tarea.length) {
$tarea.cleditor()[0].updateFrame();
}
});
var $textarea = self.$el.find('textarea.oe_trad_field');
var $textarea = self.$el.find('textarea.oe_translation_field');
$textarea.css({minHeight:'100px'});
$textarea.autosize();
$(window).resize(); // triggers the autosize
@ -166,17 +166,17 @@ openerp.web_translate_dialog = function (instance) {
return deferred;
},
on_button_save: function() {
var trads = {},
var translations = {},
self = this,
trads_mutex = new $.Mutex();
self.$el.find('.oe_trad_field.touched').each(function() {
translation_mutex = new $.Mutex();
self.$el.find('.oe_translation_field.touched').each(function() {
var field = $(this).attr('name').split('-');
if (!trads[field[0]]) {
trads[field[0]] = {};
if (!translations[field[0]]) {
translations[field[0]] = {};
}
trads[field[0]][field[1]] = $(this).val();
translations[field[0]][field[1]] = $(this).val();
});
_.each(trads, function(data, code) {
_.each(translations, function(data, code) {
if (code === self.view_language) {
_.each(data, function(value, field) {
var view_field = self.view.fields[field];
@ -190,7 +190,7 @@ openerp.web_translate_dialog = function (instance) {
}
});
}
trads_mutex.exec(function() {
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 }});
});
});

6
web_translate_dialog/static/src/xml/base.xml

@ -15,10 +15,10 @@
<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_trad_field"/>
<textarea t-if="field.field.type == 'text'" t-attf-name="#{lg.code}-#{field.name}" data-value="" class="oe_trad_field" ></textarea>
<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_trad_field oe_form_field" t-attf-name="#{lg.code}-#{field.name}" data-value=""/>
<textarea class="oe_translation_field oe_form_field" t-attf-name="#{lg.code}-#{field.name}" data-value=""/>
</div>
</td>
</tr>

Loading…
Cancel
Save