On this page
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.
- Search for the Unicode locale ID in the language-locale combination in the
@angular/common/locales/
directory. - 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 Mon Feb 28 2022
© 2010–2022 Google, Inc.
Licensed under the Creative Commons Attribution License 4.0.
https://v13.angular.io/guide/i18n-optional-manual-runtime-locale