[IMP] website, tools: allow to translate hidden inputs
As the descriptions of the donation snippet will be in hidden inputs, we added the possibility to translate these inputs in translate mode. PR-63133 task-2398403 Part-of: odoo/odoo#63133
This commit is contained in:
committed by
Jeremy Kersten
parent
65fb31454f
commit
ec005bae0e
@@ -241,6 +241,7 @@ var TranslatePageMenu = websiteNavbarData.WebsiteNavbarActionWidget.extend({
|
||||
});
|
||||
|
||||
self._markTranslatableNodes();
|
||||
this.$translations.filter('input[type=hidden].o_translatable_input_hidden').prop('type', 'text');
|
||||
},
|
||||
});
|
||||
|
||||
|
||||
@@ -58,6 +58,12 @@ html[lang] > body.editor_enable [data-oe-translation-state] {
|
||||
}
|
||||
}
|
||||
|
||||
html[data-edit_translations="1"] {
|
||||
.o_translate_mode_hidden {
|
||||
display: none !important;
|
||||
}
|
||||
}
|
||||
|
||||
// SNIPPET PANEL
|
||||
$i: 1;
|
||||
@each $font-name, $font-config in $o-theme-font-configs {
|
||||
|
||||
+12
-1
@@ -151,8 +151,19 @@ TRANSLATED_ATTRS = dict.fromkeys({
|
||||
'aria-keyshortcuts', 'aria-placeholder', 'aria-roledescription', 'aria-valuetext',
|
||||
'value_label',
|
||||
}, lambda e: True)
|
||||
|
||||
def translate_attrib_value(node):
|
||||
# check if the value attribute of a node must be translated
|
||||
classes = node.attrib.get('class', '').split(' ')
|
||||
return (
|
||||
(node.tag == 'input' and node.attrib.get('type', 'text') == 'text')
|
||||
and 'datetimepicker-input' not in classes
|
||||
or (node.tag == 'input' and node.attrib.get('type') == 'hidden')
|
||||
and 'o_translatable_input_hidden' in classes
|
||||
)
|
||||
|
||||
TRANSLATED_ATTRS.update(
|
||||
value=lambda e: (e.tag == 'input' and e.attrib.get('type', 'text') == 'text') and 'datetimepicker-input' not in e.attrib.get('class', '').split(' '),
|
||||
value=translate_attrib_value,
|
||||
text=lambda e: (e.tag == 'field' and e.attrib.get('widget', '') == 'url'),
|
||||
**{f't-attf-{attr}': cond for attr, cond in TRANSLATED_ATTRS.items()},
|
||||
)
|
||||
|
||||
Reference in New Issue
Block a user