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

nativtongue

v0.0.5

Published

Zero boilerplate i18n for React

Readme

nativtongue

Zero boilerplate i18n for React. Just write your UI — translations happen automatically.

Install

npm install nativtongue

Usage

Wrap your app with TranslationProvider:

import { TranslationProvider } from 'nativtongue'

function App() {
  return (
    <TranslationProvider defaultLocale="en">
      <h1>Welcome to my app</h1>
      <p>This text is translated automatically.</p>
      <button aria-label="Submit form">Submit</button>
      <input placeholder="Search..." />
    </TranslationProvider>
  )
}

That's it. All text content and translatable attributes (aria-label, placeholder, title, alt) are translated automatically via DOM walking. No wrappers, no function calls.

How it works

  1. TranslationProvider loads a JSON translation file for the active locale (e.g. /i18n/fr.json)
  2. A DOM TreeWalker finds every text node and translatable attribute inside the provider
  3. Each string is looked up in the translation map and replaced
  4. A MutationObserver watches for dynamically added content and translates it on the fly
  5. A WeakMap stores original text per node so switching back to the source language works correctly

Translation files

Translation files are flat JSON objects mapping source strings to translated strings:

{
  "Welcome to my app": "Bienvenue sur mon application",
  "This text is translated automatically.": "Ce texte est traduit automatiquement.",
  "Submit": "Envoyer",
  "Submit form": "Envoyer le formulaire",
  "Search...": "Rechercher..."
}

Use nativtongue-cli to generate and auto-translate these files.

API

<TranslationProvider>

| Prop | Type | Default | Description | |------|------|---------|-------------| | defaultLocale | string | 'en' | Initial locale (uncontrolled mode) | | locale | string | — | Controlled locale (parent drives changes) | | sourceLocale | string | 'en' | The language your source code is written in | | fetch | (locale: string) => Promise<Response> | fetch(\/i18n/${locale}.json`)| Custom translation file loader | |fallback|ReactNode|null| Shown while translations are loading | |onMissing|(key: string, locale: string) => void` | — | Called when a translation key is not found |

useTranslation()

Access locale and switch languages from any component inside the provider:

const { locale, setLocale } = useTranslation()

<TranslationScope>

Disambiguate identical strings that need different translations depending on context:

<TranslationScope context="navigation">
  <p>Back</p>  {/* looks up "navigation::Back" */}
</TranslationScope>

<TranslationScope context="body">
  <p>Back</p>  {/* looks up "body::Back" */}
</TranslationScope>

<p>Back</p>  {/* looks up "Back" */}

useT()

Escape hatch for when you need a translated string as a JavaScript value (not in the DOM):

const t = useT()
document.title = t('My App')