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.
@angular/common/locales/
directory.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 { }
© 2010–2023 Google, Inc.
Licensed under the Creative Commons Attribution License 4.0.
https://angular.io/guide/i18n-optional-manual-runtime-locale