Skip to content
Permalink
Browse files

fix(core): improve the "missing `$localize`" error message (#32491)

We need to be clearer to developers who upgrade to v9 (next) and get this
error, why they have a problem and what they have to do about it.

Once we have a better CLI schematics story, where this import will be
included by default in new applications and a CLI migration will add it
when upgrading apps to v9, we could simplify or remove this error message.

PR Close #32491
  • Loading branch information...
petebacondarwin authored and matsko committed Sep 5, 2019
1 parent da42a76 commit a9ff48e67fc3fbc4bebec2de179687c4e342ccd0
@@ -13,5 +13,5 @@ const __global = "undefined" !== typeof global && global;
const _global = __globalThis || __global || __window || __self;

if (ngDevMode) _global.$localize = _global.$localize || function() {
throw new Error("The global function `$localize` is missing. Please add `import '@angular/localize';` to your polyfills.ts file.");
throw new Error("It looks like your application or one of its dependencies is using i18n.\n" + "Angular 9 introduced a global `$localize()` function that needs to be loaded.\n" + "Please add `import '@angular/localize';` to your polyfills.ts file.");
};
@@ -15,5 +15,5 @@ var __global = "undefined" !== typeof global && global;
var _global = __globalThis || __global || __window || __self;

if (ngDevMode) _global.$localize = _global.$localize || function() {
throw new Error("The global function `$localize` is missing. Please add `import '@angular/localize';` to your polyfills.ts file.");
throw new Error("It looks like your application or one of its dependencies is using i18n.\n" + "Angular 9 introduced a global `$localize()` function that needs to be loaded.\n" + "Please add `import '@angular/localize';` to your polyfills.ts file.");
};
@@ -45,6 +45,8 @@ if (ngDevMode) {
// tslint:disable-next-line: no-toplevel-property-access
global.$localize = global.$localize || function() {
throw new Error(
'The global function `$localize` is missing. Please add `import \'@angular/localize\';` to your polyfills.ts file.');
'It looks like your application or one of its dependencies is using i18n.\n' +
'Angular 9 introduced a global `$localize()` function that needs to be loaded.\n' +
'Please add `import \'@angular/localize\';` to your polyfills.ts file.');
};
}

0 comments on commit a9ff48e

Please sign in to comment.
You can’t perform that action at this time.