Empresas
Empregos
  • Sobre nós
  • Soluções
    • Publicação de vagas
      Publique sua vaga e receba candidatos qualificados em 48h.
    • Avaliações de candidatos
      Mais de 500 testes técnicos e psicológicos, mais anti-fraude.
    • Headhunting
      Busca executiva personalizada do início ao fim.
    • Folha de Pagamento + EOR
      Dispersão de folha e EOR em mais de 15 países da LATAM.
  • Preços
  • Empregos

0

580
Visualizações
Angular 9 introduced a global '$localize()' function that needs to be loaded

I'm getting the following error in my new angular project setup.

Installed Packages and its versions

ERROR Error: Uncaught (in promise): Error: It looks like your application or one of its dependencies is using i18n. Angular 9 introduced a global $localize() function that needs to be loaded. Please add import '@angular/localize'; to your polyfills.ts file. Error: It looks like your application or one of its dependencies is using i18n. Angular 9 introduced a global $localize() function that needs to be loaded.

Note: I came from the following. It suggests falling back to old version. https://github.com/angular/angular/issues/32508

over 4 years ago · Santiago Trujillo
13 Respostas
Responde à pergunta

0

You need to make sure you have the @angular/localize package first:

npm install @angular/localize --save

Then, import '@angular/localize/init' in your polyfills.ts file just like the error says

over 4 years ago · Santiago Trujillo Relatório

0

Angular 9 introduced a global $localize() function that needs to be loaded if you use i18n.

Run ng add @angular/localize from the Angular CLI.

Then make sure you have:
- @angular/localize as a dependency in your app's package.json
- import '@angular/localize/init' in your polyfills.ts

over 4 years ago · Santiago Trujillo Relatório

0

As the i18n attributes are now converted to $localize calls in the generated code, we need to load the $localize function.

The CLI offers a schematic to do this for you. Simply run: ng add @angular/localize

It will add the package to your dependencies and the necessary import to your polyfills (import '@angular/localize/init')

You can also refer to the following link for more explanation. https://blog.ninja-squad.com/2019/12/10/angular-localize/

over 4 years ago · Santiago Trujillo Relatório

0

The best way if you are using Angular CLI is to run

ng add @angular/localize

It will take care of it automatically

Or else

import '@angular/localize/init'; to your polyfills.ts

Tested with Angular 9

over 4 years ago · Santiago Trujillo Relatório

0

If you have many angular projects in same workspace, running ng add @angular/localize will add import statement import '@angular/localize/init' to polyfills.ts in default Project only,i think this will be fixed in later updates.

so you need to add import '@angular/localize/init' manually to polyfills.ts in other projects.

over 4 years ago · Santiago Trujillo Relatório

0

If you are running ng test and the above answer doesn't work, install the package and add

import "@angular/localize/init"

to polyfills-test.ts

over 4 years ago · Santiago Trujillo Relatório

0

The best way to do this is by using Angular CLI:

You just have to run the following command in terminal:

ng add @angular/localize

It will automatically install packages and will also add the import statement in polyfills.ts file.

The import statement is:

import '@angular/localize/init';

If you don't want to go through the CLI approach then you can manually enter the import statement in the polyfills.ts file. Also you have to do one more step is to add the below line in package.json under dependencies tag.

"dependencies":{
    ...
    "@angular/localize":"^9.1.0",
    ...    
}
over 4 years ago · Santiago Trujillo Relatório

0

This error started to appear after I upgraded a large Nx/Angular CLI application with multiple sub apps to Angular 10. The solution suggested in the error (Please run ng add @angular/localize from the Angular CLI) does not work if the application contains multiple apps. Each of these auto-generated app had its own polyfill.ts. I manually added the import (import '@angular/localize/init';) in each of the polyfill.ts file. To fix same error while running unit tests, I also had to add the import in test.ts file of libs.

over 4 years ago · Santiago Trujillo Relatório

0

You have to add this package

ng add @angular/localize

then add import '@angular/localize/init'; to your ployfills.ts

But if your tests that are failing in a library, you must add import '@angular/localize/init'; to your test.ts

over 4 years ago · Santiago Trujillo Relatório

0

run

npm install @angular/localize --save

Then, in your polyfills.ts

import '@angular/localize/init' 

this works for me

over 4 years ago · Santiago Trujillo Relatório

0

I changed my operating system because of this problem. And yesterday I found the cause of this problem. I was getting this issue due to a plugin I installed in Visual Studio Code. If you are using Angular9, do not install the first two plugins. You can install the third one.

enter image description here

over 4 years ago · Santiago Trujillo Relatório

0

I had this error while updating Angular version from 12 to 13. I followed the instructions:

  1. Run ng add @angular/localize
  2. import '@angular/localize/init' in your polyfills.ts

but it did not work for me. I already had @angular/localize in my modules and the import in the polyfills.ts file, after all my Angular 12 app was working fine.

To solve the issue, I had to update the "@ng-bootstrap/ng-bootstrap" version. I hope this suggestion can save some headache to someone, given that there was no apparent link between the outdated @ng-bootstrap/ng-bootstrap version and the error description.

over 4 years ago · Santiago Trujillo Relatório

0

For me this error appeared when running npm test so the solutions above did not help. To solve it I had to import localize in the jest.ts file. Just add:

import "@angular/localize/init";
over 4 years ago · Santiago Trujillo Relatório
Responde à pergunta
Encontrar trabalhos remotos

Descubra a nova forma de encontrar um emprego!

melhores empregos
Principais categorias de trabalho
Empresas
Postar vaga Preços Comercial
Jurídico
Termos e Condições Política de privacidade
© 2026 PeakU Inc. All Rights Reserved.
Andres GPT
Recomende algumas ofertas para mim
Preciso de ajuda