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

react-easy-localization

v1.0.2

Published

A simple module to make React localization easy

Downloads

9

Readme

react-easy-localization

A simple module built on top of react-localization which makes React localization easy.

Demo

Installation

npm install --save react-easy-localization

React dependency

React >= 16.8.0

API

  • LocaleProvider - use React Context to provide localization values
  • useLocale - a React Hook that provides localization values
  • withLocale - a React HOC that provides localization values

Localization values

  • i18n: an object contains all localized texts
  • languageCode: current selected language code
  • changeLanguage: method to change the language
  • allLanguages: contains the list of all languages

Input

  • resources: a simple object containing language keys (i.e. en, ge, fr..) and a list of key-value pairs for localized texts
  • defaultLanguage: choose a start language, if unset, the default is the first language in resources
const resources = {
  en: {
    title: "Title",
    text: "A title is one or more words used before or after a person's name",
  },
  ja: {
    title: "題名",
    text: "タイトルは、人の名前の前後に使用される1つ以上の単語です。",
  },
};

Usage

// wrap `LocaleProvider` on top of your application and provide a resources object
import { LocaleProvider } from "react-easy-localization";

const App = () => (
  <LocaleProvider resources={resources}>
    <YourApp />
  </LocaleProvider>
);
// Use `useLocale` to get localization values
import { useLocale } from "react-easy-localization";

const Home = () => {
  const { i18n, languageCode, changeLanguage } = useLocale();

  const toggleLanguage = () => {
    return languageCode === "en" ? changeLanguage("ja") : changeLanguage("en");
  };

  return (
    <>
      <button onClick={toggleLanguage}>{languageCode}</button>

      <div>{i18n.title}</div>
      <div>{i18n.text}</div>
    </>
  );
};

export default Home;
// Or use `withLocale` to get localization values
import { withLocale } from "react-easy-localization";

const Home = ({ i18n, languageCode, changeLanguage }) => {
  const toggleLanguage = () => {
    return languageCode === "en" ? changeLanguage("ja") : changeLanguage("en");
  };

  return (
    <>
      <button onClick={toggleLanguage}>{languageCode}</button>

      <div>{i18n.title}</div>
      <div>{i18n.text}</div>
    </>
  );
};

export default withLocale(Home);