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 🙏

© 2026 – Pkg Stats / Ryan Hefner

@gehrmanng/react-i18n

v0.3.1

Published

react-i18n provides functionalities for text translation and localization. Unlike many other i18n libraries with react-i18n you can store your default texts within the translation definitions. This way you don't have to duplicate default texts for many co

Readme

react-i18n

react-i18n provides functionalities for text translation and localization. Unlike many other i18n libraries with react-i18n you can store your default texts within the translation definitions. This way you don't have to duplicate default texts for many components.

npm version downloads license

Dependencies

react-i18n uses markdown-to-jxs for basic Markdown formatting.

Installation

Installing via npm:

npm install --save @gehrmanng/react-i18n

ES6:

import { I18nProvider } from "@gehrmanng/react-i18n";

Examples

Setup translations and the default / fallback language:

import { I18nProvider } from "@gehrmanng/react-i18n";

const translations = {
  en: {
    label: {
      example: {
        text: "This is a simple example text",
        currentDate: "The current date is: _date_"
      }
    }
  }
};

// Render the app
render(
  <I18nProvider defaultLanguage="en" translations={translations}>
    <App />
  </I18nProvider>,
  document.getElementById("root")
);

Setting the langauge:

import { I18nContext, TYPES } from "@gehrmanng/react-i18n";

function ExampleApp() {
  // Get the dispatch method from the i18n context
  const { dispatch } = useContext(I18nContext);

  const setLanguage = () => dispatch({ type: TYPES.SET_LANGUAGE, payload: "de" });

  return (
    <div>
      <button type="button" onClick={setLanguage}>
        Deutsch
      </button>
    </div>
  );
}

Use the I18n component:

// Local component and context imports
import I18n from "@gehrmanng/react-i18n";

function ExampleApp() {
  return (
    <div>
      <I18n i18nKey="label.example.text" />
    </div>
  );
}

Use the I18n component with variable text parts (same for HOC and hook):

// Local component and context imports
import I18n from "@gehrmanng/react-i18n";

function ExampleApp() {
  return (
    <div>
      <I18n i18nKey="label.example.currentDate" vars={{ currentDate: new Date() }} />
    </div>
  );
}

Use the i18n HOC:

import { withI18n } from "@gehrmanng/react-i18n";

class ExampleComponent extends PureComponent {
  static propTypes = {
    i18n: PropTypes.object.isRequired
  };

  render() {
    const { i18n } = this.props;
    const text = i18n.translate("label.example.text");
    return <span>{text}</span>;
  }
}

export default withI18n(ExampleComponent);

Use the i18n hook:

import { useI18n } from "@gehrmanng/react-i18n";

function ExampleApp() {
  const translate = useI18n();
  const text = translate("label.example.text");
  return <div>{text}</div>;
}

Use Markdown formatting:

markdown-to-jxs is used for basic Markdown formatting. Additional options as described in the markdown-to-jsx documentation are not yet supported.

const translations = {
  en: {
    label: {
      example: {
        text: "This is a **formatted** example text",
      }
    }
  }
};
...
import { useI18n } from "@gehrmanng/react-i18n";

function ExampleApp() {
  const translate = useI18n();
  // The second parameter enables Markdown formatting
  const text = translate("label.example.text", true);
  return <div>{text}</div>;
}

Result: This is a formatted example text

The HOC takes the same parameter as well, the <I18n> component takes a markdown attribute to enable formatting.

LICENSE

The project is licensed under the terms of MIT license