question-mark
Stuck on an issue?

Lightrun Answers was designed to reduce the constant googling that comes with debugging 3rd party libraries. ItΒ collects links to all the places you might be looking at while hunting down a tough bug.

And, if you’re still stuck at the end, we’re happy to hop on a call to see how we can help out.

ID generated by xi18n command does not match ID generated at run time

See original GitHub issue

🐞 Bug report

Command (mark with an x)

  • new
  • build
  • serve
  • test
  • e2e
  • generate
  • add
  • update
  • lint
  • xi18n
  • run
  • config
  • help
  • version
  • doc

Is this a regression?

Not sure

Description

string ID generated by using "ng xi18n --ivy --format=xlf" dont match ID at runtime. Im getting `localize.js:392 No translation found for ...`

πŸ”¬ Minimal Reproduction

  1. Say add <custom-element i18n-label label="Your details must match your government issued ID"></custom-element> in your template
  2. Run ng xi18n --ivy --format=xlf command
  3. in your main.ts add loadTranslations({<key from xlf file>:<string vlaue>})
  4. run it with β€œng serve”

πŸ”₯ Exception or Error



In the console I see `localize.js:392 localize.js:392 No translation found for "4775231765644062609" ("Your details must match your government issued ID") warning. By comparison ID for that string in the xlf file was "bf882f6f9243369463e44749b2780c253ddce34a"

🌍 Your Environment




Angular CLI: 10.1.1
Node: 10.15.3
OS: darwin x64

Angular: 10.1.4
... animations, common, compiler, compiler-cli, core, forms
... language-service, localize, platform-browser
... platform-browser-dynamic, router
Ivy Workspace: Yes

Package                            Version
------------------------------------------------------------
@angular-devkit/architect          0.901.12
@angular-devkit/build-angular      0.1001.4
@angular-devkit/build-ng-packagr   0.1001.4
@angular-devkit/build-optimizer    0.1001.4
@angular-devkit/build-webpack      0.1001.4
@angular-devkit/core               7.3.10
@angular-devkit/schematics         7.3.10
@angular/cdk                       10.2.3
@angular/cli                       10.1.1
@angular/flex-layout               10.0.0-beta.32
@angular/google-maps               10.2.3
@angular/material                  10.2.3
@ngtools/webpack                   10.1.4
@schematics/angular                8.3.23
@schematics/update                 0.1001.1
ng-packagr                         10.1.2
rxjs                               6.6.3
typescript                         3.9.7
webpack                            4.44.1

Anything else relevant?

I also noticed that IDs generated from templates vs from $localize in TS files have different length. Here is ID from $localize: 4998556035340110929 and here is from template 47c477a6e7959ffde7a0ab247ec1c88468d5e101. Looks like ones from templates is hexadecimal where from $localize are numbers only. And template IDs twice longer.

Issue Analytics

  • State:closed
  • Created 3 years ago
  • Comments:8 (4 by maintainers)

github_iconTop GitHub Comments

1reaction
petebacondarwincommented, Oct 7, 2020

For reference, I think the line that needs to change to support legacy message ids in Ivy JIT mode is https://github.com/angular/angular/blob/d795a001375a7d06592450d6f57a4f05d4d3e8e9/packages/compiler/src/render3/view/i18n/meta.ts#L55

0reactions
angular-automatic-lock-bot[bot]commented, Nov 9, 2020

This issue has been automatically locked due to inactivity. Please file a new issue if you are encountering a similar or related problem.

Read more about our automatic conversation locking policy.

This action has been performed automatically by a bot.

Read more comments on GitHub >

github_iconTop Results From Across the Web

angular 10 translation strings IDs dont match - Stack Overflow
Any idea why runtime ID for the same string different from one generated by xi18n? Much appreciate help. angular Β· localization Β· angular10....
Read more >
add an option for xi18n tool to detect Inconsistency for ID content
With angular i18n, If the same message ID is used in several ... the same ID, does not contain the same message, and...
Read more >
ng extract-i18n - Angular
Option Description Default Value ‑‑format Output format for the generated file. xlf ‑‑out‑file Name of the file to output. ‑‑output‑path Path where output will be placed....
Read more >
Localizing your app - Angular Hispano
The ng xi18n command (with no options) generates a source language file named messages.xlf in the project src folder. Create translation files for...
Read more >
Internationalization with @angular/localize | Ninja Squad
The error is self-explanatory: as the i18n attributes are now converted to $localize calls in the generated code, we need to load the...
Read more >

github_iconTop Related Medium Post

No results found

github_iconTop Related StackOverflow Question

No results found

github_iconTroubleshoot Live Code

Lightrun enables developers to add logs, metrics and snapshots to live code - no restarts or redeploys required.
Start Free

github_iconTop Related Reddit Thread

No results found

github_iconTop Related Hackernoon Post

No results found

github_iconTop Related Tweet

No results found

github_iconTop Related Dev.to Post

No results found

github_iconTop Related Hashnode Post

No results found