Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

i18n check-text edge cases #442

Closed
Manduro opened this issue Oct 24, 2017 · 7 comments
Closed

i18n check-text edge cases #442

Manduro opened this issue Oct 24, 2017 · 7 comments

Comments

@Manduro
Copy link
Contributor

Manduro commented Oct 24, 2017

Some cases where the i18n rule with check-text errors, but shouldn't (imo):

<mat-checkbox i18n="@@terms">
  I agree to the
  <a href="#">terms of service</a>
</mat-checkbox>
<ng-container i18n="@@minlength">
  Use at least {{ minLength }} characters
</ng-container>
@mgechev mgechev added this to the 4.1.0 - Peter Naur milestone Nov 1, 2017
@mgechev
Copy link
Owner

mgechev commented Nov 1, 2017

Thanks for reporting this! Added it to the next release.

@mgechev mgechev modified the milestones: 4.0.2 - Peter Naur, 4.0.3 - Manuel Blum Dec 21, 2017
@mgechev
Copy link
Owner

mgechev commented Jan 9, 2018

@Manduro the rule with the check-text option will not fail if:

Each element containing text node should have an i18n attribute

In such case, the first template is invalid, right?

@mgechev
Copy link
Owner

mgechev commented Jan 9, 2018

@Manduro would you take a look at the referenced PR and tell me if you think that's the behavior you think the rule should have?

In the end, the content of the element with i18n will be replaced by the compiler so the interpolation will be lost, right?

If that's the case, I'd suggest to introduce another config option to this rule which warns when an interpolation is used inside of an element with i18n attribute.

@wKoza
Copy link
Collaborator

wKoza commented Jan 9, 2018

I'm not an i18n Expert, but the Angular documentation says that we can use interpolation with i18n attribute : see https://angular.io/guide/i18n#translate-singular-and-plural

@Manduro
Copy link
Contributor Author

Manduro commented Jan 9, 2018

Yes we can use interpolation if I'm correct, but be sure to double check it!

I'm not sure if the first case I submitted is valid. Maybe it was just my wishful thinking. I'd probably need to split that into two elements with two i18n attributes.

@wKoza
Copy link
Collaborator

wKoza commented Jan 9, 2018

For me, it's not valid if we take a look at this : angular/angular#18302

@mgechev
Copy link
Owner

mgechev commented Jan 9, 2018

Sounds good. Looks like the PR I opened fixes the second, incorrect, behavior. Let me know if you think we can add anything else.

mgechev added a commit that referenced this issue Jan 18, 2018
* fix(i18n): do not warn with interpolation in i18n element

Fix #442

* chore: support for angular 5.2
mgechev added a commit that referenced this issue Jan 18, 2018
* fix(i18n): do not warn with interpolation in i18n element

Fix #442

* test: add specs for check-interpolation

* test: run all tests
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

3 participants