npm package discovery and stats viewer.

Discover Tips

  • General search

    [free text search, go nuts!]

  • Package details

    pkg:[package-name]

  • User packages

    @[username]

Sponsor

Optimize Toolset

I’ve always been into building performant and accessible sites, but lately I’ve been taking it extremely seriously. So much so that I’ve been building a tool to help me optimize and monitor the sites that I build to make sure that I’m making an attempt to offer the best experience to those who visit them. If you’re into performant, accessible and SEO friendly sites, you might like it too! You can check it out at Optimize Toolset.

About

Hi, 👋, I’m Ryan Hefner  and I built this site for me, and you! The goal of this site was to provide an easy way for me to check the stats on my npm packages, both for prioritizing issues and updates, and to give me a little kick in the pants to keep up on stuff.

As I was building it, I realized that I was actually using the tool to build the tool, and figured I might as well put this out there and hopefully others will find it to be a fast and useful way to search and browse npm packages as I have.

If you’re interested in other things I’m working on, follow me on Twitter or check out the open source projects I’ve been publishing on GitHub.

I am also working on a Twitter bot for this site to tweet the most popular, newest, random packages from npm. Please follow that account now and it will start sending out packages soon–ish.

Open Software & Tools

This site wouldn’t be possible without the immense generosity and tireless efforts from the people who make contributions to the world and share their work via open source initiatives. Thank you 🙏

© 2024 – Pkg Stats / Ryan Hefner

@yeutech-lab/react-admin-intl

v1.1.4

Published

Quickly tweak react-admin and replace internationalization module polyglot with react-intl. It can work thanks to your resolve aliases babel or webpack configuration.

Downloads

14

Readme

react-admin-intl

Build Status npm Version License NPM monthly downloads NPM total downloads npm Version Module formats Coverage Quality gate status

Quickly tweak react-admin and replace internationalization module polyglot with react-intl. It can work thanks to your resolve aliases babel or webpack configuration.

Table of Contents


Installation

$ npm install @yeutech-lab/react-admin-intl --save-dev

swapPolyglotWithReactIntl

Swap polyglot with our react-intl adapter

This will replace the internationalization of react-admin (It use polyglot). Instead, it will use react-intl Because of that, default messages provided by react-admin won't be compatible anymore. This is why you must use this package to import the react-intl version of messages:

$ npm install @yeutech-lab/ra-language-intl --save

Visit ra-language-intl documentation to view available or add locale(s) translation(s).

Parameters

  • webpackConfig object Your application webpack configuration

Examples

const swapPolyglotWithReactIntl = require('@yeutech-lab/react-admin-intl/lib/swapPolyglotWithReactIntl');

// later in your application when you create your webpack configuration
webpackConfig = swapPolyglotWithReactIntl(webpackConfig);

Returns object webpackConfig - The edited webpack config

createI18nProvider

Create a i18nProvider used for retrieving translation messages. The i18nProvider is a function that accept a locale as a parameter, it return:

  • a messages object directly for the default locale
  • an unresolved Promise that is fetching the message object for the locale

This permit to do application code splitting on language, and load new language only if the user change locale.

Ideally, you create a i18n folder in the src folder of your project and had all the languages here.

src/i18n
     ├── de.js
     ├── en.js
     ├── fr.js
     ├── i18nProvider.js
     ├── index.js
     ├── translation
     │   ├── de.json
     │   ├── en.json
     │   ├── fr.json
     │   └── vi.json
     └── vi.js

The i18n/index.js file export the default application locale and the list of applications locales

Parameters

  • options Object createI18nProvider options
  • default string options.locale - Default application locale ISO3166 alpha 2 (See: https://en.wikipedia.org/wiki/ISO_3166-1_alpha-2) (optional, default en)
  • default string options.locales - List of application locales available ISO3166 (optional, default ['en'])
  • default (function | object) options.defaultMessages - A function or an object which return messages from require(locale) (optional, default {})
  • default Array<Promise> options.deferredMessagesList - A map from locales, return a function that return messages from import(locale) (optional, default [])

Examples

import createI18nProvider from '@yeutech-lab/react-admin-intl';
import { appLocales as locales, DEFAULT_LOCALE as locale } from './index';

// this will create the i18nProvider
const { i18nProvider, messages } = createI18nProvider({
  locale,
  locales,
  // this must be a function, otherwise webpack does not support dynamic import
  defaultMessages: () => require(`./${locale}`),
  deferredMessagesList: locales.map((l) => () => import(`./${l}`))
});

Returns i18nProvider

Documentation

Read react-admin-intl documentation.

Contributing

If you want to contribute to react-admin-intl please see our contributing and community guidelines, they'll help you get set up locally and explain the whole process.

Please also note that all repositories under the yeutech-lab organization follow our Code of Conduct, make sure to review and follow it.

License MIT

Copyright 2019 Yeutech Company Limited

Permission is hereby granted, free of charge, to any person obtaining a copy of this software and associated documentation files (the "Software"), to deal in the Software without restriction, including without limitation the rights to use, copy, modify, merge, publish, distribute, sublicense, and/or sell copies of the Software, and to permit persons to whom the Software is furnished to do so, subject to the following conditions:

The above copyright notice and this permission notice shall be included in all copies or substantial portions of the Software.

THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.