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

y18n-browser

v1.0.2

Published

the bare-bones internationalization library used by yargs, made browser friendly

Readme

y18n-browser

Build Status Coverage Status NPM version js-standard-style

The bare-bones internationalization library.

Inspired by i18n. and y18n.

Examples

simple string translation:

var __ = require('y18n').__

console.log(__('my awesome string %s', 'foo'))

output:

my awesome string foo

pluralization support:

var __n = require('y18n').__n

console.log(__n('one fish %s', '%d fishes %s', 2, 'foo'))

output:

2 fishes foo

JSON Language Files

The JSON language files can be stored anywhere as long as you can include them when you instantiate a new Y18N. File names correspond to locales, e.g., en.json, pirate.json.

When strings are observed for the first time they will be added to the JSON file corresponding to the current locale.

Usage

It is recommended to create a helper file/module to handle constructing a new Y18N instance like so:

y18n.js

import Y18N from 'y18n-browser'

export default new Y18N({
	sources: {
		en: require('./path/to/en.json'),
		pirate: require('./path/to/pirate.json'),
	}
})

Create an instance of y18n with the config provided, options include:

  • sources: an object mapping to existing json source files
  • writeLocalUpdates: should newly observed strings be written to local storage, default false.
  • locale: what locale should be used.
  • fallbackToLanguage: should fallback to a language-only file (e.g. en.json) be allowed if a file matching the locale does not exist (e.g. en_US.json), default true.

Methods

import y18n from './my/instance/y18n'

Now you can use your configured instance anywhere.

y18n.__(str, arg, arg, arg)

Print a localized string, %s will be replaced with args.

y18n.__n(singularString, pluralString, count, arg, arg, arg)

Print a localized string with appropriate pluralization. If %d is provided in the string, the count will replace this placeholder.

y18n.setLocale(str)

Set the current locale being used.

y18n.getLocale()

What locale is currently being used?

y18n.updateLocale(obj)

Update the current locale with the key value pairs in obj.

Example locale json file

{
  "Hello": "Hello!",
  "Hello %s %s": "Hello %s %s",
  "%d cat": {
    "one": "%d cat",
    "other": "%d cats"
  },
  "%d %s cat": {
    "one": "%d %s cat",
    "other": "%d %s cats"
  },
  "There is one monkey in the %s": {
    "one": "There is one monkey in the %s",
    "other": "There are %d monkeys in the %s"
  }
}

License

ISC