JavaScript Data GridLocalisation

The grid's displayed text can be customised for localisation. You can achieve this by providing locale information in the required language. Use the localeText property to apply one of the provided locales, create a custom locale, or use the getLocaleText callback to integrate the grid with your application's localisation system.

Provided Locales

The default language of the grid is American English, however, we provide a number of translations that can be used as a starting point for commonly requested languages:

LanguageBCP47 TagLocale Module
Arabic (Egyptian)ar-EGAG_GRID_LOCALE_EG
Bulgarianbg-BGAG_GRID_LOCALE_BG
Chinese (Hong Kong)zh-HKAG_GRID_LOCALE_HK
Chinese (Simplified)zh-CNAG_GRID_LOCALE_CN
Chinese (Taiwan)zh-TWAG_GRID_LOCALE_TW
Croatianhr-HRAG_GRID_LOCALE_HR
Czechcs-CZAG_GRID_LOCALE_CZ
Danishda-DKAG_GRID_LOCALE_DK
Dutchnl-NLAG_GRID_LOCALE_NL
Finnishfi-FIAG_GRID_LOCALE_FI
Frenchfr-FRAG_GRID_LOCALE_FR
Germande-DEAG_GRID_LOCALE_DE
Greekel-GRAG_GRID_LOCALE_GR
Hebrewhe-ILAG_GRID_LOCALE_IL
Hungarianhu-HUAG_GRID_LOCALE_HU
Italianit-ITAG_GRID_LOCALE_IT
Japaneseja-JPAG_GRID_LOCALE_JP
Koreanko-KRAG_GRID_LOCALE_KR
Norwegian (Bokmål)nb-NOAG_GRID_LOCALE_NO
Persianfa-IRAG_GRID_LOCALE_IR
Polishpl-PLAG_GRID_LOCALE_PL
Portuguesept-PTAG_GRID_LOCALE_PT
Portuguese (Brazil)pt-BRAG_GRID_LOCALE_BR
Romanianro-ROAG_GRID_LOCALE_RO
Slovaksk-SKAG_GRID_LOCALE_SK
Spanishes-ESAG_GRID_LOCALE_ES
Swedishsv-SEAG_GRID_LOCALE_SE
Turkishtr-TRAG_GRID_LOCALE_TR
Ukrainianuk-UAAG_GRID_LOCALE_UA
Urdu (Pakistan)ur-PKAG_GRID_LOCALE_PK
Vietnamesevi-VNAG_GRID_LOCALE_VN

Translations are provided as an illustration only and are not guaranteed to be accurate or error free. They are designed to show developers where to store their chosen phrase or spelling variant in the target language.

Using a Provided Locale Module

All of the provided locales listed above are available in the @ag-grid-community/locale package. To use any of the provided locales in your application, follow these steps:

First, import the desired locale module from the @ag-grid-community/locale package. For example, to use the German locale, import AG_GRID_LOCALE_DE:

import { AG_GRID_LOCALE_DE } from '@ag-grid-community/locale';

Next, assign the imported locale object to the localeText property in your Grid Options:

const gridOptions = {
    localeText: AG_GRID_LOCALE_DE,

    // other grid options ...
}

Finally, ensure the @ag-grid-community/locale module is listed as a dependency in your application's package configuration:

"dependencies": {
    "@ag-grid-community/locale": "~32.0.2",
    ...
}

The following example demonstrates applying the AG_GRID_LOCALE_DE locale to the grid:

Some localisation variables have ${variable} in them. When this occurs, it means that part of the string will be replaced by a variable value.

Customising a Provided Locale

If you want to customise a provided locale, you can do so by creating a new object and merging the provided locale with your customisations.

import { AG_GRID_LOCALE_DE } from '@ag-grid-community/locale';

const customGermanLocale = {
    ...AG_GRID_LOCALE_DE,
    // customise the locale here
};

const gridOptions = {
    localeText: customGermanLocale,
};

The example below shows this in action by adding a "zzz" prefix to each Locale key to create a new zzzLocale object, and then applying this customised locale to the grid:

Changing Locale

The grid uses the locale as it is needed. It does not refresh as the locale changes. If your application allows changing the locale for the application, you must destroy and recreate the grid for it to use the new locale.

Creating a Locale

By default, the grid does not require a locale. If no locale is provided, the grid will default to English. If a locale is provided but is missing values, the default English will be used for the missing values.

All locales provided are listed above, and are also available in the @ag-grid-community/locale package.

To support other languages, the first step is to import the @ag-grid-community/locale package and reference the locale you're interested in.

There is a single locale file which covers all modules across all of AG Grid Enterprise and AG Grid Community. This was done on purpose as having a separate localisation file for each module would be harder to manage.

Locale Callback

Providing a locale for the grid does not fit in with localisation libraries or localisation for a broader application. If you want the grid to take from an application wide locale, then implement the getLocaleText to act as a bridge between the grid and the applications localisation.

The example below shows providing a callback for the grid's localisation. The example for simplicity just returns the default value in upper case. In a real world application, the callback would use the applications localisation.

In a real world application, the callback would look something like this:

const getLocaleText = (params) => {
    // to avoid key clash with external keys, we add 'grid' to the start of each key.
    const gridKey = 'grid.' + params.key;

    // look the value up using an application wide service
    return applicationLocaleService(gridKey);
}