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

@biorate/i18n

v2.1.5

Published

Internationalization library

Readme

@biorate/i18n

Internationalization library — DI‑wrapped i18next with automatic lifecycle initialization and a convenience t tagged‑template function.

Features

  • DI integration@injectable() abstract class with @init() lifecycle.
  • i18next re‑export — all types, interfaces, and helpers from i18next are available from the same import.
  • Tagged‑template tt\key`` syntax for concise translations.
  • Middleware support — i18next plugins via middlewares getter.
  • Languages helperlanguages getter from supportedLngs option.

Installation

pnpm add @biorate/i18n

Requires @biorate/config, @biorate/inversion, i18next.

Quick start

import { inject, container, Core, Types } from '@biorate/inversion';
import { Config, IConfig } from '@biorate/config';
import { I18n, t } from '@biorate/i18n';

class MyI18n extends I18n {
  protected options = {
    fallbackLng: 'ru',
    lng: 'ru',
    resources: {
      ru: { translation: { 'Привет мир': 'Привет мир!' } },
      en: { translation: { 'Привет мир': 'Hello world!' } },
    },
  };
}

class Root extends Core() {
  @inject(Types.Config) public config: IConfig;
  @inject(MyI18n) public i18n: MyI18n;
}

container.bind<IConfig>(Types.Config).to(Config).inSingletonScope();
container.bind<MyI18n>(MyI18n).toSelf().inSingletonScope();
container.bind<Root>(Root).toSelf().inSingletonScope();

(async () => {
  const root = container.get<Root>(Root);
  await root.$run();
  console.log(t`Привет мир`);             // 'Привет мир!'
  console.log(t('Привет мир', { lng: 'en' })); // 'Hello world!'
})();

Module reference

I18n — Abstract base

import { I18n } from '@biorate/i18n';

DI‑ready abstract class wrapping i18next.

| Member | Visibility | Type / Signature | Description | |---------------|---------------|------------------------------------------|--------------------------------------| | config | protected | IConfig | Injected config service. | | options | protected abstract | Record<string, unknown> | i18next init options (must override).| | middlewares | protected get | (NewableModule \| Newable \| Module)[] | i18next plugins (default: []). | | initialize | @init() protected | (): Promise<void> | Register middlewares, call i18next.init(). | | languages | public get | string[] | options.supportedLngs array. |

t — Translation function

import { t } from '@biorate/i18n';

| Export | Signature | Description | |--------|-------------------------------------------------|------------------------------------------| | t | (key: any \| any[], options?: TOptionsBase) | Translate key (wraps i18next.t). Works as tagged template t\key`` or function call. |

Re‑exports from i18next

All named exports from i18next v23 are available:

Interfaces: i18n, WithT, Interpolator, Formatter, Services, Module, BackendModule, LanguageDetectorModule, LanguageDetectorAsyncModule, PostProcessorModule, LoggerModule, I18nFormatModule, FormatterModule, ThirdPartyModule, Modules, Newable, NewableModule, ExistsFunction, CloneOptions.

Types: TFunction, TOptions, InitOptions, Resource, ResourceKey, ResourceLanguage, Namespace, DefaultNamespace, ParseKeys, TFunctionReturn, TFunctionDetailedResult, Callback, CallbackError, FallbackLng, FallbackLngObjList, TypeOptions, CustomTypeOptions, CustomPluginOptions, PluginOptions, FormatFunction, InterpolationOptions, ReactOptions, KeyPrefix, ModuleType, ReadCallback, MultiReadCallback.

Classes: ResourceStore.

Functions/Constants: createInstance, init, use, changeLanguage, getFixedT, exists, setDefaultNamespace, hasLoadedNamespace, loadNamespaces, loadLanguages, dir, loadResources, reloadResources.

Usage patterns

Custom middleware (i18next backend)

class MyI18n extends I18n {
  protected options = { fallbackLng: 'en', lng: 'en' };

  protected get middlewares() {
    return [MyCustomBackend];  // i18next BackendModule
  }
}

Accessing i18next instance directly

import { init, use, changeLanguage } from '@biorate/i18n';

Architecture

I18n (abstract, @injectable)
│
├── @inject(Types.Config) config
├── protected abstract options          → i18next.init options
├── protected get middlewares()         → i18next.use() plugins
│
└── @init() initialize()
    ├── for each middleware → use(middleware)
    └── await i18next.init(this.options)
        └── t`key` / t('key') now resolves

Learn

  • Documentation can be found here - docs.

Release History

See the CHANGELOG

License

MIT

Copyright (c) 2021-present Leonid Levkin (llevkin)