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

@adobe-addon-i18n/react

v0.2.0

Published

The microscopic React runtime for `adobe-addon-i18n`.

Readme

@adobe-addon-i18n/react

The microscopic React runtime for adobe-addon-i18n.

Zero external dependencies. Integrates directly with the Adobe Express Add-on SDK to detect locale, listen for locale changes, and resolve translations from static JSON dictionaries.


Installation

npm install @adobe-addon-i18n/react

Quick Start

import { I18nProvider, useTranslation } from '@adobe-addon-i18n/react';
import en from './locales/en.json';
import fr from './locales/fr.json';

const locales = { en, fr };

function App() {
  const { t } = useTranslation();

  return (
    <div>
      <h1>{t('header.title')}</h1>
      <p>{t('welcome.user', { username: 'Keshav' })}</p>
    </div>
  );
}

export default function Root() {
  return (
    <I18nProvider locales={locales} defaultLocale="en">
      <App />
    </I18nProvider>
  );
}

API

<I18nProvider>

| Prop | Type | Description | |---|---|---| | locales | Record<string, TranslationDict> | Map of BCP 47 locale codes to translation dictionaries | | defaultLocale | string | Fallback locale when the SDK locale is not available | | children | React.ReactNode | Your application tree |

The provider automatically:

  1. Waits for addOnUISdk.ready to resolve.
  2. Reads the initial locale from addOnUISdk.app.ui.locale.
  3. Subscribes to localechange events for live updates.
  4. Unregisters the localechange listener on unmount (no ghost handlers).

Locale fallback chain: If the SDK reports "es-ES" but your locales object only has "es", the provider falls back to the primary language subtag automatically. If that is also absent, it uses defaultLocale.

useTranslation()

Returns { locale: string, t: Function }. Must be called inside an <I18nProvider>.

t(key, params?)

| Argument | Type | Description | |---|---|---| | key | string | Dot-notation path into the translation dictionary (e.g. "auth.login.title") | | params | Record<string, string \| number \| boolean> | Optional interpolation variables |

Returns: The translated string, or the raw key if no entry is found.


Features

Dot-Notation Keys

// Resolves locales.en.auth.login.title
t('auth.login.title')

Variable Interpolation

// en.json: { "greeting": "Hello, {{name}}!" }
t('greeting', { name: 'Keshav' })  // → "Hello, Keshav!"

If a variable is present in the template but absent from params, the original {{placeholder}} is preserved — there is no silent data loss.

Pluralization

Use a count param to activate automatic plural form selection. Define a <key>_plural variant in your JSON for non-singular counts:

{
  "item_count": "One item",
  "item_count_plural": "{{count}} items"
}
t('item_count', { count: 1 })  // → "One item"
t('item_count', { count: 5 })  // → "5 items"

When count !== 1, the _plural variant is used. If no _plural variant exists, the base key is used as a fallback.


TypeScript

The package exports proper recursive types for translation dictionaries:

import type { TranslationDict, TranslationValue, InterpolationParams } from '@adobe-addon-i18n/react';
  • TranslationValuestring | TranslationDict
  • TranslationDict{ [key: string]: TranslationValue }
  • InterpolationParamsRecord<string, string | number | boolean>

⚠️ Security Note

The t() function returns a plain string. If you render the result via dangerouslySetInnerHTML, you are responsible for sanitizing it first — interpolated param values are not HTML-escaped by this library. For typical React usage (rendering as text nodes or JSX attributes), this is not a concern.


License

MIT