@reactizer/intl
TypeScript icon, indicating that this package has built-in type declarations

0.28.0 • Public • Published

@reactizer/intl

A minimalistic node-polyglot based React hooks-based i18n solution.

API

API of the t function found in the context mirrors node-polyglot's API.

Core

Mount your provider:

import { IntlProvider } from "@reactizer/intl";

const locale = {
  id: "en-GB",
  translations: {/* ... */},
};

<IntlProvider locale={locale} onChange={id => fetch(/* ... */)}>
  <Root />
</IntlProvider>

Use the useIntl hook (or IntlConsumer):

import { useIntl } from "@reactizer/intl";

const MyComponent = () => {
  const intl = useIntl();
  
  return (
    /* ... */
  );
};

Translate

There's a Translate component:

import Translate from "@reactizer/intl/lib/Translate";

<Translate t="lmao" />

License

MIT

Readme

Keywords

none

Package Sidebar

Install

npm i @reactizer/intl

Weekly Downloads

11

Version

0.28.0

License

MIT

Unpacked Size

10.4 kB

Total Files

10

Last publish

Collaborators

  • oreqizer