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

@i18n-micro/core

v2.1.0

Published

Core utilities for translations, formatting, and locale routing in Nuxt I18n Micro.

Readme

@i18n-micro/core

Translation core shared by every @i18n-micro/* adapter and nuxt-i18n-micro: translation storage, t / tc / tn / td / tdr / has, interpolation, plurals and cached Intl formatters. No runtime dependencies (@i18n-micro/types is types only), about 3.4 KB min+gzip.

npm install @i18n-micro/core

Entries

| Entry | What | | --------------------------- | ----------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------- | | @i18n-micro/core | BaseI18n, TranslationHelper, FormatService, createReactiveI18nStore, and everything in /helpers | | @i18n-micro/core/render | The <i18n-t> and switcher renderers Vue and Nuxt share: renderI18nT, createLocaleSwitcher. They take Vue's h as an argument | | @i18n-micro/core/helpers | Functions: tokenize, interpolate, resolveText, pluralForm, escapeHtml, defaultPlural, getByPath, resolveTranslation, hasTranslationValue, setTranslationAtKey, mergeTranslationChunk, mergeTranslationLayers, collectTranslationPaths, translationCacheKey, strategy predicates | | @i18n-micro/core/devtools | Vue DevTools inspector tree builders |

Storage model

Translations live in a TranslationStorage — a Map of chunks keyed locale:route (en:index, de:about), each a nested tree.

  • Stored trees are never mutated. A merge copies the nodes on the patch's paths and stores a new root. Objects you pass in, objects t() / getCache() return, route chunks that share subtrees and cloned storages (new Map(storage.translations)) all stay as they were.
  • Lookups always start from the Map. Writes made straight to storage.translations, or by another instance sharing the storage, are seen at once. Resolved keys are cached per tree object, so replace a chunk rather than editing a stored tree in place.
import { TranslationHelper } from '@i18n-micro/core'

const helper = new TranslationHelper()
helper.mergeTranslation('en', 'index', { greeting: 'Hello, {name}!', nav: { home: 'Home' } })
helper.mergeTranslation('en', 'index', { nav: { about: 'About' } }) // deep merge, nav.home kept
helper.mergeTranslation('en', 'about', { title: 'About us' })

helper.getTranslation('en', 'index', 'nav.about') // 'About'
helper.hasTranslation('en', 'title') // true (any route of `en`)

BaseI18n

Adapters extend it and supply the current state:

import { BaseI18n } from '@i18n-micro/core'

class MyI18n extends BaseI18n {
  locale = 'en'
  route = 'index'
  getLocale() {
    return this.locale
  }
  getFallbackLocale() {
    return 'en'
  }
  getRoute() {
    return this.route
  }
}

const i18n = new MyI18n({ numberFormats: { en: { currency: { style: 'currency', currency: 'USD' } } } })
i18n.loadTranslationsCore('en', { apples: 'no apples | one apple | {count} apples' }, true)
i18n.tc('apples', 5) // '5 apples'
i18n.tn(1234.5, 'currency') // '$1,234.50'
  • t(key, params?, default?, route?) — the active locale, then the fallback locale; a missing key returns default || key and goes to missingHandler (or a dev console.warn in the browser).
  • has(key, route?) — whether the active locale itself defines key (not the fallback).
  • tc(key, count | params, default?) — plural. defaultPlural picks form count for a whole non-negative count and the last form otherwise; a custom plural returning null falls back to it.
  • tn / td — Vue I18n-style named formats (tn(n, 'currency'), td(d, 'short', 'de')); a named format falls back through shorter tags (zh-Hant-TW → zh-Hant → zh).
  • tdr(date) — 3 days ago / in 3 days; Invalid Date for an invalid date.
  • setTranslation(key, value) — replaces the value at key in the active chunk; resolveTranslations() — the merged tree t() reads from.
  • extend(methods) — attaches framework helpers onto the instance.

FormatService

Caches one Intl.NumberFormat / DateTimeFormat / RelativeTimeFormat per locale and options (key order does not matter) and resolves named formats.

const formats = new FormatService()
formats.formatNumber(1234.5, 'de-DE') // '1.234,5'
formats.formatRelativeTime(Date.now() + 86_400_000, 'en', { numeric: 'auto' }) // 'tomorrow'

License

MIT — see LICENSE.