Per T261181#6831706 the current syntax is problematic for Parsoid.
Current syntax example:
Latest '''[[<tvar|technews>m:Special:MyLanguage/Tech/News</>|tech news]]''' from the Wikimedia technical community. Please tell other users about these changes. Not all changes will affect you. [[<tvar|more-transl>m:Special:MyLanguage/Tech/News/2021/07</>|Translations]] are available.
Subbu's proposed syntax example:
Latest '''[[<tvar id='technews'>m:Special:MyLanguage/Tech/News</tvar>|tech news]]''' from the Wikimedia technical community. Please tell other users about these changes. Not all changes will affect you. [[<tvar id='more-transl'>m:Special:MyLanguage/Tech/News/2021/07</tvar>|Translations]] are available.
One possible issue with this is that id attributes are global to the page, while tvars are local to the translation unit. Often numbered ids starting from 1 are used, causing the same id to be used multiple times on a translatable page. This syntax does not appear in the rendered output, but could be confusing to the editors.
Alternative would be to use other name like <tvar name='1'>...</tvar> or <tvar x='1'>...</tvar> to make it shorter, or explore whether <tvar 1>...</tvar> syntax would be possible. The quotes around the value would be optional, only needed if there are spaces (which I think should be disallowed in variable names if not already prevented).
Since Translate is (for now) string based, the regular expression would be amended to allow whitespace and quotes, but not other attributes (similar to <translate nowrap>.
For migration, old syntax can automatically be converted to the new syntax whenever a page is (re-)marked for translation.
Documentation pages that need updating
- Support for new syntax <tvar name=1>value</tvar> is deployed and documented
- Showing warnings for misuse of variables on Special:PageTranslation is waiting to be deployed
- There is no automatic migration to the new syntax, nor easy way to find pages using the old syntax (Special:Search might work though)