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

olo-locale

v0.1.1

Published

olo-locale provides usefull functionality for content negotiation for language specific contents. As well as other utilities around internationalization.

Readme

olo-locale

olo-locale provides usefull functionality for content negotiation for language specific contents. As well as other utilities around internationalization.

Currently only the main english and german languages and reagions are supported. Support for additional languages as well as the customization of used locales will be added next.

Installation

Navigate to your project folder and enter the following in you terminal:

npm i olo-locale --save

Usage

This package provides three classes that should cover usefull functionality not allready covered by other platforms.

Locale

The Locale class is meant to identify the locale (language & region) of a piece of content, asset, or entity. You can set it up with a language, a country code or a meta-data object:

const english = new Locale('en');
const greatbritain = new Locale('GB');

const swissGerman = new Locale({
  locale: 'de-CH',
  language: 'de', // not needed of locale is defined
  region: 'CH', // not needed of locale is defined
  availableLocales: ['de-DE', 'de-AT'], // Available locales describes other version of the entity that are available with an additional request.
});

Once setup the Locale instace allows you to check if it is the same as another locale, locale code, language or regions and how well it fits a given locale request.

english.isSame(greatbritain); // true, because GB is the default region for english
english.isSame('en'); // true

swissGerman.isSame('DE'); // false, because here the Swiss locale has been explicitly defined;
swissGerman.isSame('de'); // true;

english.isFit(['de-CH', 'de-DE', 'en-GB']), // 3
swissGerman.isFit(['en-GB']), // false

LocaleRequest

LocaleRequest is ordered list of preferred locales, typically used for content negotiation or defining a fallback sequence for localization.

It extends the native Array class and automatically populates itself based on input locales, their mapped fallbacks (via DefaultLocaleLocale), and the global DefaultLocale, ensuring no duplicates and maintaining a preference order.

const swissGerman = new LocaleRequest('de-CH'); // ['de-CH', 'de-DE', 'en-GB']

The isFit() method provides an a number representing how well a given locale fits the request (lower is better).

swissGerman.isFit(new Locale('de-CH')); // 1
swissGerman.isFit(new Locale('en-US')); // false

Localization

The static Localization class provides utility classes and methods around for specific internationalization cases.

You can compile gender inclusive phrasings with the language specific Genderer classes.

const germanGenderer = Localization.getGenderer('de-DE');
germanGenderer.setGenderDividers('*', '/'); // defaults to ':' and '/'

germanGenderer.compileGenderedDeclinationItem('Studentin', 'Student'); // Student*in
germanGenderer.compileGenderedDeclinationItem('Studentinnen', 'Studenten'); // Studentinnen/Studenten

In case you don't use configuration by locale but only by language or region, you can convert them to lacale based configurations.

Localization.expandLanguageToLocaleMap({
  de: { capitalization: 'always', adress: 'Liebe(r) ' }
  en: { capitalization: 'startOfSentence', adress: 'Dear ' }
});

/*
{
  'de-DE': { capitalization: 'always', adress: 'Liebe(r) ' },
  'de-CH': { capitalization: 'always', adress: 'Liebe(r) ' },
  'de-AT': { capitalization: 'always', adress: 'Liebe(r) ' },
  'en-US': { capitalization: 'startOfSentence', adress: 'Dear ' },
  'en-GB': { capitalization: 'startOfSentence', adress: 'Dear ' }
}
*/

Localization.expandRegionToLocaleMap({
  GB: { imprintRequired: false, privacyStatementRequired: true },
  DE: { imprintRequired: true, privacyStatementRequired: true }
});