Locales

Locales in amCharts 4 are used to apply translations to common prompts, as well as national settings, like number and date formats.

Using locales

By default, all charts and objects are created using a so called International English.

Loading a locale

Before a locale can be used, it needs to be loaded, just like any other resource:

// ... other imports
import am4lang_en_US from "@amcharts/amcharts4/lang/en_US";
<!-- other includes -->
<script src="//www.amcharts.com/lib/4/lang/en_US.js"></script>

NOTE In JavaScript, when you load a locale, it will be accessible in handy am4lang_[locale] object. In TypeScript, you can name imported locale whatever you want, but for the sake of this article (and anywhere else in our documentation), we're going to use the same naming convention, e.g. am4lang_en_US.

Setting a locale

Each object in amCharts 4 universe has a property language. It's an instance of the Language class, which is responsible for translating stuff to whatever locale you have set for your chart. (if it's other than International English)

So that Language knows which locale to use, it has a property, predictably named locale, which you can set to a locale reference we've already checked how to load.

chart.language.locale = am4lang_en_US;
chart.language.locale = am4lang_en_US;
{
  // ...
  "language": {
    "locale": "en_US"
  }
}

US English

It's worth mentioning a special bundled locale "en_US". While it does not add any new prompt translations, it overrides default international number and date formats with the ones commonly used in the United States.

Bundled locales

At the moment of the Preview Release there are only these locales bundled with amCharts 4. We'll be adding new translations, hopefully donated by the community, in the very near future.

Locale Comment
en_CA Canadian English
en_US U.S. English
lt_LT Lithuanian
nl_NL Dutch
pt_BR Brazilian Portuguese
ru_RU Russian

Creating and updating locales

Please refer to the tutorial "Creating Locales" for in-depth information on how to updated existing locales as well as create and contribute new ones.