mirror of
https://github.com/odoo/owl.git
synced 2025-10-06 19:59:41 +07:00
[ADD] Translation feature
This commit brings back the possibility to translate text nodes and the attributes "label", "title", "placeholder", and "alt" in an app configured with a suitable translation function. It is also possible to deactivate translations under a node via the directive t-translation="off". For flexibility it is possible to define the list of translatable attributes in the app.
This commit is contained in:
committed by
Géry Debongnie
parent
e2d98e4c26
commit
b8649f1add
@@ -1126,4 +1126,47 @@ describe("qweb parser", () => {
|
||||
name: "myBlock",
|
||||
});
|
||||
});
|
||||
|
||||
// ---------------------------------------------------------------------------
|
||||
// t-translation
|
||||
// ---------------------------------------------------------------------------
|
||||
test('t-translation="off"', async () => {
|
||||
expect(parse(`<t t-translation="off">word</t>`)).toEqual({
|
||||
type: ASTType.TTranslation,
|
||||
content: {
|
||||
type: ASTType.Text,
|
||||
value: "word",
|
||||
},
|
||||
});
|
||||
|
||||
expect(parse(`<div t-foreach="list" t-translation="off" t-as="item">word</div>`)).toEqual({
|
||||
body: {
|
||||
content: {
|
||||
attrs: {},
|
||||
content: [
|
||||
{
|
||||
type: 0,
|
||||
value: "word",
|
||||
},
|
||||
],
|
||||
on: {},
|
||||
ref: null,
|
||||
tag: "div",
|
||||
type: 2,
|
||||
},
|
||||
type: 16,
|
||||
},
|
||||
collection: "list",
|
||||
elem: "item",
|
||||
hasNoComponent: true,
|
||||
hasNoFirst: true,
|
||||
hasNoIndex: true,
|
||||
hasNoLast: true,
|
||||
hasNoValue: true,
|
||||
isOnlyChild: false,
|
||||
key: null,
|
||||
memo: "",
|
||||
type: 9,
|
||||
});
|
||||
});
|
||||
});
|
||||
|
||||
Reference in New Issue
Block a user