[18.0][FIX] project_timesheet_time_control: keep translatable terms free of markup whitespace - #1788
[18.0][FIX] project_timesheet_time_control: keep translatable terms free of markup whitespace#1788brambuijs wants to merge 1 commit into
Conversation
|
Hi @victoralmau, |
pedrobaeza
left a comment
There was a problem hiding this comment.
- Check the new AI policy https://github.com/pypa/pip/blob/main/AI_POLICY.md
- This doesn't include the .pot and .po files changes.
- The module version is changed by the bot, not here.
… markup whitespace
Four view terms in this module span several XML lines. Odoo extracts them
verbatim: translate_xml_node() groups consecutive translatable siblings and
only strips the outer whitespace, so the embedded newline and indentation end
up inside the msgid, for example:
".\n If you continue, it will be stopped with"
"<br/>\n <span>to</span>"
Any reindentation of the surrounding markup therefore changes the msgid and
orphans every existing translation. That already happened: nl.po, fi.po and
he_IL.po still carry the old translation as an obsolete entry with a different
indentation width, while the current msgid is empty. Across all 44 language
files, 176 of these term instances are untranslated.
Keep each translatable run on a single line, and exclude the <br/> from the
run in the kanban template so the term is just the <span>. Rendering is
unchanged, except that the period after the timer start no longer has a stray
space in front of it.
The catalogs are migrated along with the terms, otherwise this change would
orphan the translations it sets out to protect. The .pot is regenerated and
every .po is run through msgmerge --previous, which keeps the existing
translations and recovers three that had gone obsolete. The entry for
"<span>to</span>" is filled in by hand for the ten languages that had it,
since msgmerge does not match it to its predecessor.
Verified by running odoo.tools.translate.xml_translate over the arch blocks
before and after: the same terms are produced, none of them containing a
newline, and the model_terms msgids in the .pot match them exactly. All
catalogs pass msgfmt --check-format. Formatting checked with the repository
prettier configuration.
67ffede to
df1ce00
Compare
|
Thanks for the review. Module version: reverted, I had missed that AI policy: read and understood. No LLM co-author tags on the commit, and I take full .pot and .po: added. Flagging that CONTRIBUTING says PRs should never modify
Checks: all catalogs pass
|
Problem
Four view terms in this module span several XML lines. Odoo's
translate_xml_node()groups consecutive translatable siblings into one term and only strips the outer whitespace, so the embedded newline and indentation end up inside the msgid:Any reindentation of the surrounding markup changes the msgid and silently orphans every existing translation.
That is not hypothetical, it already happened.
nl.po,fi.poandhe_IL.postill carry the previous translation as an obsolete entry with a different indentation width, while the current msgid sits there empty:Note the 28 spaces in the live entry against 24 in the obsolete one. Across the 44 language files, 176 instances of these four terms are untranslated. In practice a Dutch user reads a sentence that switches to English halfway through:
Fix
Keep each translatable run on a single line, and take the
<br/>out of the run in the kanban template so the term is just the<span>. Resulting terms:No term contains a newline any more, so reindentation can no longer break them.
Verification
odoo.tools.translate.xml_translateover the arch blocks before and after. The same set of terms is produced, no terms added or removed, and none of them contains a newline.prettier@3.3.3+@prettier/plugin-xml@3.4.1):All matched files use Prettier code style!Notes
.pofiles are touched, since translations are managed through Weblate. The four msgids do change, so they will need translating again there. 176 of those instances were already untranslated, and for the three languages that still hold the old text as an obsolete entry it is a copy-paste away.<br t-translation="off" />is used in the kanban template purely to keep the<br/>out of the translatable run, since<br>is inTRANSLATED_ELEMENTS. Happy to use another approach if you prefer, but moving it or giving the<span>a block class both change the layout.