[DOC] update translations page

This commit is contained in:
Géry Debongnie
2022-01-18 15:22:15 +01:00
committed by Aaron Bohy
parent 82f6923a21
commit cfb6b9f958
2 changed files with 19 additions and 4 deletions
+4
View File
@@ -599,6 +599,10 @@ hello owl. This is just a text node!
<div t-if="someCondition"><SomeChildComponent/></div>
```
```xml
<t t-if="someCondition"><SomeChildComponent/></t>
```
## Inline templates
Most real applications will define their templates in a XML file, to benefit
+15 -4
View File
@@ -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"] });
// ...
```