home / skills / secondsky / claude-skills / internationalization-i18n

This skill implements multi-language support with i18n tooling and formatting, enabling RTL, pluralization, and locale-aware dates and numbers.

npx playbooks add skill secondsky/claude-skills --skill internationalization-i18n

Review the files below or copy the command above to add this skill to your agents.

Files (2)
SKILL.md
2.3 KB
---
name: internationalization-i18n
description: Implements multi-language support using i18next, gettext, or Intl API with translation workflows and RTL support. Use when building multilingual applications, handling date/currency formatting, or supporting right-to-left languages.
---

# Internationalization (i18n)

Implement multi-language support with proper translation management and formatting.

## i18next Setup (React)

```javascript
import i18n from 'i18next';
import { initReactI18next } from 'react-i18next';
import LanguageDetector from 'i18next-browser-languagedetector';

i18n
  .use(LanguageDetector)
  .use(initReactI18next)
  .init({
    fallbackLng: 'en',
    interpolation: { escapeValue: false },
    resources: {
      en: { translation: { welcome: 'Welcome, {{name}}!' } },
      es: { translation: { welcome: '¡Bienvenido, {{name}}!' } }
    }
  });

// Usage
const { t } = useTranslation();
<h1>{t('welcome', { name: 'John' })}</h1>
```

## Pluralization

```javascript
// Translation file
{
  "items": "{{count}} item",
  "items_plural": "{{count}} items",
  "items_zero": "No items"
}

// Usage
t('items', { count: 0 })  // "No items"
t('items', { count: 1 })  // "1 item"
t('items', { count: 5 })  // "5 items"
```

## Date/Number Formatting

```javascript
// Dates
new Intl.DateTimeFormat('de-DE', {
  dateStyle: 'long',
  timeStyle: 'short'
}).format(new Date());

// Numbers
new Intl.NumberFormat('en-US', {
  style: 'currency',
  currency: 'USD'
}).format(1234.56);  // "$1,234.56"

// Relative time
new Intl.RelativeTimeFormat('en', { numeric: 'auto' })
  .format(-1, 'day');  // "yesterday"
```

## RTL Support

```css
/* Use logical properties */
.container {
  margin-inline-start: 1rem;  /* margin-left in LTR, margin-right in RTL */
  padding-inline-end: 1rem;
}

/* Direction attribute */
html[dir="rtl"] .icon {
  transform: scaleX(-1);
}
```

## Additional Frameworks

See [references/frameworks.md](references/frameworks.md) for:
- React-Intl (Format.js) complete implementation
- Python gettext with Flask/Babel
- RTL language support patterns
- ICU Message Format examples

## Best Practices

- Extract all user-facing strings
- Use ICU message format for complex translations
- Test with pseudo-localization
- Support RTL from the start
- Never concatenate translated strings
- Use professional translators for production

Overview

This skill implements robust multi-language support for TypeScript apps using i18next, gettext, or the Intl API. It includes translation workflows, pluralization, date/number formatting, and built-in RTL (right-to-left) handling for production-ready multilingual interfaces. Use it to standardize localization across React, Cloudflare, and AI-integrated projects.

How this skill works

The skill initializes a chosen i18n library (e.g., i18next or gettext) and provides conventions for resource structure, language detection, and fallback behavior. It demonstrates runtime formatting using Intl for dates, numbers, and relative time, and shows CSS patterns and HTML direction attributes to enable RTL layouts. Translation workflows cover extraction, plural rules, ICU message formatting, and pseudo-localization for testing.

When to use it

  • Building a multilingual React app or UI component library
  • Formatting dates, currencies, and relative times per locale
  • Adding right-to-left language support (Arabic, Hebrew)
  • Standardizing translation extraction and deployment workflows
  • Ensuring consistent pluralization and ICU message usage across codebase

Best practices

  • Extract all user-facing strings into resource files; avoid in-code concatenation
  • Prefer ICU Message Format for complex interpolations and plural rules
  • Use language detection with a sensible fallback (e.g., fallbackLng: 'en')
  • Test with pseudo-localization and real translators before release
  • Design CSS with logical properties and respect the html[dir] attribute for RTL support

Example use cases

  • React app using i18next with initReactI18next and browser language detection
  • Server-side translation with gettext or Flask-Babel for backend-rendered pages
  • Formatting prices and dates with Intl.NumberFormat and Intl.DateTimeFormat per locale
  • Handling pluralization and zero/one/many rules in translation JSON files
  • Adapting UI layout and iconography for RTL by toggling html[dir] and flipping icons

FAQ

Which library should I choose: i18next, react-intl, or gettext?

Choose i18next for flexible JS/React integration and ecosystem tools; react-intl (Format.js) for strict ICU-first workflows; gettext for traditional server-side or Python apps. Base decision on platform, existing tooling, and translator workflow.

How do I handle RTL styles consistently?

Use CSS logical properties (margin-inline, padding-inline) and toggle html[dir]="rtl". Flip directional icons via transform: scaleX(-1) when dir="rtl" and test layout with real RTL content.