Chong Wang (cwg)
2d08f97c07
[IMP] core: support delay translation
Jsonb data structure of model_terms translated fields' columns
'{
"en_US": "<div>Apple</div>"
"fr_FR": "<div>Pomme</div><div>Banane</div>"
"_fr_FR": "<div>Pomme</div>"
}'::jsonb
"column" IS NULL OR "column"->>'en_US' IS NOT NULL
"column"->>'lang'
1. stores last confirmed value
2. logically fallbacks to
COALESCE(
"column"->>'lang',
"column"->>'en_US'
)
"column"->>'_lang'
1. stores translations and the last written html/xml structure
2. shares the same html/xml structure with other "column"->>'_lang'
3. logically fallbacks to
COALESCE(
"column"->>'_lang',
"column"->>'lang',
"column"->>'_en_US',
"column"->>'en_US'
)
Context:
1. `delay_translations`(new) only write values to _langs while keeping
translations for langs when the written value has at least one translatable term
2. `check_translations`(new) read _langs values to create translation mapping
for the translation dialog
3. `edit_translations` read values whose translatable terms are wrapped by
`<span></span>` with term information for the TRANSLATE mode of website
Potential issue
since the record value of a model terms translated field is logical content
dependent (check_translations, edit_translations), all computed field computed
from any model terms translated field should also be marked.
@api.depends_context('lang', 'edit_translations', 'check_translations')
Data flow for column value, cache value and record value
(make sure the window is wide enough to see the graph)
+- - - - - - - - - - - - - - - - - - - - - - - - - - - -+
' Record(str): '
' '
' +---------------------------------------------------+ ' +~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~+
' | "<div><span data-oe-model='model' | ' { read fr_FR {
' | data-oe-id='id' ...>French</span></div>" | ' <------------ } context.get('edit_translations') } <+
' +---------------------------------------------------+ ' +~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~+ |
' +---------------------------------------------------+ ' +~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~+ |
' | "<div>French</div>" | ' { read fr_FR { |
' | | ' <------------ } context.get('check_translations') } <+
' +---------------------------------------------------+ ' +~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~+ |
+~~~~~~~~~~~~+ ' +---------------------------------------------------+ ' |
{ read fr_FR { ------------> ' | "<a>French</a>" | ' |
+~~~~~~~~~~~~+ ' +---------------------------------------------------+ ' |
^ ' ' |
| +- - - - - - - - - - - - - - - - - - - - - - - - - - - -+ |
| |
| |
| |
| +- - - - - - - - - - - - - - - - - - - - - - - - - - - -+ |
| ' Cache(dict): ' |
| ' ' |
| ' +---------------------------------------------------+ ' |
| ' | | ' -----------------------------------------------------+
| ' | "_fr_FR": "<div>French</div>" | '
| ' | | ' <----------------------------------------------------+
| ' +---------------------------------------------------+ ' |
| ' +---------------------------------------------------+ ' +~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~+
+------------------------- ' | | ' { fetch fr_FR {
' | "fr_FR": "<a>French</a>" | ' } context.get('edit_translations') }
+------------------------> ' | | ' { or context.get('check_translations') {
| ' +---------------------------------------------------+ ' +~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~+
+~~~~~~~~~~~~~~~~~+ ' ' ^
{ fetch fr_FR { +- - - - - - - - - - - - - - - - - - - - - - - - - - - -+ COALESCE( |
+~~~~~~~~~~~~~~~~~+ "c"->>'_fr_FR', |
^ "c"->>'fr_FR', |
| COALESCE( "c"->>'_en_US', |
| "c"->>'fr_FR', +- - - - - - - - - - - - - - - - - - - - - - - - - - - -+ "c"->>'en_US' |
| "c"->>'en_US' ' Database(jsonb): ' ) |
| ) ' ' |
| ' +---------------------------------------------------+ ' |
| ' | "_fr_FR": "<div>French</div>" | ' -----------------------------------------------------+
| ' +---------------------------------------------------+ ' |
| ' +---------------------------------------------------+ ' |
+------------------------- ' | "fr_FR": "<a>French</a>" | ' -----------------------------------------------------+
| ' +---------------------------------------------------+ ' |
| ' +---------------------------------------------------+ ' |
| ' | "_en_US": "<div>English</div>" | ' -----------------------------------------------------+
| ' +---------------------------------------------------+ ' |
| ' +---------------------------------------------------+ ' |
+------------------------- ' | "en_US": "<div>English1</div><div>English2</div>" | ' -----------------------------------------------------+
' +---------------------------------------------------+ '
' '
+- - - - - - - - - - - - - - - - - - - - - - - - - - - -+
Task: 3043340
Part-of: odoo/odoo#139819
2023-10-27 11:35:03 +00:00
..
2023-02-07 09:12:32 +01:00
2023-05-17 14:47:12 +02:00
2023-08-28 15:15:19 +00:00
2023-07-18 11:42:26 +02:00
2023-05-03 13:57:17 +02:00
2023-07-13 19:28:12 +02:00
2023-05-17 14:47:12 +02:00
2023-10-06 14:33:43 +00:00
2023-04-19 21:58:27 +02:00
2023-07-19 13:12:51 +02:00
2023-09-22 11:55:58 +00:00
2023-10-04 18:27:03 +00:00
2023-07-15 05:10:45 +02:00
2023-10-20 09:35:17 +00:00
2023-10-17 08:53:06 +00:00
2023-10-20 09:35:18 +00:00
2023-09-29 13:11:58 +00:00
2022-11-17 13:57:35 +01:00
2023-10-20 09:35:17 +00:00
2023-10-25 11:37:36 +00:00
2023-03-07 01:59:38 +01:00
2023-10-27 11:35:03 +00:00
2023-10-25 17:03:19 +00:00
2023-06-14 10:54:47 +02:00