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鈥檒l occasionally send you account related emails.

Already on GitHub? Sign in to your account

Avoid child elements in translation units #92

Open
rajsite opened this issue Jun 2, 2022 · 1 comment
Open

Avoid child elements in translation units #92

rajsite opened this issue Jun 2, 2022 · 1 comment
Labels
enhancement New feature or request needs-proposal Needs investigation and a proposal to implement

Comments

@rajsite
Copy link
Member

rajsite commented Jun 2, 2022

Elements in an angular template with the i18n attribute should not have child elements. For example:

馃憥 Incorrect code for the rule

<nimble-toggle-button i18n>
    <nimble-thumbtack-icon slot="start"></nimble-thumbtack-icon>
        Pin navigation
</nimble-toggle-button>

馃憤 Correct code for the rule

<nimble-toggle-button>
    <nimble-icon-thumbtack slot="start"></nimble-icon-thumbtack>
    <span i18n>Pin navigation</span>
</nimble-toggle-button>

Unfortunately, angular eslint does not have a rule for that yet, but there is an existing issue: angular-eslint/angular-eslint#930

For more about why we want to avoid this behavior see this Skyline PR. This is also currently documented on the Angular Internationalization page,

@mure mure added the enhancement New feature or request label Jun 30, 2022
@rajsite rajsite added the blocked Blocked on a external dependency label Sep 8, 2022
@jattasNI
Copy link
Collaborator

One idea to fix this would be to write a custom script (not an ESLint plugin) that scans the extracted XLIFF/JSON strings and fails if it contains any HTML tags. Clients would call that CLI tool from their lint/build script.

Or we could contribute a custom rule in angular-eslint.

@jattasNI jattasNI removed the blocked Blocked on a external dependency label Apr 20, 2023
@rajsite rajsite added the needs-proposal Needs investigation and a proposal to implement label Apr 20, 2023
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
enhancement New feature or request needs-proposal Needs investigation and a proposal to implement
Projects
None yet
Development

No branches or pull requests

3 participants