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

pikku-i18n

v2.0.2

Published

Tiny i18n library for ES6 and React

Readme

pikku-i18n

"Pikku" means tiny in the Finnish language.

A tiny ES6 library for i18n string interpolation with supporting React component.

Provides most commonly used i18n functionalities:

  • String interpolation with variables
  • Injecting React components inside string variables
  • Helpful error messages for incorrect strings, missing variables etc.

Install

npm install pikku-i18n

Using pikku-i18n

Pikku-i18n can be used with both vanilla JavaScript and with React. The core library handles the string interpolations while the Trans component extends the library with React support.

Javascript

import { init, t, lang, defaultNS, resources, Trans } from "pikku-i18n"
import localeData from "./locales/en.json"

// Call init() before calling any other method.
init("en", "home", localeData)

// Access to passed data if needed
console.log(lang) // "en"
console.log(defaultNS) // "home"
console.log(resources) // "access passed localeData within the library"

console.log(t("title")) // returns "home.title" from locales

// Access alternative namespace strings
console.log(t("modal:title")) // returns "modal.title" from locales

// strings with variables
console.log(t("status", { currentStatus: t("open") })) // "We are currently open"

// Interpolate a variable
console.log(
  t("modal:cars", {
    carsCount: 5,
    serviceType: t("modal:services.lease.title")
  })
) // "We currently have 5 cars available for lease"

// Strings can contain multiple variables
console.log(
  t("locations", {
    locationsCount: 20, // Both numbers and
    citiesCount: "4", // strings can be used for interpolation.
    helsinki: t("locations:helsinki"),
    // Variables can be nested
    washington: t("locations:washington", {
      usState: t("locations:usStates.ohio")
    }), // Washington Ohio
    newYork: t("locations:newYork"), // Both camelCase and
    new_delhi: t("locations:new_delhi") // snake_case are supported
  })
) // "We have 20 locations in 4 cities: Helsinki, Washington Ohio, New York and New Delhi."

With React

The Trans component is used for wrapping the string variables inside a React node.

import React from "react"
import { init, t, Trans } from "vanska/pikku-i18n"
import localeData from "./locales/en.json"

export default function Component() {
  init("en", "home", localeData)

  return (
    <>
      <h1>{t("title")}</h1> // Use the core library the same way as with plain
      JavaScript
      <p>
        <Trans
          i18nKey="locations"
          subs={{
            locationsCount: <strong>20</strong>,
            citiesCount: <strong>{4}</strong>,
            helsinki: t("locations:helsinki"),
            washington: t("locations:washington", {
              usState: t("locations:usStates.ohio")
            }),
            newYork: t("locations:newYork"),
            new_delhi: t("locations:new_delhi")
          }}
        />
      </p>
    </>
  )
}

You can also access non-default namespaces with Trans component i.e. i18nKey="modal:cars".

i18n JSON format

{
  "home": {
    "title": "This is our awesome home page title",
    "status": "We are currently {{currentStatus}}",
    "chosenLocation": "{{chosenLocation}} chosen as home location",
    "open": "open",
    "closed": "closed",
    "locations": "We have {{locationsCount}} locations in {{citiesCount}} cities: {{helsinki}}, {{washington}}, {{newYork}} and {{new_delhi}}.",
    "testimonials": {
      "title": "Testimonials",
      "description": "This is what our {{customerCount}} customers are saying",
      "customers": {
        "john": {
          "quote": "This is an awesome company!"
        },
        "mary": {
          "quote": "A great experience!"
        }
      }
    }
  },
  "modal": {
    "title": "How may we help?",
    "cars": "We currently have {{carsCount}} cars available for {{serviceType}}",
    "services": {
      "rental": {
        "title": "rental"
      },
      "lease": {
        "title": "lease"
      }
    }
  },
  "locations": {
    "helsinki": "Helsinki",
    "newYork": "New York",
    "new_delhi": "New Delhi",
    "washington": "Washington {{usState}}",
    "usStates": {
      "ohio": "Ohio",
      "north_carolina": "North Carolina"
    }
  }
}

Development

# TypeScript
npm run tsc-watch
# Prettier
npm run format
# Jest
npm run jest-watch

Local end to end package testing with yalc

npm run yalc-watch
cd ../destination-project
yalc link pikku-i18n

Project roadmap

  • Semantic release
  • yalc-watch build
  • NPM build on install
  • Typescript
    • t()
      • Add min string lengths to types
    • Trans
      • Throw type error on any value other than i18nKey or ns that is not a ReactNode
  • Tests
    • Add tests for incorrect locale data
    • i18n
      • init()
        • toThrow for incorrect locale data
  • Trans
    • string substitution prop name needs to have an exact match with string variables