Title: extract-i18n generating wrong source inside the xfl file when parsing empty elements · Issue #56824 · angular/angular · GitHub
Open Graph Title: extract-i18n generating wrong source inside the xfl file when parsing empty elements · Issue #56824 · angular/angular
X Title: extract-i18n generating wrong source inside the xfl file when parsing empty elements · Issue #56824 · angular/angular
Description: Command extract-i18n Is this a regression? Yes, this behavior used to work in the previous version The previous version in which this bug was not present was No response Description We recently upgraded to v16.2.14 from v14 (couldn't upd...
Open Graph Description: Command extract-i18n Is this a regression? Yes, this behavior used to work in the previous version The previous version in which this bug was not present was No response Description We recently upg...
X Description: Command extract-i18n Is this a regression? Yes, this behavior used to work in the previous version The previous version in which this bug was not present was No response Description We recently upg...
Opengraph URL: https://github.com/angular/angular/issues/56824
X: @github
Domain: patch-diff.githubusercontent.com
{"@context":"https://schema.org","@type":"DiscussionForumPosting","headline":"extract-i18n generating wrong source inside the xfl file when parsing empty elements","articleBody":"### Command\r\n\r\nextract-i18n\r\n\r\n### Is this a regression?\r\n\r\n- [X] Yes, this behavior used to work in the previous version\r\n\r\n### The previous version in which this bug was not present was\r\n\r\n_No response_\r\n\r\n### Description\r\n\r\nWe recently upgraded to v16.2.14 from v14 (couldn't update further as we need to fix some dependencies which don't support \u003e v17) and now I discovered by chance that extract-i18n is producing an xlf which would break html once using a language different from the default one.\r\nDebugging a bit, I found out that the parse of empty html elements (like `\u003csvg\u003e\u003c/svg\u003e` or `\u003cspan\u003e\u003c/span\u003e`) is producing wrong closing tags picking up part of the text after the real closing tag. An example below:\r\nthis html\r\n```html\r\n\u003cdiv\u003e\r\n \u003cbutton\r\n i18n=\"add line button@myAddLineStringId\"\r\n \u003e\r\n Add line\r\n \u003csvg cdsIcon=\"add\" size=\"20\" class=\"cds--btn__icon\"\u003e\u003c/svg\u003e\r\n \u003c/button\u003e\r\n\u003c/div\u003e\r\n```\r\nis producing this entry in the xlf\r\n```xlf\r\n\u003csource\u003e Add line \u003cx id=\"START_TAG__SVG_SVG\" ctype=\"x-_svg_svg\" equiv-text=\"\u0026lt;svg cdsIcon=\u0026quot;add\u0026quot; size=\u0026quot;20\u0026quot; class=\u0026quot;cds--btn__icon\u0026quot;\u0026gt;\"/\u003e\u003cx id=\"CLOSE_TAG__SVG_SVG\" ctype=\"x-_svg_svg\" equiv-text=\"\u0026lt;/button\u0026gt;\r\n\u0026lt;/di\"/\u003e\u003c/source\u003e\r\n```\r\nas you can see, when the translated xlf will take over the default language version, it will produce an svg closing tag `\u003c/button\u003e\u003c/di` which would then break the above html\r\nA simple fix is to add a space inside the empty element, or move the closing tag in a new line, but this might collide with linter setup, so not a great temporary solution.\r\n\r\n### Minimal Reproduction\r\n\r\nhave in a template the following:\r\n```html\r\n\u003cdiv i18n=\"description@@stringId\"\u003e\r\n A string\r\n \u003cspan\u003e\u003c/span\u003e\r\n\u003c/div\u003e\r\n```\r\n\r\nand then run the normal extract-i18n\r\n\r\n### Exception or Error\r\n\r\n_No response_\r\n\r\n### Your Environment\r\n\r\n```text\r\n_ _ ____ _ ___\r\n / \\ _ __ __ _ _ _| | __ _ _ __ / ___| | |_ _|\r\n / △ \\ | '_ \\ / _` | | | | |/ _` | '__| | | | | | |\r\n / ___ \\| | | | (_| | |_| | | (_| | | | |___| |___ | |\r\n /_/ \\_\\_| |_|\\__, |\\__,_|_|\\__,_|_| \\____|_____|___|\r\n |___/\r\n \r\n\r\nAngular CLI: 16.2.14\r\nNode: 18.20.1\r\nPackage Manager: yarn 1.22.19\r\nOS: darwin arm64\r\n\r\nAngular: 16.2.12\r\n... animations, common, compiler, compiler-cli, core, elements\r\n... forms, language-service, localize, platform-browser\r\n... platform-browser-dynamic, router, service-worker\r\n\r\nPackage Version\r\n---------------------------------------------------------\r\n@angular-devkit/architect 0.1602.14\r\n@angular-devkit/build-angular 16.2.14\r\n@angular-devkit/core 16.2.14\r\n@angular-devkit/schematics 16.2.14\r\n@angular/cdk 16.2.14\r\n@angular/cli 16.2.14\r\n@angular/material 16.2.14\r\n@schematics/angular 16.2.14\r\nrxjs 7.8.1\r\ntypescript 4.9.5\r\nzone.js 0.13.3\r\n```\r\n\r\n\r\n### Anything else relevant?\r\n\r\n_No response_","author":{"url":"https://github.com/Licen-it","@type":"Person","name":"Licen-it"},"datePublished":"2024-07-03T12:38:08.000Z","interactionStatistic":{"@type":"InteractionCounter","interactionType":"https://schema.org/CommentAction","userInteractionCount":9},"url":"https://github.com/56824/angular/issues/56824"}
| route-pattern | /_view_fragments/issues/show/:user_id/:repository/:id/issue_layout(.:format) |
| route-controller | voltron_issues_fragments |
| route-action | issue_layout |
| fetch-nonce | v2:d760ec49-b06f-611f-554d-e3051ed18747 |
| current-catalog-service-hash | 81bb79d38c15960b92d99bca9288a9108c7a47b18f2423d0f6438c5b7bcd2114 |
| request-id | 8EAC:1E0AAF:277AA83:36D06D9:6977A484 |
| html-safe-nonce | 6d749fb4669e4d0e8bdcd4658ed323df95eb3845241a941aff39976a0393ba7b |
| visitor-payload | eyJyZWZlcnJlciI6IiIsInJlcXVlc3RfaWQiOiI4RUFDOjFFMEFBRjoyNzdBQTgzOjM2RDA2RDk6Njk3N0E0ODQiLCJ2aXNpdG9yX2lkIjoiMjY2MzU3NTAyMDM2NTEyODgzNiIsInJlZ2lvbl9lZGdlIjoiaWFkIiwicmVnaW9uX3JlbmRlciI6ImlhZCJ9 |
| visitor-hmac | 6bdcb5dfb0a2d2419d1058525bd57b433f1d006c7cc6b7af9123cf5b04c2d211 |
| hovercard-subject-tag | issue:2388749626 |
| github-keyboard-shortcuts | repository,issues,copilot |
| google-site-verification | Apib7-x98H0j5cPqHWwSMm6dNU4GmODRoqxLiDzdx9I |
| octolytics-url | https://collector.github.com/github/collect |
| analytics-location | / |
| fb:app_id | 1401488693436528 |
| apple-itunes-app | app-id=1477376905, app-argument=https://github.com/_view_fragments/issues/show/angular/angular/56824/issue_layout |
| twitter:image | https://opengraph.githubassets.com/00155e588d4ff7300cd0c6d5c215505cce0dce09846a6cf21d25ae456168de93/angular/angular/issues/56824 |
| twitter:card | summary_large_image |
| og:image | https://opengraph.githubassets.com/00155e588d4ff7300cd0c6d5c215505cce0dce09846a6cf21d25ae456168de93/angular/angular/issues/56824 |
| og:image:alt | Command extract-i18n Is this a regression? Yes, this behavior used to work in the previous version The previous version in which this bug was not present was No response Description We recently upg... |
| og:image:width | 1200 |
| og:image:height | 600 |
| og:site_name | GitHub |
| og:type | object |
| og:author:username | Licen-it |
| hostname | github.com |
| expected-hostname | github.com |
| None | e8b91803a5fc7ac066710509c57c636dab6ed4620bd9213b470a4617c79989c9 |
| turbo-cache-control | no-preview |
| go-import | github.com/angular/angular git https://github.com/angular/angular.git |
| octolytics-dimension-user_id | 139426 |
| octolytics-dimension-user_login | angular |
| octolytics-dimension-repository_id | 24195339 |
| octolytics-dimension-repository_nwo | angular/angular |
| octolytics-dimension-repository_public | true |
| octolytics-dimension-repository_is_fork | false |
| octolytics-dimension-repository_network_root_id | 24195339 |
| octolytics-dimension-repository_network_root_nwo | angular/angular |
| turbo-body-classes | logged-out env-production page-responsive |
| disable-turbo | false |
| browser-stats-url | https://api.github.com/_private/browser/stats |
| browser-errors-url | https://api.github.com/_private/browser/errors |
| release | 9b4562e3c5c60b38349a7d80ec8e160c11fe84b6 |
| ui-target | canary-2 |
| theme-color | #1e2327 |
| color-scheme | light dark |
Links:
Viewport: width=device-width