Gathering detailed insights and metrics for ra-i18n-polyglot
Gathering detailed insights and metrics for ra-i18n-polyglot
Gathering detailed insights and metrics for ra-i18n-polyglot
Gathering detailed insights and metrics for ra-i18n-polyglot
A frontend Framework for single-page applications on top of REST/GraphQL APIs, using TypeScript, React and Material Design
npm install ra-i18n-polyglot
Typescript
Module System
Node Version
NPM Version
TypeScript (98.05%)
JavaScript (1.61%)
Shell (0.16%)
Makefile (0.09%)
HTML (0.08%)
Total Downloads
0
Last Day
0
Last Week
0
Last Month
0
Last Year
0
MIT License
25,989 Stars
22,988 Commits
5,384 Forks
269 Watchers
42 Branches
616 Contributors
Updated on Jul 06, 2025
Minified
Minified + Gzipped
Latest Version
5.9.1
Package Id
ra-i18n-polyglot@5.9.1
Unpacked Size
25.34 kB
Size
6.03 kB
File Count
14
NPM Version
lerna/7.1.5/node@v20.19.3+x64 (linux)
Node Version
20.19.3
Published on
Jul 03, 2025
Cumulative downloads
Total Downloads
2
3
Polyglot i18n provider for react-admin, the frontend framework for building admin applications on top of REST/GraphQL services. It relies on polyglot.js, which uses JSON files for translations.
1npm install --save ra-i18n-polyglot
Wrap the function exported by this package around a function returning translation messages based on a locale to produce a valid i18nProvider
.
1import * as React from "react"; 2import { Admin, Resource } from 'react-admin'; 3import polyglotI18nProvider from 'ra-i18n-polyglot'; 4import englishMessages from 'ra-language-english'; 5import frenchMessages from 'ra-language-french'; 6 7const messages = { 8 fr: frenchMessages, 9 en: englishMessages, 10}; 11 12const i18nProvider = polyglotI18nProvider( 13 locale => messages[locale], 14 'en', 15 [ 16 { locale: 'en', name: 'English' }, 17 { locale: 'fr', name: 'Français' }, 18 ] 19); 20 21const App = () => ( 22 <Admin i18nProvider={i18nProvider}> 23 ... 24 </Admin> 25); 26 27export default App;
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:
1{ 2 ra: { 3 action: { 4 delete: 'Delete', 5 show: 'Show', 6 list: 'List', 7 save: 'Save', 8 create: 'Create', 9 edit: 'Edit', 10 cancel: 'Cancel', 11 }, 12 ... 13 }, 14}
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.
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.
1import polyglotI18nProvider from 'ra-i18n-polyglot'; 2import englishMessages from 'ra-language-english'; 3 4const asyncMessages = { 5 fr: () => import('ra-language-french').then(messages => messages.default), 6 it: () => import('ra-language-italian').then(messages => messages.default), 7}; 8 9const messagesResolver = locale => { 10 if (locale === 'en') { 11 // initial call, must return synchronously 12 return englishMessages; 13 } 14 // change of locale after initial call returns a promise 15 return asyncMessages[params.locale](); 16} 17 18 const i18nProvider = polyglotI18nProvider(messageResolver, "en", [ 19 { locale: 'en', name: 'English' }, 20 { locale: 'fr', name: 'Français' }, 21 { locale: 'it', name: 'Italiano' }, 22]);
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.
1const messages = { 2 'hello_name': 'Hello, %{name}', 3 'count_beer': 'One beer |||| %{smart_count} beers', 4}; 5 6// interpolation 7translate('hello_name', { name: 'John Doe' }); 8=> 'Hello, John Doe.' 9 10// pluralization 11translate('count_beer', { smart_count: 1 }); 12=> 'One beer' 13 14translate('count_beer', { smart_count: 2 }); 15=> '2 beers' 16 17// default value 18translate('not_yet_translated', { _: 'Default translation' }); 19=> 'Default translation'
To find more detailed examples, please refer to http://airbnb.io/polyglot.js/
No vulnerabilities found.
Reason
no dangerous workflow patterns detected
Reason
30 commit(s) and 11 issue activity found in the last 90 days -- score normalized to 10
Reason
license file detected
Details
Reason
no binaries found in the repo
Reason
SAST tool is run on all commits
Details
Reason
Found 12/13 approved changesets -- score normalized to 9
Reason
no effort to earn an OpenSSF best practices badge detected
Reason
security policy file not detected
Details
Reason
detected GitHub workflow tokens with excessive permissions
Details
Reason
branch protection not enabled on development/release branches
Details
Reason
project is not fuzzed
Details
Reason
dependency not pinned by hash detected -- score normalized to 0
Details
Reason
13 existing vulnerabilities detected
Details
Score
Last Scanned on 2025-06-30
The Open Source Security Foundation is a cross-industry collaboration to improve the security of open source software (OSS). The Scorecard provides security health metrics for open source projects.
Learn MoreLast Day
0%
NaN
Compared to previous day
Last Week
0%
NaN
Compared to previous week
Last Month
0%
NaN
Compared to previous month
Last Year
0%
NaN
Compared to previous year