Online

Refer to locales by ID

Angular uses the Unicode locale identifier \(Unicode locale ID\) to find the correct locale data for internationalization of text strings.

A locale ID specifies the language, country, and an optional code for further variants or subdivisions. A locale ID consists of the language identifier, a hyphen \(-\) character, and the locale extension.

html
{language_id}-{locale_extension}

Many countries share the same language, but differ in usage. The differences include grammar, punctuation, formats for currency, decimal numbers, dates, and so on.

For the examples in this guide, use the following languages and locales.

LanguageLocaleUnicode locale ID
EnglishCanadaen-CA
EnglishUnited States of Americaen-US
FrenchCanadafr-CA
FrenchFrancefr-FR

The [Angular repository][GithubAngularAngularTreeMasterPackagesCommonLocales] includes common locales.

Set the source locale ID

Use the Angular CLI to set the source language in which you are writing the component template and code.

By default, Angular uses en-US as the source locale of your project.

To change the source locale of your project for the build, complete the following actions.

  1. Open the [angular.json][GuideWorkspaceConfig] workspace build configuration file.
  2. Add or modify the sourceLocale field inside the i18n section:
json
{
  "projects": {
    "your-project": {
      "i18n": {
        "sourceLocale": "ca" // Use your desired locale code
      }
    }
  }
}

What's next

[GuideWorkspaceConfig]: reference/configs/workspace-config 'Angular workspace configuration | Angular' [GithubAngularAngularTreeMasterPackagesCommonLocales]: https://github.com/angular/angular/tree/main/packages/common/locales 'angular/packages/common/locales | angular/angular | GitHub' [RfcEditorInfoBcp47]: https://www.rfc-editor.org/info/bcp47 'BCP 47 | RFC Editor' [UnicodeCldrDevelopmentCoreSpecification]: https://cldr.unicode.org/index/cldr-spec 'Core Specification | Unicode CLDR Project' [UnicodeCldrDevelopmentCoreSpecificationLocaleID]: https://cldr.unicode.org/index/cldr-spec/picking-the-right-language-code 'Unicode Language and Locale Identifiers - Core Specification | Unicode CLDR Project'