angular / 12.2.13 / guide / i18n-optional-manual-runtime-locale.html /

Set the runtime locale manually

The inital 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 repository.
  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';

@NgModule({
  imports: [ BrowserModule ],
  declarations: [ AppComponent ],
  providers: [ { provide: LOCALE_ID, useValue: 'fr' } ],
  bootstrap: [ AppComponent ]
})
export class AppModule { }
Last reviewed on Thu Oct 07 2021

© 2010–2021 Google, Inc.
Licensed under the Creative Commons Attribution License 4.0.
https://v12.angular.io/guide/i18n-optional-manual-runtime-locale