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 🙏

© 2024 – Pkg Stats / Ryan Hefner

stele

v0.0.1

Published

A compile time internationalization library for javascript and webpack

Downloads

5

Readme

Stele

What is stele?

Stele is a suite of tools for building international applications in modern single page apps. The name comes from the Rosetta Stone, which was a Stele, meaning a giant stone (or wooden) monument, often with some sort of decree. Really, it was the coolest name we could think of that was not taken on NPM.

The Problems

The ecosystem in javascript for internationalization is quite daunting to first look into. At Patreon we had a few main goals for starting our internationalization journey.

  1. We have thousands of untranslated strings.
  2. We have dozens of developers working as the same time
  3. We have tens of thousands of strings and do not want to bloat our application by sending down strings we do not need

Our goal is not to create a new standard to replace all standards in the JS ecosystem. We wanted to solve the problems we were facing at Patreon and share our solution. If you are facing a different set of problems this may not be the right solution for you or your product.

What we needed in an internationalizable library

  1. Transitioning strings should be as easy as possible.
  2. Writing translatable strings should be as easy as possible.
  3. Use the power of our compiler to alleviate run time checks of strings.
  4. Easily enforce conversion of our site with an existing lint rule.

The Components

  1. Webpack plugin for compiling individual languages, and extracting a json file
  2. Webpack loader for rewriting individual files
  3. An abstraction of ICU strings to aid in writing more complex international strings

How it works

This library is heavily inspired by elm-i18n and i18n-webpack-plugin

What we do for simple strings

Given:

__('Hello World!')

Replace with (English):

__(generateInternationalizableString('Hello World'))

As this is static and has no formatters, we can simplify further to:

'Hello World'

Replace with (Spanish):

'Hola Mundo'

Given:

__('Hello, {name}', { name: 'Ben' })

Replace with (English)

__(generateInternationalizableString('Hello, {name}', { name: 'Ben' }))

Replace with (Spanish)

__(generateInternationalizableString('Hola, {name}', { name: 'Ben' }))

Plurals

In the world of JavaScript internationalization plurals are where we have noticed the most division. Often, the most simple of libraries ignore this and leave it up to the user to handle. We wanted to create a simple type-safe interface for generating plural ICU compatible strings. It ends up looking something like this:

import { Translatable, Argument, Count, plural } from 'stele'

@Translatable()
class MyMessages {
    apples(@Argument() name, @Count() appleCount) {
        const appleSuffix = plural(appleCount, {
            one: 'an apple',
            other: count => `${count} apples`,
        })
        return `${name} has ${appleSuffix}`
    }
}

document.findElementById('root').textContent = new MyMessages().apples('Ben', 5)