Repository navigation
Description
Which @angular/* package(s) are relevant/releated to the feature request?
@angular/compiler-cli
Description
In internationalized applications, each piece of text in an Angular template requires the i18n attribute. This can contain a description, and there are other i18n- attributes which provide localized versions of user-visible text (such as i18n-title). The attributes are easy to forget, especially edge cases like i18n-title. There should be some kind of conformance check which verifies that all text in an application is marked for internationalization.
Proposed solution
We could have an extended diagnostic which requires that every message in the compilation is marked for i18n and warns / errors for messages missing the relevant attribute. It could also warn on attributes like title and suggest i18n-title as an alternative.
Since not every app is internationalized, this check probably needs to be off by default, but having a one line config change like:
{
"angularCompilerOptions": {
"extendedDiagnostics": {
"checks": {
+ "i18nMessages": "error"
}
}
}
}Would be a really easy way to make sure no messages fall through the cracks.
We may want some kind of i18n-ignore attribute to allow some messages to be skipped. I've seen this happen for debug UI which doesn't typically need to be translated.
Alternatives considered
There might be a community based solution which is able to do this, but I don't recall any offhand.
Activity
angular-robot commentedon Jan 28, 2022
This feature request is now candidate for our backlog! In the next phase, the community has 60 days to upvote. If the request receives more than 20 upvotes, we'll move it to our consideration list.
You can find more details about the feature request process in our documentation.
angular-robot commentedon Mar 8, 2022
Just a heads up that we kicked off a community voting process for your feature request. There are 20 days until the voting process ends.
Find more details about Angular's feature request process in our documentation.
angular-robot commentedon Mar 28, 2022
Thank you for submitting your feature request! Looks like during the polling process it didn't collect a sufficient number of votes to move to the next stage.
We want to keep Angular rich and ergonomic and at the same time be mindful about its scope and learning journey. If you think your request could live outside Angular's scope, we'd encourage you to collaborate with the community on publishing it as an open source package.
You can find more details about the feature request process in our documentation.
studioromeo commentedon May 17, 2022
It would be handy if the compiler could warn about using i18n when theres no static text to translate eg
Sometimes theres confusion on what i18n can pick up where people think it can determine all variations of
titlewhen actually it creates a translation like thisWhere the title is interpolated into the text and the title isn't localized.
I guess a useful suggestion from the compiler could be to see if the user can add
$localizeto wheretitleis defined but I also worry that could be confusing iftitleis a bit more complex than a simpletitle = 'Hello World'.Andrew-Marks-Trisept commentedon Jun 3, 2022
This would be fantastic, as long as (like you said), there is an easy way to override it for certain cases or false positives. And don't forget about messages defined in TS using
$localize.Edit: I guess the ones that use
$localizealready are marked for translation. I guess there's probably no good way to make sure text from the TS files is translated...