Set the runtime locale manually

The initial installation of Angular already contains locale data for English in the United States (en-US). The Angular CLI automatically includes the locale data and sets the LOCALE_ID value when you use the --localize option with ng build command.

To manually set the runtime locale of an application to one other than the automatic value, complete the following actions.

  1. Search for the Unicode locale ID in the language-locale combination in the @angular/common/locales/ directory.
  2. Set the LOCALE_ID token.

The following example sets the value of LOCALE_ID to fr for French.

import { LOCALE_ID, NgModule } from '@angular/core';
import { BrowserModule } from '@angular/platform-browser';

import { AppComponent } from '../src/app/app.component';

  imports: [ BrowserModule ],
  declarations: [ AppComponent ],
  providers: [ { provide: LOCALE_ID, useValue: 'fr' } ],
  bootstrap: [ AppComponent ]
export class AppModule { }
Last reviewed on Mon Feb 28 2022

© 2010–2023 Google, Inc.
Licensed under the Creative Commons Attribution License 4.0.