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

wilster-trans

v0.9.6

Published

Ultra simple translation / i18n library that support multiple languages that are stored in JSON.

Readme

Wilster-trans

It's always bugged me how difficult translations in applications ends up being, so this is an attempt on making that task as simple as possible. It's based on some really nice projects e.g. node-polyglot.

The only thing I would have like to do better, is the flexibility of extraction - currently you are required to use import Trans from 'wilster-trans' syntax - due to my poor regex skills.. nevertheless, it works :)

Installation

npm i --save wilster-trans and for CLI command npm i -g wilster-trans

Getting started

  1. Import the repo (import Trans from 'wilster-trans')
  2. Run the Trans.init({config: {...}, locales: {...}) (see example)
  3. Start using it (Trans.t("foo")'). NB: Trans is the mandatory name for the extractor to work.
  4. Run wilster-trans run -s PATH_TO_SRC -o PATH_TO_OUTPUT_DIR -l COMMA_SEPARATED_LOCALES. This will extract all the translation keys and put them into your translation directory.

NB: If you want to run the extractor from the local scope, just call ./node_modules/wilster-trans/bin/wilster-trans.js run instead.

Use example

./src/application.js

import React, { Component } from 'react'
import Trans from 'wilster-trans'

// Init's the translator
Trans.init({
  config: {
    defaultLocale: "en"
  },
  locales: {
    en: require("path/to/translations/en.json"),
    da: require("path/to/translations/da.json")
  }
})

export default App extends Component {
  render() {
    return (
	    <div>
        <h1>{Trans.t("welcome.heading")}</h1>
	      <p>{Trans.t("welcome.greetings", {name: "John Doe"})}</p>
	    </div>
    )
  }
}

Then run wilster-trans run -s ./src -o ./src/translations -l en,da

./src/translations/en.json

{
  "welcome.heading": "Hello world",
  "welcome.greetings": "Hi there %name% - nice to see you!"
}

CLI Command(s)

wilster-trans run -s PATH_TO_SRC -o PATH_TO_OUTPUT_DIR -l COMMA_SEPARATED_LOCALES Runs the extractor.

-o || --output is the output directory.

-s || --source is the code source directory (where we'll look for "Trans.t" matches)

-l || --locales is the locales that will be created.

Documentation

  • Trans.t(translationKey: String, params: Object) If you want to use placeholders, you should use the following syntax Hi there %name%! in the translation string, and reference it using in the params object e.g. Trans.t("...", {name: "John Doe"})

  • Trans.setLocale('LOCALE_KEY') Run this method if you want to change from the current language. Then re-render your UI and it'll use the newly set locale.