From cfb6b9f958dfb00e4706fe7262cae5b3fce9e968 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?G=C3=A9ry=20Debongnie?= Date: Tue, 18 Jan 2022 15:22:15 +0100 Subject: [PATCH] [DOC] update translations page --- doc/reference/templates.md | 4 ++++ doc/reference/translations.md | 19 +++++++++++++++---- 2 files changed, 19 insertions(+), 4 deletions(-) diff --git a/doc/reference/templates.md b/doc/reference/templates.md index 181432c9..cbb3980a 100644 --- a/doc/reference/templates.md +++ b/doc/reference/templates.md @@ -599,6 +599,10 @@ hello owl. This is just a text node!
``` +```xml + +``` + ## Inline templates Most real applications will define their templates in a XML file, to benefit diff --git a/doc/reference/translations.md b/doc/reference/translations.md index f405b5b0..9af9cccd 100644 --- a/doc/reference/translations.md +++ b/doc/reference/translations.md @@ -1,8 +1,6 @@ # 🦉 Translations 🦉 -take care of this and "cherry-pick" 8464a1b04e7469434f9dcb3d68a543f58cb61b8e - -If properly setup, Owl QWeb engine can translate all rendered templates. To do +If properly setup, Owl can translate all rendered templates. To do so, it needs a translate function, which takes a string and returns a string. For example: @@ -15,9 +13,13 @@ const translations = { }; const translateFn = (str) => translations[str] || str; -const qweb = new QWeb({ translateFn }); +const app = new App(Root, { templates, tranaslateFn }); +// ... ``` +See the [app configuration page](app.md#configuration) for more info on how to +configure an Owl application. + Once setup, all rendered templates will be translated using `translateFn`: - each text node will be replaced with its translation, @@ -46,3 +48,12 @@ will be rendered as: Note that the translation is done during the compilation of the template, not when it is rendered. + +In some case, it is useful to be able to extend the list of translatable attributes. +For example, one may want to also translate `data-title` attributes. To do that, +we can define additional attributes with the `translatableAttributes` option: + +```js +const app = new App(Root, { templates, tranaslateFn, translatalbeAttributes: ["data-title"] }); +// ... +```