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 🙏

© 2025 – Pkg Stats / Ryan Hefner

nordnet-i18n

v0.0.5

Published

Nordnet React and Intl locale configuration

Downloads

27

Readme

Nordnet i18n library

NPM version Build Status Dependency Status

This library does the following things:

  • Returns the locale of the user
  • Loads Intl locale configuration.
  • Wraps React components in order to expose some i18n methods.

Installation

NPM

npm install --save nordnet-i18n

API

initialize

Gets the locale of the user and downloads Intl configuration. It first check if data-lang and data-country attributes is given in the provided element. If these attributes are not found it will make a request to the Nordnet API which will return the locale of the user. The locale is then used to download the Intl locale configuration (using the webpack code splitting feature). The promise is resolved with a string lang-COUNTRY.

Example:

import {initialize} from '../lib/index';
const el = document.getElementById("myapp");
initialize(el).then(start);
const AppWithI18N = i18n(App);

function start(locale) {
  const intlData = // get the intlData for your locale, see below
  ReactDOM.render(<AppWithI18N {...intlData}/>,  el));
}

Example of intlData:

const intlData = {
  locales: ['sv-SE'],
  messages: {
    title: {
      world: 'Värld',
    },
  },
}

supportedLocales

Returns an array of locales that this library supports

Example:

import {supportedLocales} from '../lib/index';
console.log('Supported locales: ' + supportedLocales().join(','));

i18n

Wraps given React component with React context properties (format, messages, locales) These properties can be used to translate or format values in a locale specific way. You should use the i18n function at the root of your component tree. Each component that needs i18n functionality should use the translatable function, see below. You should also provide the root component with translations for the locale.

Example:

import {i18n} from '../lib/index';
class App extends React.Component {
  render() {
     // Your components, e.g. see MyComponent below 
  }
}
export default i18n(App);

translatable

If you have wrapped your parent component with the i18n function (see above) you can use the translatable function. The translatable function will expose the getIntlMessage function as a property to your component.

Example:

class MyComponent extends React.Component {
  render() {
    return (<h1>{this.props.getIntlMessage('title.world')}</h1>);
  }
}
export default translatable(MyComponent);

Usage

See the complete example or unit tests