Title: extract-i18n with HTML entities and interpolation · Issue #41034 · angular/angular · GitHub
Open Graph Title: extract-i18n with HTML entities and interpolation · Issue #41034 · angular/angular
X Title: extract-i18n with HTML entities and interpolation · Issue #41034 · angular/angular
Description: 🐞 Bug report Command (mark with an x) new build serve test e2e generate add update lint extract-i18n run config help version doc Is this a regression? Yes, I also tested this with the old extraction tool ("@angular/cli": "~9.1.15") and i...
Open Graph Description: 🐞 Bug report Command (mark with an x) new build serve test e2e generate add update lint extract-i18n run config help version doc Is this a regression? Yes, I also tested this with the old extractio...
X Description: 🐞 Bug report Command (mark with an x) new build serve test e2e generate add update lint extract-i18n run config help version doc Is this a regression? Yes, I also tested this with the old extractio...
Opengraph URL: https://github.com/angular/angular/issues/41034
X: @github
Domain: github.com
{"@context":"https://schema.org","@type":"DiscussionForumPosting","headline":"extract-i18n with HTML entities and interpolation","articleBody":"\u003c!--🔅🔅🔅🔅🔅🔅🔅🔅🔅🔅🔅🔅🔅🔅🔅🔅🔅🔅🔅🔅🔅🔅🔅🔅🔅🔅🔅🔅🔅🔅🔅\r\n\r\nOh hi there! 😄\r\n\r\nTo expedite issue processing please search open and closed issues before submitting a new one.\r\nExisting issues often contain information about workarounds, resolution, or progress updates.\r\n\r\n🔅🔅🔅🔅🔅🔅🔅🔅🔅🔅🔅🔅🔅🔅🔅🔅🔅🔅🔅🔅🔅🔅🔅🔅🔅🔅🔅🔅🔅🔅🔅🔅🔅-->\r\n\r\n\r\n# 🐞 Bug report\r\n\r\n### Command (mark with an `x`)\r\n\u003c!-- Can you pin-point the command or commands that are effected by this bug? -->\r\n\u003c!-- ✍️edit: -->\r\n\r\n- [ ] new\r\n- [ ] build\r\n- [ ] serve\r\n- [ ] test\r\n- [ ] e2e\r\n- [ ] generate\r\n- [ ] add\r\n- [ ] update\r\n- [ ] lint\r\n- [x] extract-i18n\r\n- [ ] run\r\n- [ ] config\r\n- [ ] help\r\n- [ ] version\r\n- [ ] doc\r\n\r\n\r\n### Is this a regression?\r\n\r\nYes, I also tested this with the old extraction tool (`\"@angular/cli\": \"~9.1.15\"`) and it works correctly with `ng xi18n`.\r\n\r\n\r\n### Description\r\n\r\nPlacing an [HTML entity](https://dev.w3.org/html5/html-author/charref) (e.g. ` `) inside a translated text which also contains interpolated variables\r\n(`\u003cdiv i18n> Interpolation: {{ variable }}\u003c/div>`)\r\nresults in an incorrect value of the `equiv-text` attribute inside the extracted message's `INTERPOLATION` tag\r\n(`\u003cx id=\"INTERPOLATION_1\" equiv-text=\"ion: {{ v\"/>`).\r\nSeems like the value is shifted by the difference in amount of characters taken up by the HTML entity and it's actual representation.\r\n\r\nThis is a minor and rather unimportant issue since it does not affect the actual interpolation or translation. From what I understand this `equiv-text` attribute has an informative role for translators.\r\n\r\n## 🔬 Minimal Reproduction\r\n\u003c!--\r\nSimple steps to reproduce this bug.\r\n\r\nPlease include: commands run (including args), packages added, related code changes.\r\n\r\nIf reproduction steps are not enough for reproduction of your issue, please create a minimal GitHub repository with the reproduction of the issue. \r\nA good way to make a minimal reproduction is to create a new app via `ng new repro-app` and add the minimum possible code to show the problem. \r\nShare the link to the repo below along with step-by-step instructions to reproduce the problem, as well as expected and actual behavior.\r\n\r\nIssues that don't have enough info and can't be reproduced will be closed.\r\n\r\nYou can read more about issue submission guidelines here: https://github.com/angular/angular-cli/blob/master/CONTRIBUTING.md#-submitting-an-issue\r\n-->\r\n[https://github.com/pKrupaJunior/extract-i18n-issue](https://github.com/pKrupaJunior/extract-i18n-issue)\r\n\r\n1. Create project:\r\n ```shell\r\n ng new extract-i18n-issue -s -t --minimal -g -S --style css --create-application false\r\n ```\r\n2. Create sample application:\r\n ```shell\r\n ng g application demo -s -t --minimal --style css -S --routing false\r\n ```\r\n3. Add localization support:\r\n ```shell\r\n ng add @angular/localize\r\n ```\r\n4. Add an HTML template containing `i18n` attribute on a tag with **interpolated variables** and **HTML entities**:\r\n ```html\r\n \u003cdiv i18n>Interpolation: {{ one }} Interpolation: {{ two }}\u003c/div>\r\n ```\r\n5. Run `extract-i18n`:\r\n ```shell\r\n ng extract-i18n --output-path projects/demo/src/i18n\r\n ```\r\n\r\n## 🔥 Result\r\nThe generated `messages.xlf` file contains this:\r\n```xml\r\n\u003ctrans-unit id=\"4906579891802234912\" datatype=\"html\">\r\n \u003csource>Interpolation: \u003cx id=\"INTERPOLATION\" equiv-text=\"{{ one }}\"/> Interpolation: \u003cx id=\"INTERPOLATION_1\" equiv-text=\"ion: {{ t\"/>\u003c/source>\r\n ...\r\n\u003c/trans-unit>\r\n```\r\nThe second `equiv-text` attribute value is incorrect: `\u003cx id=\"INTERPOLATION_1\" equiv-text=\"ion: {{ t\"/>`.\r\nWhile it should be: `\u003cx id=\"INTERPOLATION_1\" equiv-text=\"{{ two }}\"/>`.\r\n\r\n\r\n## 🌍 Your Environment\r\n\u003cpre>\u003ccode>Angular CLI: 11.1.4\r\nNode: 12.13.0\r\nOS: win32 x64\r\n\r\nAngular: 11.1.2\r\n... animations, common, compiler, compiler-cli, core, forms\r\n... localize, platform-browser, platform-browser-dynamic, router\r\nIvy Workspace: Yes\r\n\r\nPackage Version\r\n---------------------------------------------------------\r\n@angular-devkit/architect 0.1101.4\r\n@angular-devkit/build-angular 0.1101.4\r\n@angular-devkit/core 11.1.4\r\n@angular-devkit/schematics 11.1.4\r\n@angular/cli 11.1.4\r\n@schematics/angular 11.1.4\r\n@schematics/update 0.1101.4\r\nrxjs 6.6.6\r\ntypescript 4.1.5\r\n\u003c/code>\u003c/pre>\r\n","author":{"url":"https://github.com/pKrupaJunior","@type":"Person","name":"pKrupaJunior"},"datePublished":"2021-02-27T22:40:37Z","url":"https://github.com/angular/angular/issues/41034"}
| react-profiling | 0 |
| react-import-map | react,react-dom,react-dom/client,react-dom/profiling,react-is,react/compiler-runtime,react/jsx-dev-runtime,react/jsx-runtime,scheduler@b8488ee2c322 |
| 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:4701bf7f-3324-383d-7b1b-00e0c94b4632 |
| current-catalog-service-hash | 81bb79d38c15960b92d99bca9288a9108c7a47b18f2423d0f6438c5b7bcd2114 |
| request-id | B70E:14ECB:2342F52:2CC8D4E:6B0180AC |
| html-safe-nonce | 782f548b8ec4d95ae12324fcb8f672b82f147ad3fd420ab9de811dfc7d7c2d56 |
| visitor-payload | eyJyZWZlcnJlciI6IiIsInJlcXVlc3RfaWQiOiJCNzBFOjE0RUNCOjIzNDJGNTI6MkNDOEQ0RTo2QjAxODBBQyIsInZpc2l0b3JfaWQiOiI5MjYxMjg2NTc0Mzk3NTIzNjQiLCJyZWdpb25fZWRnZSI6ImlhZCIsInJlZ2lvbl9yZW5kZXIiOiJpYWQifQ== |
| visitor-hmac | 88afdef6fe8bfa80dc6b7968c644d60ec761e933f270ecb4b5d08a77359b3fa7 |
| hovercard-subject-tag | issue:818278418 |
| 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/41034/issue_layout |
| twitter:image | https://opengraph.githubassets.com/338c0862fc87c851e77666e621ab0feac609d223bc3ae0be954bc5f1819f1269/angular/angular/issues/41034 |
| twitter:card | summary_large_image |
| og:image | https://opengraph.githubassets.com/338c0862fc87c851e77666e621ab0feac609d223bc3ae0be954bc5f1819f1269/angular/angular/issues/41034 |
| og:image:alt | 🐞 Bug report Command (mark with an x) new build serve test e2e generate add update lint extract-i18n run config help version doc Is this a regression? Yes, I also tested this with the old extractio... |
| og:image:width | 1200 |
| og:image:height | 600 |
| og:site_name | GitHub |
| og:type | object |
| og:author:username | pKrupaJunior |
| hostname | github.com |
| expected-hostname | github.com |
| None | cc5dfdd32f62ebd3223cab3af3aa2b268d3605218237326a48a99d1efd89495c |
| 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 | 8c77c9e8439031ad54c75a250694842892f693e1 |
| ui-target | full |
| theme-color | #1e2327 |
| color-scheme | light dark |
| react-app-name | issues |
Links:
Viewport: width=device-width