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] Unexpected behaviors #513

Closed
rafaelss95 opened this issue May 28, 2021 · 0 comments · Fixed by #665
Closed

[i18n] Unexpected behaviors #513

rafaelss95 opened this issue May 28, 2021 · 0 comments · Fixed by #665
Assignees
Labels
bug Something isn't working package: eslint-plugin-template Angular Template rules

Comments

@rafaelss95
Copy link
Member

rafaelss95 commented May 28, 2021

Description and reproduction of the issue

  1. boundTextAllowedPattern isn't behaving as expected. See this case:
    convertAnnotatedSourceToFailureCase({
    description: 'it should fail because of the custom pattern',
    annotatedSource: `
    <div>
    <span>-{{data_from_backend}}</span>
    ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
    </div>
    `,
    messageId: i18nText,
    options: [{ boundTextAllowedPattern: '-' }],
    data: { attributeName: 'span' },
    }),

Here we report a bound text that starts with an allowed character. It should be valid instead;

  1. Missing i18n-* attributes are reported duplicately. See this case:

{
messageId: i18nAttribute,
line: 8,
column: 11,
data: { attributeName: 'label' },
},
{
messageId: i18nAttribute,
line: 8,
column: 11,
data: { attributeName: 'label' },
},

  1. Report ranges could be more assertive. For example, when an i18n attribute is missing an id or the text is missing the i18n attribute, the whole element is reported, when we just need to report the original attribute or text;

  2. <ng-template> , ngPlural, ngPluralCase and ngProjectAs should be ignored;

  3. Numeric values and HTML entities ("i18n": [false,"check-text"] fails on text containing only non-word characters mgechev/codelyzer#618 and [template-i18n]: Single HTML entities should be ignored mgechev/codelyzer#952) should be ignored. Examples:

<div ariaselected="0"></div>
<div matBadge="&#8288;">5</div>
<div>732</div>
<div>&nbsp;</div>
  1. ICUs are not being reported (https://angular.io/guide/i18n#translate-plurals-and-alternate-expressions);

  2. Duplicate custom IDs are not being reported (https://angular.io/guide/i18n#define-unique-custom-ids).

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
bug Something isn't working package: eslint-plugin-template Angular Template rules
Projects
None yet
Development

Successfully merging a pull request may close this issue.

1 participant