Skip to content

[i18n] new option includeAttributes #929

@superole

Description

@superole

Description and reproduction of the issue
I would like to propose a new option includeAttributes to the i18n rule.
This option should be a complement to the ignoreAttributes option, and specify attributes that should be checked even if the checkAttributes option is false.

This way when using 3rd party components that have lots of string attributes of which only a handful are texts that should be translated, we could list only the relevant attributes instead of all the irrelevant ones.

I would also like to propose that the enhancement requested in #839 is included in this option as well, for the same reasons.

{
  "rules": {
    "@angular-eslint/template/i18n": ["error", {
      "checkAttributes": false,
      "includeAttributes": ["title","caption","name"]
    }]
  }
}
// your repro code case
<dx-tree-list
    id="employees"
    [dataSource]="employees"
    keyExpr="ID"
    parentIdExpr="Head_ID"
    [showRowLines]="true"
    [showBorders]="true"
    [columnAutoWidth]="true"
    [expandedRowKeys]="[1, 2, 3, 4, 5]"
    (onEditorPreparing)="editorPreparing($event)"
    (onInitNewRow)="initNewRow($event)"
  >
    <dxo-editing
      mode="row"
      [allowUpdating]="true"
      [allowDeleting]="true"
      [allowAdding]="true"
    >
    </dxo-editing>

    <dxi-column dataField="Full_Name">
      <dxi-validation-rule type="required"></dxi-validation-rule>
    </dxi-column>
    <dxi-column dataField="Head_ID" caption="Head" i18n-caption="@@columnCaptionHead">
      <dxo-lookup
        [dataSource]="lookupData"
        valueExpr="ID"
        displayExpr="Full_Name"
      >
      </dxo-lookup>
      <dxi-validation-rule type="required"></dxi-validation-rule>
    </dxi-column>
    <dxi-column dataField="Title" caption="Position" i18n-caption="@@columnCaptionTitle">
      <dxi-validation-rule type="required"></dxi-validation-rule>
    </dxi-column>
    <dxi-column dataField="Hire_Date" dataType="date" [width]="120">
      <dxi-validation-rule type="required"></dxi-validation-rule>
    </dxi-column>
    <dxi-column type="buttons">
      <dxi-button name="edit" i18n-name="@@buttonTextEdit"></dxi-button>
      <dxi-button name="delete" i18n-name="@@buttonTextDelete"></dxi-button>
    </dxi-column>
  </dx-tree-list>
  <dx-accordion
    [collapsible]="true"
    [multiple]="false"
    [animationDuration]="300">
    <dxi-item i18n-title="Accordion title@@options" title="Options">
      <my-content-component></my-content-component>
    </dxi-item>
  </dx-accordion>

Metadata

Metadata

Assignees

No one assigned

    Labels

    package: eslint-plugin-templateAngular Template rulestriageThis issue needs to be looked at and categorized by a maintainer

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions