mcpField
R
react-i18n

react-i18n

github.com/fusengineDevelopment3446 installsUpdated 2w ago
Repository

About react-i18n

A skill for adding react-i18next internationalization to React 19 apps built with Vite or CRA, excluding Next.js. It guides developers through typed translations, localization loading, language detection, and testing.

Key features

  1. 01Typed translation keys with the Selector API
  2. 02Feature-based translation namespaces
  3. 03ICU pluralization and interpolation
  4. 04Lazy loading and language detection
  5. 05React 19 Suspense and Trans support
  6. 06RTL, fallback, and test setup guidance

Use cases

  1. 01Add type-safe translations to a React 19 app
  2. 02Load locale files by route or feature
  3. 03Format plural messages, dates, and currency
  4. 04Test components with mocked i18n

Install

Copy the command and run it in a terminal.

$npx skills add https://github.com/fusengine/agents --skill react-i18n

After installing, type/react-i18nin Claude Code to confirm it loaded.

Bundled files

References and scripts installed along with SKILL.md.

references/
fallback-strategies.md
i18next-basics.md
interpolation.md
language-detection.md
lazy-loading.md
namespaces.md
pluralization.md
react-19-integration.md
rtl-support.md
testing.md
trans-component.md
typescript-types.md
references/templates/
basic-setup.md
date-number-formatter.md
form-validation-i18n.md
language-switcher.md
lazy-loading-routes.md
plural-interpolation.md
testing-i18n.md
trans-component-examples.md
typed-translations.md

Details

From the project README
Implements react-i18next in a React 19 app (Vite/CRA, not Next.js): `useTranslation()` hook usage, the TypeScript Selector API (i18next ≥25.4) for type-safe translation keys, namespace organization for code splitting, pluralization with ICU MessageFormat, interpolation (variables, dates, numbers, currency), lazy-loaded translations, and browser/URL/cookie language detection.

Also covers React 19 Suspense integration, the Trans component for JSX inside translations, RTL language support, fallback strategies for missing keys, and unit-testing i18n setups. This skill is explicitly for React apps without Next.js — for Next.js App Router i18n use nextjs-i18n, and for Astro use astro-i18n.

react-i18next for React 19

Agent Workflow (MANDATORY)

Before ANY implementation, spawn 3 agents in parallel, one Agent call each with a name:

  1. fuse-ai-pilot:explore-codebase - Analyze existing i18n setup and translation patterns
  2. fuse-ai-pilot:research-expert - Verify latest react-i18next/i18next docs via Context7/Exa
  3. mcp__context7__query-docs - Check TypeScript Selector API and React 19 Suspense patterns

After implementation, run fuse-ai-pilot:sniper for validation.


MANDATORY: SOLID Principles

ALWAYS apply SOLID principles from solid-react skill.

→ See ../solid-react/SKILL.md for complete rules

Key Rules:

  • Files < 100 lines (split at 90)
  • Interfaces in modules/[feature]/src/interfaces/
  • JSDoc mandatory on all exports
  • No business logic in components

Core Hooks

HookPurposeGuide
useTranslation()Access translations and i18n instancereferences/i18next-basics.md
useTranslation(ns)Load specific namespacereferences/namespaces.md
useTranslation([ns])Load multiple namespacesreferences/namespaces.md

→ See references/i18next-basics.md for detailed usage


Key Packages

PackagePurposeSize
i18nextCore library~40KB
react-i18nextReact bindings~12KB
i18next-http-backendLazy loading~5KB
i18next-browser-languagedetectorAuto-detection~8KB

Key Features

TypeScript Selector API (i18next ≥25.4)

Type-safe translations with autocompletion. → See references/typescript-types.md

Namespaces

Organize translations by feature for code splitting. → See references/namespaces.md

Pluralization

Count-based rules with ICU MessageFormat support. → See references/pluralization.md

Interpolation

Variables, dates, numbers, and currency formatting. → See references/interpolation.md

Lazy Loading

Load translations on-demand per route. → See references/lazy-loading.md

Language Detection

Auto-detect from browser, URL, cookie, localStorage. → See references/language-detection.md

React 19 Integration

Suspense, useTransition, Concurrent Rendering. → See references/react-19-integration.md

Trans Component

JSX elements inside translations. → See references/trans-component.md

Testing

Mock i18n for unit tests. → See references/testing.md

RTL Support

Right-to-left languages (Arabic, Hebrew). → See references/rtl-support.md

Fallback Strategies

Handle missing keys gracefully. → See references/fallback-strategies.md


Templates

TemplateUse Case
templates/basic-setup.mdConfiguration with React 19
templates/language-switcher.mdDropdown component
templates/typed-translations.mdTypeScript Selector API
templates/form-validation-i18n.mdTranslated form errors
templates/lazy-loading-routes.mdPer-route loading
templates/date-number-formatter.mdIntl formatting
templates/plural-interpolation.mdCount-based messages
templates/trans-component-examples.mdJSX in translations
templates/testing-i18n.mdUnit test setup

Modular Architecture (SOLID)

src/
├── modules/cores/i18n/
│   ├── src/
│   │   ├── interfaces/
│   │   │   └── i18n.interface.ts
│   │   ├── services/
│   │   │   └── i18n.service.ts
│   │   ├── hooks/
│   │   │   └── useLanguage.ts
│   │   └── config/
│   │       └── i18n.config.ts
│   ├── components/
│   │   └── LanguageSwitcher.tsx
│   └── locales/
│       ├── en/
│       │   └── translation.json
│       └── es/
│           └── translation.json
└── main.tsx

Best Practices

  1. Suspense: Wrap app with <Suspense> for loading states
  2. Namespaces: One namespace per feature/module
  3. TypeScript: Use Selector API for type-safe keys
  4. Lazy Loading: Load namespaces on-demand
  5. Detection: Configure language detection order
  6. Fallback: Always set fallbackLng

Forbidden (Anti-Patterns)

  • ❌ Hardcoded strings → use t('key')
  • ❌ No Suspense → causes loading flicker
  • ❌ All translations in one file → use namespaces
  • ❌ No fallback language → broken UI
  • ❌ String concatenation → use interpolation {{var}}
  • ❌ Manual language state → use i18n.changeLanguage()

Comments

Markdown supported