Skip to content

Commit

Permalink
fix(core): improve the "missing $localize" error message (angular#3…
Browse files Browse the repository at this point in the history
…2491)

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 angular#32491
  • Loading branch information
petebacondarwin authored and arnehoek committed Sep 26, 2019
1 parent de6b459 commit a520379
Show file tree
Hide file tree
Showing 3 changed files with 5 additions and 3 deletions.
2 changes: 1 addition & 1 deletion integration/side-effects/snapshots/core/esm2015.js
Original file line number Diff line number Diff line change
Expand Up @@ -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.");
};
2 changes: 1 addition & 1 deletion integration/side-effects/snapshots/core/esm5.js
Original file line number Diff line number Diff line change
Expand Up @@ -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.");
};
4 changes: 3 additions & 1 deletion packages/core/src/core.ts
Original file line number Diff line number Diff line change
Expand Up @@ -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 a520379

Please sign in to comment.