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.

i18n with ivy breaks the injection of translated attribute

See original GitHub issue

🐞 bug report

Affected Package

The issue is caused by package @angular/localize.

Is this a regression?

Yes, this issue is reproducible only with Ivy. With ViewEngine it works fine.

Description

Injecting the attribute to the component/directive that is translated using i18n is always resulting in null.

Example:

text is a directive that reads the text attribute and simply adds the following text to the host element:

Text attribtue value is: <attribute value>

Code:

<div text="Text without i18n"></div>
<div i18n-text text="Text with i18n"></div>

Resulting HTML:

<div text="Text without i18n">Text attribtue value is: Text without i18n.</div>
<div text="Text with i18n">Text attribtue value is: null.</div>

Observed in the result above, text attribute is properly set to Text with i18n, while the injected value remains null.

🔬 Minimal Reproduction

https://stackblitz.com/edit/angular-ivy-uzgvwe

You can observe null as described above.

To make this example work, open settings and uncheck Enable Ivy. Now ViewEngine will be used to compile the application, and the null text will be replaced by Text with i18n.

🌍 Your Environment

Angular CLI: 10.0.4 Node: 12.16.3 OS: linux x64

Angular: 10.0.5 … animations, common, compiler, compiler-cli, core, forms … localize, platform-browser, platform-browser-dynamic, router Ivy Workspace: Yes

Package Version

@angular-devkit/architect 0.1000.4 @angular-devkit/build-angular 0.1000.4 @angular-devkit/build-optimizer 0.1000.4 @angular-devkit/build-webpack 0.1000.4 @angular-devkit/core 10.0.4 @angular-devkit/schematics 10.0.4 @angular/cli 10.0.4 @ngtools/webpack 10.0.4 @schematics/angular 10.0.4 @schematics/update 0.1000.4 rxjs 6.5.5 typescript 3.9.7 webpack 4.43.0

Issue Analytics

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

github_iconTop GitHub Comments

1reaction
petebacondarwincommented, Aug 12, 2020

Note that this involves an @Attribute decorator rather than an @Input decorator to pass the value through. It does work if you use @Input instead: https://stackblitz.com/edit/angular-ivy-af37h8?file=src%2Fapp%2Ftext.directive.ts

0reactions
angular-automatic-lock-bot[bot]commented, Nov 27, 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 localization with Ivy
The i18n tags are very powerful — they can be used in attributes as ... The build pipeline of a translated Angular application...
Read more >
Angular 9 is here – Ivy, Lazy Loading and more - devmio
Fully integrated Ivy, Lazy Loading components and localization ... Then we can add the attribute i18n to the texts to be translated in...
Read more >
Angular: Localization in to multiple languages - Stack Overflow
With Angular 9 and Ivy, run-time, single build translations are coming closer to reality. Ivy already has capabilities to load translations ...
Read more >
Build Times, Bundle Sizes, and Other Improvements Made by ...
This means that after the Angular compiler has completed its work, all the template text marked with i18n attributes have been converted to...
Read more >
The Ultimate Guide to Angular Localization | Phrase
We'll add a special i18n attribute to the <h1> element, which marks its text for translation. src/app/layout/navbar/navbar.component.html.
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