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

ht-i18n

v1.0.2

Published

Lightweight React i18n library with native Kreyòl Ayisyen support — first npm package with built-in Haitian Creole

Readme

ht-i18n

npm Bundle size TypeScript React License: MIT Made in Haiti Open Source

The first npm library with native Kreyòl Ayisyen support.
Lightweight React i18n — zero dependencies — TypeScript-first.


📋 Table of Contents

| # | Section | |:---:|:---| | 1 | Why ht-i18n? | | 2 | Installation | | 3 | Quick Start | | 4 | API Reference | | 5 | 200+ Built-in Keys | | 6 | Troubleshooting | | 7 | FAQ | | 8 | Contributing | | 9 | Credits |


✦ Why ht-i18n?

Haiti has 11+ million Kreyòl speakers — yet Kreyòl Ayisyen is virtually absent from open-source tooling. Every i18n library ships French, Spanish, Arabic, sometimes Swahili — but never Kreyòl.

ht-i18n fixes that. It ships 200+ pre-translated keys for Kreyòl, French, and English — covering the most common UI patterns out of the box — with a developer experience that stays out of your way.

  • < 3KB gzip · zero runtime dependencies
  • TypeScript-first — full type safety, autocomplete on keys
  • React Context based — compatible with React Native
  • Fallback chain — graceful degradation across languages
  • Auto-detection from navigator.language

↑ Back to top


✦ Installation

# npm
npm install ht-i18n

# yarn
yarn add ht-i18n

# pnpm
pnpm add ht-i18n

Requirements: React ≥ 17 · Node.js ≥ 18

↑ Back to top


✦ Quick Start

1. Wrap your app with I18nProvider

// root.tsx or main.tsx
import { I18nProvider } from 'ht-i18n';
import { App } from './App';

export default function Root() {
  return (
    <I18nProvider defaultLang="ht" fallback={['fr', 'en']}>
      <App />
    </I18nProvider>
  );
}

2. Translate in any component

import { useTranslation } from 'ht-i18n';

export function Greeting({ name }: { name: string }) {
  const { t, lang, setLang } = useTranslation();

  return (
    <div>
      <h1>{t('greeting', { name })}</h1>
      {/* → "Bonjou, Marie!" in Kreyòl */}

      <button onClick={() => setLang('ht')}>🇭🇹 Kreyòl</button>
      <button onClick={() => setLang('fr')}>🇫🇷 Français</button>
      <button onClick={() => setLang('en')}>🇬🇧 English</button>
    </div>
  );
}

3. Add custom translations

import { I18nProvider } from 'ht-i18n';

const myLocales = {
  ht: { 'app.title': 'Aplikasyon mwen' },
  fr: { 'app.title': 'Mon application' },
  en: { 'app.title': 'My application' },
};

function Root() {
  return (
    <I18nProvider locales={myLocales} defaultLang="ht">
      <App />
    </I18nProvider>
  );
}

Custom locales are merged with built-ins — your keys override, everything else stays available.

↑ Back to top


✦ API Reference

<I18nProvider>

| Prop | Type | Default | Description | |:---|:---|:---:|:---| | defaultLang | 'ht' \| 'fr' \| 'en' | 'ht' | Initial language | | locales | Record<Lang, Record<string, string>> | built-in | Custom translations (merged) | | fallback | Lang[] | ['fr', 'en'] | Fallback chain when a key is missing | | autoDetect | boolean | true | Auto-detect from navigator.language |


useTranslation()

const { t, lang, setLang } = useTranslation();

| Return | Type | Description | |:---|:---|:---| | t(key, vars?) | (key: string, vars?: Record<string, string \| number>) => string | Translate a key with optional interpolation | | lang | 'ht' \| 'fr' \| 'en' | Current active language | | setLang | (lang: Lang) => void | Switch language |


Interpolation

Keys support {{variable}} placeholders:

{ "greeting": "Bonjou, {{name}}!" }
t('greeting', { name: 'Marie' })
// → "Bonjou, Marie!"

Plurals

Use _one and _other suffixes:

{
  "items_one": "{{count}} atik",
  "items_other": "{{count}} atik"
}
t('items', { count: 1 })  // → "1 atik"
t('items', { count: 5 })  // → "5 atik"

↑ Back to top


✦ 200+ Built-in Keys

ht-i18n ships with ~200 pre-translated keys covering the most common UI patterns — in Kreyòl, French, and English.

# Actions
btn.save       btn.cancel     btn.delete     btn.confirm
btn.edit       btn.close      btn.back       btn.next

# Errors
err.required   err.invalid    err.network    err.notfound

# Navigation
nav.home       nav.about      nav.contact    nav.settings

# Auth
auth.login     auth.logout    auth.signup    auth.password

# Status
status.loading   status.success   status.error   status.empty

View the full list → src/locales/ht.json

↑ Back to top


✦ Troubleshooting

Cannot find module 'ht-i18n'

rm -rf node_modules package-lock.json
npm install

If still failing:

npm install ht-i18n --save

useTranslation must be used within an I18nProvider

Your component is outside the provider tree:

// ❌ Wrong
function App() {
  return <MyComponent />;
}

// ✅ Correct
function App() {
  return (
    <I18nProvider defaultLang="ht">
      <MyComponent />
    </I18nProvider>
  );
}

Translation key returns itself (e.g. "btn.save")

The key isn't found in your locale. Check:

  1. Spelling is exact — keys are case-sensitive
  2. The key exists in your locales object
  3. Your fallback chain includes a language that has the key
// Quick debug
const { t } = useTranslation();
console.log(t('btn.save')); // Should NOT return "btn.save"

TypeScript: Type 'string' is not assignable to type 'Lang'

// ❌ Wrong
const lang = 'ht';

// ✅ Correct
import type { Lang } from 'ht-i18n';
const lang: Lang = 'ht';

Language detection not working

navigator.language may return 'fr-HT' instead of 'ht'. You can disable auto-detection and handle it manually:

<I18nProvider defaultLang="ht" autoDetect={false}>

Or normalize on mount:

useEffect(() => {
  const nav = navigator.language.split('-')[0] as Lang;
  if (['ht', 'fr', 'en'].includes(nav)) setLang(nav);
}, []);

SSR / Next.js: ReferenceError: navigator is not defined

<I18nProvider defaultLang="ht" autoDetect={false}>

Then detect language client-side inside a useEffect.


Bundle larger than expected

Use named imports only — they're tree-shakeable:

// ✅ Tree-shakeable
import { useTranslation } from 'ht-i18n';

// ❌ Avoid — pulls everything in
import ht from 'ht-i18n';

↑ Back to top


✦ FAQ

Q: Poukisa Kreyòl Ayisyen kòm lang prensipal?
A: Ayiti gen plis pase 11 milyon moun ki pale Kreyòl. Se lang manman majorite Ayisyen yo — men li prèske absan nan zouti open-source yo. Pwojè sa a chanje sa.

Q: Can I use ht-i18n without React?
A: The core translate() function is framework-agnostic. The React-specific parts (I18nProvider, useTranslation) require React 17+.

Q: Does it support RTL languages?
A: Not natively. You can combine it with CSS dir="rtl" on your own elements.

Q: How do I add a language beyond ht / fr / en?

const locales = {
  ht: { ... },
  fr: { ... },
  en: { ... },
  es: { 'btn.save': 'Guardar' },
};
<I18nProvider locales={locales} defaultLang="ht">

Q: Are the Kreyòl translations validated by native speakers?
A: The initial 200 keys were reviewed carefully. Contributions from native Kreyòl speakers are actively welcome — open an issue or PR anytime.

Q: Does it work with React Native?
A: Yes — it only uses React Context. Tested with React Native 0.73+.

↑ Back to top


✦ Contributing

Contributions are what make open source thrive.

  • 🐛 Bug reportsOpen an issue
  • 🌍 Translation improvements → Edit src/locales/*.json
  • New features → Open a PR with a clear description
  • 📖 Docs → Always welcome
# Fork and clone
git clone https://github.com/YOUR_USERNAME/ht-i18n.git
cd ht-i18n

# Install
npm install

# Develop
npm run dev

# Test
npm test

# Build
npm run build

↑ Back to top


✦ Credits

Designed, built & maintained by

mrsaget2003

GitHub npm Made in Haiti

MIT License · © 2026 mrsaget2003

For Haiti's 11 million Kreyòl speakers — and every developer who builds for them.

↑ Back to top