Title: ivy i18n Wrong placeholders generated for components with dash · Issue #34151 · angular/angular · GitHub
Open Graph Title: ivy i18n Wrong placeholders generated for components with dash · Issue #34151 · angular/angular
X Title: ivy i18n Wrong placeholders generated for components with dash · Issue #34151 · angular/angular
Description: 🐞 bug report Affected Package The issue is caused by packages @angular/localize @angular/compiler Description Localized build is failed if you have a components in 18n section with more than one word in name (my-test-component) (see erro...
Open Graph Description: 🐞 bug report Affected Package The issue is caused by packages @angular/localize @angular/compiler Description Localized build is failed if you have a components in 18n section with more than one wo...
X Description: 🐞 bug report Affected Package The issue is caused by packages @angular/localize @angular/compiler Description Localized build is failed if you have a components in 18n section with more than one wo...
Opengraph URL: https://github.com/angular/angular/issues/34151
X: @github
Domain: github.com
{"@context":"https://schema.org","@type":"DiscussionForumPosting","headline":"ivy i18n Wrong placeholders generated for components with dash","articleBody":"# 🐞 bug report\r\n\r\n### Affected Package\r\nThe issue is caused by packages\r\n**@angular/localize\r\n@angular/compiler**\r\n\r\n### Description\r\n\r\nLocalized build is failed if you have a components in 18n section with more than one word in name (my-test-component) (see error below)\r\n\r\n```html\r\n\u003cdiv i18n>\u003capp-my-component>\u003c/app-my-component> Welcome\u003c/div>\r\n```\r\nCaused because `@angular/compiler` generates xliff file with kebab-case in placeholders `START_TAG_APP-MY-COMPONENT` for components with kebab-cased name, but `ɵtranslate` from \r\n`@angular/localize` package expecting placeholders in underscore case format:\r\n\r\n```ts\r\n/// packages/localize/src/utils/src/translations.ts\r\nexport function translate(...): [TemplateStringsArray, readonly any[]] {\r\n ....\r\n return [\r\n translation.messageParts, translation.placeholderNames.map(placeholder => {\r\n if (message.substitutions.hasOwnProperty(placeholder)) {\r\n return message.substitutions[placeholder];\r\n } else {\r\n throw new Error(\r\n `No placeholder found with name ${placeholder} in message ${describeMessage(message)}.`);\r\n }\r\n })\r\n ];\r\n}\r\n```\r\n\r\n\r\nManual edit placeholder in translation file from Kebab-case to underscore_case helps:\r\n```diff\r\n+START_TAG_APP_MY_COMPONENT\r\n-START_TAG_APP-MY-COMPONENT\r\n```\r\n\r\n## 🔬 Minimal Reproduction\r\nMinimal reproduction repo is here:\r\n\r\nhttps://github.com/thekip/i18n-ivy-placeholder-issue\r\n\r\nSteps to reproduce: \r\n\r\nJust run `ng build` and see error or follow next steps to see more details:\r\n\r\n1. Generate messages using `ng xi18n` command\r\n2. Ensure that `START_TAG_APP-MY-COMPONENT` has kebab case in component name\r\n3. Create a translation file (there is one `ru` already created in repo) and add a translation\r\n4. Build project with any of AngularCli commands\r\n5. See error\r\n6. Change kebab case to unserscore case in translation file\r\n7. See succesful build\r\n\r\n\r\n## 🔥 Exception or Error\r\n\u003cpre>\u003ccode>No placeholder found with name START_TAG_APP-MY-COMPONENT in message \"293cc2dd1c2eef5113079f323ba045dd817e422d\" (\"{$START_TAG_APP_MY_COMPONENT}{$CLOSE_TAG_APP_MY_COMPONENT} Welcome\").\r\n\u003c/code>\u003c/pre>\r\n\r\n## 🌍 Your Environment\r\n\r\n**Angular Version:**\r\n\u003cpre>\u003ccode>\r\nAngular CLI: 9.0.0-rc.4\r\nNode: 10.16.0\r\nOS: darwin x64\r\n\r\nAngular: 9.0.0-rc.4\r\n... animations, cli, common, compiler, compiler-cli, core, forms\r\n... language-service, platform-browser, platform-browser-dynamic\r\n... router\r\nIvy Workspace: Yes\r\n\r\nPackage Version\r\n-----------------------------------------------------------\r\n@angular-devkit/architect 0.900.0-rc.4\r\n@angular-devkit/build-angular 0.900.0-rc.4\r\n@angular-devkit/build-optimizer 0.900.0-rc.4\r\n@angular-devkit/build-webpack 0.900.0-rc.4\r\n@angular-devkit/core 9.0.0-rc.4\r\n@angular-devkit/schematics 9.0.0-rc.4\r\n@angular/localize 9.0.0-rc.0\r\n@ngtools/webpack 9.0.0-rc.4\r\n@schematics/angular 9.0.0-rc.4\r\n@schematics/update 0.900.0-rc.4\r\nrxjs 6.5.3\r\ntypescript 3.6.4\r\nwebpack 4.41.2\r\n\u003c/code>\u003c/pre>\r\n\r\nFYI @ocombe \r\n","author":{"url":"https://github.com/timofei-iatsenko","@type":"Person","name":"timofei-iatsenko"},"datePublished":"2019-11-29T11:29:30Z","url":"https://github.com/angular/angular/issues/34151"}
| 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:818407c1-c5ad-29a9-8b15-ae9c5aac8c9c |
| current-catalog-service-hash | 81bb79d38c15960b92d99bca9288a9108c7a47b18f2423d0f6438c5b7bcd2114 |
| request-id | 9464:31B4CC:E322AE:12BF419:6B00FC61 |
| html-safe-nonce | e5ededeeca56c2c0921c9aef4cabad4d2c8894c575b4100114d63370c96ad828 |
| visitor-payload | eyJyZWZlcnJlciI6IiIsInJlcXVlc3RfaWQiOiI5NDY0OjMxQjRDQzpFMzIyQUU6MTJCRjQxOTo2QjAwRkM2MSIsInZpc2l0b3JfaWQiOiIxODU5OTUyNTA3MjA0MjA1NjY1IiwicmVnaW9uX2VkZ2UiOiJpYWQiLCJyZWdpb25fcmVuZGVyIjoiaWFkIn0= |
| visitor-hmac | b9eec1254dd4768884f6adbbe326475424ba150e89b01cfd5421e78fc9c2b68c |
| hovercard-subject-tag | issue:530298062 |
| 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/34151/issue_layout |
| twitter:image | https://opengraph.githubassets.com/48c98d6597b357127fb42d8f007645a1893c54050b00cc254e04f87f66ed3b46/angular/angular/issues/34151 |
| twitter:card | summary_large_image |
| og:image | https://opengraph.githubassets.com/48c98d6597b357127fb42d8f007645a1893c54050b00cc254e04f87f66ed3b46/angular/angular/issues/34151 |
| og:image:alt | 🐞 bug report Affected Package The issue is caused by packages @angular/localize @angular/compiler Description Localized build is failed if you have a components in 18n section with more than one wo... |
| og:image:width | 1200 |
| og:image:height | 600 |
| og:site_name | GitHub |
| og:type | object |
| og:author:username | timofei-iatsenko |
| hostname | github.com |
| expected-hostname | github.com |
| None | e208d86428ec00a57ade75058166297440e8128a01e5287c31a53dc042bbf187 |
| 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 | 7dafd017fb7809a839c443dba08622af38e63c09 |
| ui-target | full |
| theme-color | #1e2327 |
| color-scheme | light dark |
| react-app-name | issues |
Links:
Viewport: width=device-width