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

text-intl

v1.0.1

Published

Intuitive i18n with plain text keys

Downloads

14

Readme

text-intl

Type-safe internationalization with plain text keys

npm version License: MIT

한국어


Philosophy

Write what you see. See what you write.

// In your code - use plain text directly
t('Hello World');

Write natural language directly in your code. Internally managed through hash-based key mapping for efficiency.


Features

  • Plain Text Keys - Use natural language directly in code
  • Type-Safe - TypeScript support
  • Gettext-style - Write t("Hello World") directly in code
  • ICU MessageFormat - Pluralization, select, number/date formatting
  • React Support - Hooks and Provider included
  • Auto-extraction - CLI extracts messages from code
  • Tree-shakeable - ESM + CJS support

Installation

npm install text-intl

Quick Start

1. Create Configuration

// i18n.config.ts
export default {
  sourceLocale: 'en',
  locales: ['en', 'fr', 'es'],
  messagesDir: './messages',
  include: ['src/**/*.{ts,tsx}'],
};

2. Setup React Provider

// app/providers/i18n-provider.tsx
'use client';

import { setupI18n } from 'text-intl/react';

import enMessages from '@/messages/en/common.json';
import enMeta from '@/messages/en/common.meta.json';
import frMessages from '@/messages/fr/common.json';
import frMeta from '@/messages/fr/common.meta.json';

export const { I18nProvider, useTranslation, useLocale } = setupI18n({
  messages: {
    en: { common: enMessages },
    fr: { common: frMessages },
  },
  meta: {
    en: { common: enMeta },
    fr: { common: frMeta },
  },
  defaultLocale: 'en',
  fallbackLocale: 'en',
});

3. Wrap Your App

// app/layout.tsx
import { I18nProvider } from '@/providers/i18n-provider';

export default function RootLayout({ children }) {
  return (
    <html>
      <body>
        <I18nProvider>{children}</I18nProvider>
      </body>
    </html>
  );
}

4. Use in Components

'use client';

import { useTranslation, useLocale } from '@/providers/i18n-provider';

export default function HomePage() {
  const { t } = useTranslation();
  const { locale, setLocale } = useLocale();

  return (
    <div>
      <h1>{t('Hello World')}</h1>
      <p>{t('Welcome {name}', { name: 'User' })}</p>

      <button onClick={() => setLocale('en')}>English</button>
      <button onClick={() => setLocale('fr')}>Français</button>
    </div>
  );
}

5. Extract Messages

# Extract messages from code
npx text-intl extract

# Watch mode
npx text-intl watch

# Validate translations
npx text-intl validate

Output structure:

messages/
├── en/
│   ├── common.json        # hash → translation
│   └── common.meta.json   # source text → hash mapping
└── fr/
    ├── common.json
    └── common.meta.json

Usage Examples

Variables

t('Hello {name}', { name: 'John' });
// → "Hello John"

Pluralization (ICU)

t('{count, plural, =0 {No items} one {# item} other {# items}}', { count: 5 });
// → "5 items"

Select (Conditional)

t('{gender, select, male {He} female {She} other {They}} liked your post', { gender: 'female' });
// → "She liked your post"

Component Tags

t('Click <link>here</link> to continue', {
  link: (children) => <a href="/next">{children}</a>,
});
// → Click <a href="/next">here</a> to continue

Namespaces

const { t } = useTranslation('dashboard');
t('Dashboard Title');

API

Core

import { init, t, getLocale, setLocale } from 'text-intl';

init({
  locale: 'en',
  messages: { en: { common: {...} } },
  meta: { en: { common: {...} } },
  fallbackLocale: 'en'
});

t('Hello World');
t('Hello {name}', { name: 'John' });

getLocale(); // 'en'
setLocale('fr');

React

import { setupI18n } from 'text-intl/react';

const { I18nProvider, useTranslation, useLocale } = setupI18n({
  messages: { en: { common: {...} } },
  meta: { en: { common: {...} } },
  defaultLocale: 'en',
  fallbackLocale: 'en',
  components: {
    bold: (children) => <strong>{children}</strong>
  }
});

Configuration

i18n.config.ts

export default {
  sourceLocale: 'en',
  locales: ['en', 'fr', 'es', 'de'],
  messagesDir: './messages',
  include: ['src/**/*.{ts,tsx,js,jsx}'],
  exclude: ['**/*.test.*', '**/node_modules/**'],
};

Issues & Contributing

Report bugs or request features on GitHub Issues.

Bug Reports

Please include:

  • text-intl version
  • Node.js version
  • Minimal reproducible code
  • Expected vs actual behavior

Feature Requests

Please include:

  • Use case description
  • Expected behavior

License

MIT