Big News: Socket raises $60M Series C at a $1B valuation to secure software supply chains for AI-driven development.Announcement
Sign In

@felixgeelhaar/glossa-format

Package Overview
Dependencies
Maintainers
1
Versions
2
Alerts
File Explorer

Advanced tools

Socket logo

Install Socket

Detect and block malicious and high-risk dependencies

Install

@felixgeelhaar/glossa-format

ICU MessageFormat subset — variables, plurals, select, nesting. Backed by Intl.PluralRules; zero runtime deps.

latest
Source
npmnpm
Version
0.1.1
Version published
Maintainers
1
Created
Source

@felixgeelhaar/glossa-format

ICU MessageFormat subset — variable interpolation, plurals via Intl.PluralRules, select, nesting, apostrophe escaping. Zero runtime dependencies. ~400 LOC, ~9 KB unpacked.

pnpm add @felixgeelhaar/glossa-format

Usage

import { format, parse } from "@felixgeelhaar/glossa-format";

format("Hello, {name}!", "en", { name: "Sophia" });
// → "Hello, Sophia!"

format(
  "{count, plural, one {# session} other {# sessions}}",
  "en",
  { count: 3 },
);
// → "3 sessions"

format(
  "{gender, select, female {She did it} male {He did it} other {They did it}}",
  "en",
  { gender: "female" },
);
// → "She did it"

For hot paths, parse once and reuse the AST:

const ast = parse("{count, plural, one {# tip} other {# tips}}");
format(ast, "de", { count: 1 }); // → "1 Tipp"

Supported ICU features

FeatureExample
Variable interpolation{name}
Plural categories{n, plural, zero{…} one{…} two{…} few{…} many{…} other{…}}
Numeric plural override{n, plural, =0{none} one{…} other{…}}
Hash placeholder inside plural{count, plural, one {# item} other {# items}}
Select{gender, select, female{…} male{…} other{…}}
Nested patternsplurals inside select inside variable substitution
Apostrophe escapingit''sit's, '{literal}'{literal}

Plural keyword resolution defers to Intl.PluralRules so the package works across the ~100 locales the browser ships without bundling CLDR. Falls back to "other" on environments without Intl.PluralRules.

Out of scope

  • Numbers / dates / relative time — use Intl.NumberFormat, Intl.DateTimeFormat, Intl.RelativeTimeFormat directly.
  • Custom formatter extension API.
  • Bidi / RTL re-ordering.

License

MIT

Keywords

icu

FAQs

Package last updated on 24 May 2026

Did you know?

Socket

Socket for GitHub automatically highlights issues in each pull request and monitors the health of all your open source dependencies. Discover the contents of your packages and block harmful activity before you install or update your dependencies.

Install

Related posts