# ra-i18n-polyglot

> Polyglot i18n provider for react-admin

Latest version **5.15.3** (published 2026-09-04) · MIT license · 0 weekly downloads

## Install

```sh
npm install ra-i18n-polyglot
pnpm add ra-i18n-polyglot
yarn add ra-i18n-polyglot
bun add ra-i18n-polyglot
```

## Health

**Score 70/100 (B)** — status: active.

Positive: has types; esm support; no vulnerabilities; recently updated; high maintenance score; popular repo.

Warnings: low downloads.

## Facts

| | |
|---|---|
| Version | 5.15.3 |
| Published | 2026-09-04 |
| First published | 2019-10-01 |
| Weekly downloads | 0 |
| License | MIT |
| TypeScript types | bundled |
| Module format | ESM + CommonJS |
| Dependencies | 2 |
| Unpacked size | 25.6 KB |
| Known vulnerabilities | 0 |
| Install scripts | no |
| GitHub stars | 26937 |
| Maintainers | fzaninotto, thiery, slax57 |

## Links

- npm: https://www.npmjs.com/package/ra-i18n-polyglot
- Repository: https://github.com/marmelab/react-admin
- Homepage: https://github.com/marmelab/react-admin#readme
- Issues: https://github.com/marmelab/react-admin/issues
- npm.io page: https://npm.io/package/ra-i18n-polyglot

## Dependencies (2)

- [ra-core](https://npm.io/package/ra-core.md) ^5.15.3
- [node-polyglot](https://npm.io/package/node-polyglot.md) ^2.2.2

## Recent versions

- 5.15.3 (latest) — 2026-09-04
- 5.0.0-rc.0 (next) — 2024-06-17
- 5.15.2 — 2026-09-01
- 5.15.0 — 2026-06-24
- 5.14.7 — 2026-05-18
- 5.14.6 — 2026-04-21
- 5.14.5 — 2026-03-31
- 5.14.4 — 2026-03-10
- 5.14.3 — 2026-02-27
- 5.14.2 — 2026-02-16
- 5.14.1 — 2026-01-30
- 5.14.0 — 2026-01-23
- 5.13.6 — 2026-01-16
- 5.13.5 — 2026-01-09
- 5.13.4 — 2025-12-16
- … 286 more at https://npm.io/package/ra-i18n-polyglot/versions

## README

# Polyglot i18n provider for react-admin

Polyglot i18n provider for [react-admin](https://github.com/marmelab/react-admin), the frontend framework for building admin applications on top of REST/GraphQL services. It relies on [polyglot.js](https://airbnb.io/polyglot.js/), which uses JSON files for translations.

[![react-admin-demo](https://marmelab.com/react-admin/img/react-admin-demo-still.png)](https://www.youtube.com/watch?v=bJEo1O1oT6o)

## Installation

```sh
npm install --save ra-i18n-polyglot
```

## Usage

Wrap the function exported by this package around a function returning translation messages based on a locale to produce a valid `i18nProvider`.

```jsx
import * as React from "react";
import { Admin, Resource } from 'react-admin';
import polyglotI18nProvider from 'ra-i18n-polyglot';
import englishMessages from 'ra-language-english';
import frenchMessages from 'ra-language-french';

const messages = {
    fr: frenchMessages,
    en: englishMessages,
};

const i18nProvider = polyglotI18nProvider(
    locale => messages[locale],
    'en',
    [
        { locale: 'en', name: 'English' },
        { locale: 'fr', name: 'Français' },
    ]
);

const App = () => (
    <Admin i18nProvider={i18nProvider}>
        ...
    </Admin>
);

export default App;
```

## Translation Messages

The `message` returned by the function argument should be a dictionary where the keys identify interface components, and values are the translated string. This dictionary is a simple JavaScript object looking like the following:

```js
{
    ra: {
        action: {
            delete: 'Delete',
            show: 'Show',
            list: 'List',
            save: 'Save',
            create: 'Create',
            edit: 'Edit',
            cancel: 'Cancel',
        },
        ...
    },
}
```

All core translations are in the `ra` namespace, in order to prevent collisions with your own custom translations. The root key used at runtime is determined by the value of the `locale` prop.

The default messages are available [here](https://github.com/marmelab/react-admin/blob/master/packages/ra-language-english/src/index.ts).

## Asynchronous Locale Change

The function passed as parameter of `polyglotI18nProvider` can return a *Promise* for messages instead of a messages object. This lets you lazy load messages upon language change.

Note that the messages for the default locale (used by react-admin for the initial render) must be returned in a synchronous way. 

```jsx
import polyglotI18nProvider from 'ra-i18n-polyglot';
import englishMessages from 'ra-language-english';

const asyncMessages = {
    fr: () => import('ra-language-french').then(messages => messages.default),
    it: () => import('ra-language-italian').then(messages => messages.default),
};

const messagesResolver = locale => {
    if (locale === 'en') {
        // initial call, must return synchronously
        return englishMessages;
    }
    // change of locale after initial call returns a promise
    return asyncMessages[params.locale]();
}

 const i18nProvider = polyglotI18nProvider(messageResolver, "en", [
    { locale: 'en', name: 'English' },
    { locale: 'fr', name: 'Français' },
    { locale: 'it', name: 'Italiano' },
]);
```

## Using Specific Polyglot Features

Polyglot.js is a fantastic library: in addition to being small, fully maintained, and totally framework agnostic, it provides some nice features such as interpolation and pluralization, that you can use in react-admin.

```js
const messages = {
    'hello_name': 'Hello, %{name}',
    'count_beer': 'One beer |||| %{smart_count} beers',
};

// interpolation
translate('hello_name', { name: 'John Doe' });
=> 'Hello, John Doe.'

// pluralization
translate('count_beer', { smart_count: 1 });
=> 'One beer'

translate('count_beer', { smart_count: 2 });
=> '2 beers'

// default value
translate('not_yet_translated', { _: 'Default translation' });
=> 'Default translation'
```

To find more detailed examples, please refer to [http://airbnb.io/polyglot.js/](https://airbnb.io/polyglot.js/)

---
_Source: https://npm.io/package/ra-i18n-polyglot · Machine-readable twin of the npm.io package page. Health data is recomputed on every publish._
