How do you report missing translations?

By default, When translation is missing, it generates a warning message such as "Missing translation for message 'somekey'". But you can configure with a different level of message in Angular compiler as below,

  1. Error: It throws an error. If you are using AOT compilation, the build will fail. But if you are using JIT compilation, the app will fail to load.
  2. Warning (default): It shows a 'Missing translation' warning in the console or shell.
  3. Ignore: It doesn't do anything.

If you use AOT compiler then you need to perform changes in configurations section of your Angular CLI configuration file, angular.json.

"configurations": {
...
"de": {
...
"i18nMissingTranslation": "error"
}
}

If you use the JIT compiler, specify the warning level in the compiler config at bootstrap by adding the 'MissingTranslationStrategy' property as below,

import { MissingTranslationStrategy } from '@angular/core';
import { platformBrowserDynamic } from '@angular/platform-browser-dynamic';
import { AppModule } from './app/app.module';
platformBrowserDynamic().bootstrapModule(AppModule, {
missingTranslation: MissingTranslationStrategy.Error,
providers: [
// ...
],
});

July 30, 2022
190