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

@reaatech/confidence-router-languages

v0.1.1

Published

Multi-language support with 47 locales for confidence-router

Readme

@reaatech/confidence-router-languages

npm version License: MIT CI

Status: Pre-1.0 — APIs may change in minor versions. Pin to a specific version in production.

Multi-language support for confidence-router clarification prompts, with 47 built-in locale configurations and a pluggable LanguageConfig system. Manages language metadata, prompt templates, and locale-aware formatting conventions.

Installation

npm install @reaatech/confidence-router-languages
# or
pnpm add @reaatech/confidence-router-languages

Feature Overview

  • 47 built-in languages — Afrikaans to Zulu, covering all major languages
  • Localized clarification templates — each language has prompt strings with {options} placeholder
  • Locale-aware formatting — list separators (", " vs "、") and conjunctions ("or" vs "还是")
  • RTL supportdirection: "rtl" for Arabic, Hebrew, Persian, Urdu
  • English fallback — unknown language codes silently fall back to English
  • Custom languagesaddLanguage() for adding new locale configs at runtime
  • Zero external dependencies beyond @reaatech/confidence-router-core

Quick Start

import { LanguageManager, PromptGenerator } from "@reaatech/confidence-router-languages";

const languages = new LanguageManager();
const prompt = new PromptGenerator(languages);

const text = prompt.generate(
  [
    { confidence: 0.55, label: "book_flight" },
    { confidence: 0.45, label: "check_status" },
  ],
  "es" // Spanish
);
// → "¿Quisiste decir: book_flight o check_status?"

Built-in Languages

| Code | Language | Direction | |------|----------|-----------| | en | English | ltr | | es | Spanish | ltr | | fr | French | ltr | | de | German | ltr | | it | Italian | ltr | | pt | Portuguese | ltr | | nl | Dutch | ltr | | ru | Russian | ltr | | ja | Japanese | ltr | | ko | Korean | ltr | | zh-cn | Chinese (Simplified) | ltr | | zh-tw | Chinese (Traditional) | ltr | | ar | Arabic | rtl | | he | Hebrew | rtl | | fa | Persian | rtl | | ur | Urdu | rtl | | hi | Hindi | ltr | | bn | Bengali | ltr | | ta | Tamil | ltr | | te | Telugu | ltr | | mr | Marathi | ltr | | gu | Gujarati | ltr | | kn | Kannada | ltr | | ml | Malayalam | ltr | | tr | Turkish | ltr | | pl | Polish | ltr | | sv | Swedish | ltr | | no | Norwegian | ltr | | da | Danish | ltr | | fi | Finnish | ltr | | cs | Czech | ltr | | el | Greek | ltr | | th | Thai | ltr | | vi | Vietnamese | ltr | | id | Indonesian | ltr | | ms | Malay | ltr | | fil | Filipino | ltr | | ro | Romanian | ltr | | bg | Bulgarian | ltr | | hr | Croatian | ltr | | sr | Serbian | ltr | | sl | Slovenian | ltr | | hu | Hungarian | ltr | | sk | Slovak | ltr | | uk | Ukrainian | ltr | | sw | Swahili | ltr | | af | Afrikaans | ltr |

API Reference

LanguageManager

import { LanguageManager } from "@reaatech/confidence-router-languages";

const lm = new LanguageManager();

| Method | Returns | Description | |--------|---------|-------------| | getLanguage(code) | LanguageConfig | Retrieves config by ISO 639-1 code; falls back to English | | addLanguage(config) | void | Registers a custom language configuration | | hasLanguage(code) | boolean | Checks whether a language is supported | | getSupportedLanguages() | string[] | Returns all registered language codes |

PromptGenerator

import { PromptGenerator } from "@reaatech/confidence-router-languages";

const pg = new PromptGenerator(languageManager);

| Method | Returns | Description | |--------|---------|-------------| | generate(predictions, languageCode, customTemplate?, maxOptions?) | string | Formats a clarification prompt with sorted prediction labels |

The generate method:

  1. Looks up the language config
  2. Sorts predictions by confidence descending
  3. Truncates to maxOptions (default: 3)
  4. Formats labels using locale-specific separators and conjunctions
  5. Replaces {options} in the template with the formatted list

Prompt Templating

Custom templates use the {options} placeholder:

const template = "Which of these did you mean: {options}";
const text = pg.generate(predictions, "en", template);
// → "Which of these did you mean: book_flight, check_status, or cancel_booking"

Adding a Custom Language

import type { LanguageConfig } from "@reaatech/confidence-router-core";
import { LanguageManager } from "@reaatech/confidence-router-languages";

const lm = new LanguageManager();
lm.addLanguage({
  code: "eo",
  name: "Esperanto",
  nativeName: "Esperanto",
  direction: "ltr",
  clarificationTemplates: {
    basic: "Ĉu vi celis: {options}?",
  },
  formatting: {
    listSeparator: ", ",
    conjunction: "aŭ",
  },
});

Usage Patterns

Multi-language Clarification

const languages = new LanguageManager();
const prompt = new PromptGenerator(languages);

for (const code of ["en", "es", "ja", "ar"]) {
  console.log(prompt.generate([
    { confidence: 0.55, label: "book" },
    { confidence: 0.45, label: "status" },
  ], code));
}

// en: "Did you mean: book or status?"
// es: "¿Quisiste decir: book o status?"
// ja: "どちらをお探しですか:book、status"
// ar: "هل كنت تقصد: book أو status؟"

Related Packages

License

MIT