summaryrefslogtreecommitdiff
path: root/addons/web/static/src/js/widgets/translation_dialog.js
diff options
context:
space:
mode:
authorMartin Trigaux <mat@odoo.com>2019-09-20 12:46:07 +0000
committerMartin Trigaux <mat@odoo.com>2019-09-24 15:52:55 +0000
commit2471ee506f38f5ca54d7bd54084b0ac3d74abeae (patch)
tree0f40dc99590d0c4d93da16e57ef3e170cb1de23b /addons/web/static/src/js/widgets/translation_dialog.js
parent5a9cb644147ee891e1afb3ddf88e052cdda7fb04 (diff)
[FIX] web: translate html fields
This commit fixes: - body of a email.template in a small field - translation of website_description of a product does not show the source of the translation - translation of website_description of a product shows the full content for the current language HTML fields are typically fields with longer of content. If the field is an HTML field, it should be displayed in a textarea, like the text fields. Most of HTML fields are split in meaningful chunks of content (using xml_translate or html_translate method). For these fields, the source must be displayed. Also sort the entries on the source to have a consistent order closes odoo/odoo#37215 Signed-off-by: Martin Trigaux (mat) <mat@odoo.com>
Diffstat (limited to 'addons/web/static/src/js/widgets/translation_dialog.js')
-rw-r--r--addons/web/static/src/js/widgets/translation_dialog.js13
1 files changed, 10 insertions, 3 deletions
diff --git a/addons/web/static/src/js/widgets/translation_dialog.js b/addons/web/static/src/js/widgets/translation_dialog.js
index 39d841a48d0..426ef68cb35 100644
--- a/addons/web/static/src/js/widgets/translation_dialog.js
+++ b/addons/web/static/src/js/widgets/translation_dialog.js
@@ -23,6 +23,7 @@ odoo.define('web.TranslationDialog', function (require) {
* @param {string} [options.dataPointID] the data point id of the record for which we do the translations
* @param {boolean} [options.isComingFromTranslationAlert] the initiator of the dialog, might be a link on a field or the translation alert on top of the form
* @param {boolean} [options.isText] is the field a text field (multiline) or char (single line)
+ * @param {boolean} [options.showSrc] is the source of the translation should be rendered (for partial translations, i.e. XML content)
*
*/
init: function (parent, options) {
@@ -37,6 +38,7 @@ odoo.define('web.TranslationDialog', function (require) {
this.isComingFromTranslationAlert = options.isComingFromTranslationAlert;
this.currentInterfaceLanguage = session.user_context.lang;
this.isText = options.isText;
+ this.showSrc = options.showSrc;
this._super(parent, _.extend({
size: 'large',
@@ -66,15 +68,18 @@ odoo.define('web.TranslationDialog', function (require) {
id: term.id,
lang: term.lang,
langName: relatedLanguage[1],
+ source: term.src,
// we set the translation value coming from the database, except for the language
// the user is currently utilizing. Then we set the translation value coming
// from the value of the field in the form
value: (term.lang === this.currentInterfaceLanguage &&
+ !this.showSrc &&
!this.isComingFromTranslationAlert) ?
this.userLanguageValue : term.value || ''
};
});
- this.data.sort((left, right) => left.langName < right.langName ? -1 : 1);
+ this.data.sort((left, right) =>
+ (left.langName < right.langName || (left.langName === right.langName && left.source < right.source)) ? -1 : 1);
});
},
@@ -89,7 +94,7 @@ odoo.define('web.TranslationDialog', function (require) {
return this._rpc({
model: 'ir.translation',
method: 'search_read',
- fields: ['lang', 'value'],
+ fields: ['lang', 'src', 'value'],
domain: this.domain,
});
},
@@ -132,10 +137,12 @@ odoo.define('web.TranslationDialog', function (require) {
if (initialValue.value !== t.value) {
updatedTerm[t.dataset.id] = t.value;
- if (initialValue.lang === this.currentInterfaceLanguage) {
+ if (initialValue.lang === this.currentInterfaceLanguage && !this.showSrc) {
// when the user has changed the term for the language he is
// using in the interface, this change should be reflected
// in the form view
+ // partial translations being handled server side are
+ // also ignored
var changes = {};
changes[this.fieldName] = updatedTerm[initialValue.id];
updateFormViewField = {