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

@emdc/i18n

v0.5.1

Published

i18n library

Readme

i18n

Dependencies

None

Benefits

  • Very simple usage. Add reducer and use provided methods.
  • Translations are divided between components.

API

  • i18n.setLocale(locale). Argument locale must be a string. This function change locale for all app.

  • Component.setLocale(locale). Is same.

  • this.props.setLocale(locale). Is same.

  • i18n.setFallbackLocale(locale). By default fallback locale is null. Warning! This way created for workaround confuses of lost translations. Normal way is correct labels for all used locales.

  • i18n.translate(componentName, labelPath, locale = currentLocale). If the label isn't found by labelPath, labelPath will be returned. The return labelPath is necessary if the label is not found needed, because this is an easy way to find the lost labels.

    • componentName tells from what component will use translations.
    • labelPath tells from what path by component branch will get result label.
    • locale tells what locale we should use. By default it's current locale (by function setLocale).
  • Component.translate(labelPath, locale = currentLocale).

  • this.props.translate(labelPath, locale = currentLocale).

Usage

You can see simple example in examples/simple-react folder in this repo. But key points are:

  1. Set initial locale, optionally fallback locale in your index.jsx file, and Provider:
import i18n from '@emdc/i18n';

// initial locale
i18n.setLocale('en');

// optionally fallback locale
i18n.setFallbackLocale('en');

ReactDOM.render(
<AppContainer>
  <i18n.Provider>
    <AppComponent />
  </i18n.Provider>
</AppContainer>,
element
);
  1. Use in components by two ways:
import * as React from 'react';
import i18n from '@emdc/i18n';


const translations = {
  en: {
    test: 'Component label'
  },
  ru: {
    test: 'Текст Comp'
  }
};

// You shuould provide component name for functional components and use 'translate' func from props
const Comp = i18n.localize(translations, 'Comp')(({translate}) => (
  <div>
    {translate('test')}
  </div>
));
import * as React from 'react';
import i18n from '@emdc/i18n';


const translations = {
  en: {
    test: 'App label',
    switchTo: {
      en: 'Switch to English',
      ru: 'Переключиться на русский язык',
      de: 'Wechseln Sie zu Deutsch'
    }
  },
  ru: {
    test: 'Текст App',
    switchTo: {
      en: 'Switch to English',
      ru: 'Переключиться на русский язык',
      de: 'Wechseln Sie zu Deutsch'
    }
  },
  de: {
    test: 'Inschrift App',
    switchTo: {
      en: 'Switch to English',
      ru: 'Переключиться на русский язык',
      de: 'Wechseln Sie zu Deutsch'
    }
  }
};

// 1. You can use function 'localize' as decorator
// 2. You can omit the component name for regular components
// 3. You can use 'translate' function from component class: App.translate, from props or from i18n module.
// 4. You can change locale by function 'setLocale' from i18n module or from props.
// 5. You can specify locale for translate.

@i18n.localize(translations)
class App extends React.Component {
  constructor (props) {
    super(props);
  }

  render () {
    return (
      <div>
        <div>
          <button onClick={() => i18n.setLocale('en')}>
            {App.translate('switchTo.en')}
          </button>

          <button onClick={() => this.props.setLocale('ru')}>
            {translate('switchTo.ru')}
          </button>

          <button onClick={() => i18n.setLocale('de')}>
            {i18n.translate('App', 'switchTo.de')}
          </button>
        </div>
        <div>
          {`Translated label from class: ${App.translate('test')}`}
          <br />
          {`Translated label from props: ${this.props.translate('test')}`}
          <br />

        </div>
      </div>
    );
  }
}

export default App;