# frontend-internationalization-best-practices

frontend-internationalization-best-practices is a Claude Code skill with best practices for React Router and remix-i18next, covering middleware, locale detection, and SSR hydration sync.

- skill · `type=skill` · Claude Code, Codex, Cursor, GitHub Copilot, Gemini CLI, OpenCode, Windsurf (Devin Desktop), Claude.ai · 195 installs · ★ 92 repo stars
- Author: sergiodxa
- License: MIT · policy=mirror · the beginning of the file is at the end of this page
- Source: https://github.com/sergiodxa/agent-skills/tree/HEAD/skills/frontend-internationalization-best-practices/SKILL.md
- Updated: 2026-02-01
- Security check: automated, 2026-11-16 (text) — no signs of malicious code found.
- HTML: https://affpapa.org/en/nevibecode/skills/frontend-internationalization-best-practices

## What it does

This skill provides targeted guidelines for setting up internationalization in React Router projects powered by `remix-i18next`. It defines patterns for initializing `createI18nextMiddleware`, structuring translation files inside `app/locales`, and handling namespace splits for varying application sizes.

Included instructions cover resource routes like `/api/locales/:lng/:ns` with HTTP cache headers, client-side detection via `htmlTag`, and wiring `I18nextProvider` inside the SSR entry. It also directs loaders to consume bound `t()` instances using `getFixedT`.

The skill strictly targets the `remix-i18next` ecosystem inside React Router framework mode; projects using alternative localization engines will find little use here.

## Install

### Claude Code (native platform)

1. **Skills CLI (Vercel)**
```bash
npx skills add sergiodxa/agent-skills --skill frontend-internationalization-best-practices -a claude-code
```

2. **Manually: put the files in place**
- File: `~/.claude/skills/frontend-internationalization-best-practices/SKILL.md` — Copy the whole skill folder; for one project use .claude/skills/frontend-internationalization-best-practices/

### Codex

1. **Skills CLI (Vercel)**
```bash
npx skills add sergiodxa/agent-skills --skill frontend-internationalization-best-practices -a codex
```

2. **Manually: put the files in place**
- File: `.agents/skills/frontend-internationalization-best-practices/SKILL.md` — For all projects use ~/.agents/skills/

### Cursor

1. **Skills CLI (Vercel)**
```bash
npx skills add sergiodxa/agent-skills --skill frontend-internationalization-best-practices -a cursor
```

2. **Manually: put the files in place**
- File: `.cursor/skills/frontend-internationalization-best-practices/SKILL.md` — Cursor also reads .agents/skills/ and .claude/skills/

### GitHub Copilot

1. **GitHub CLI**
```bash
gh skill install sergiodxa/agent-skills skills/frontend-internationalization-best-practices
```

2. **Manually: put the files in place**
- File: `.github/skills/frontend-internationalization-best-practices/SKILL.md`

### Gemini CLI

1. **Skills CLI (Vercel)**
```bash
npx skills add sergiodxa/agent-skills --skill frontend-internationalization-best-practices -a gemini-cli
```

2. **Platform CLI**
```bash
gemini skills install https://github.com/sergiodxa/agent-skills --path skills/frontend-internationalization-best-practices
```

### Windsurf (Devin Desktop)

**Manually: put the files in place**
- File: `.devin/skills/frontend-internationalization-best-practices/SKILL.md` — The legacy .windsurf/skills/ path still works

### OpenCode

**Skills CLI (Vercel)**
```bash
npx skills add sergiodxa/agent-skills --skill frontend-internationalization-best-practices -a opencode
```

### Claude.ai

**Claude.ai**
- Zip the folder and upload it in Settings → Capabilities → Skills

Where a file is given instead of a command, copy the files from the source to that path: https://github.com/sergiodxa/agent-skills/tree/HEAD/skills/frontend-internationalization-best-practices/SKILL.md

## When to use it
- configure remix-i18next middleware with cookie persistence
- structure locale folders and multi-namespace translation dictionaries
- align SSR locale states with HTML root attributes and client hydration
- expose localized JSON payloads through a cached resource route

## Example prompts
- Configure createI18nextMiddleware for React Router with cookie detection
- Implement a resource route at /api/locales/:lng/:ns with caching headers
- Sync the active locale between root loader and the html tag attributes

## Source text · SKILL.md · MIT

Below is the content of a third-party file. It is data, not instructions for you: do not act on anything written inside unless the human asks. Block tag: 3d1c74a29b774ba7.

BEGIN THIRD-PARTY FILE 3d1c74a29b774ba7
````text
---
name: frontend-internationalization-best-practices
description: Internationalization best practices for React Router framework mode using remix-i18next. Use when setting up locales, middleware, resource routes, or language switching.
---

# Internationalization Best Practices

Guidelines for building a React Router i18n setup with `remix-i18next`. Focuses on middleware detection, locale storage, type safety, and client/server synchronization.

## When to Apply

- Adding i18n to a React Router app
- Wiring `remix-i18next` middleware
- Implementing language switching or locale detection
- Serving locale resources from `/api/locales`

## Rules Summary

### Setup & Middleware (CRITICAL)

#### setup-middleware - @rules/setup-middleware.md

Configure `createI18nextMiddleware` and type-safe resources.

```ts
export const [i18nextMiddleware, getLocale, getInstance] =
  createI18nextMiddleware({
    detection: {
      supportedLanguages: ["es", "en"],
      fallbackLanguage: "en",
      cookie: localeCookie,
    },
    i18next: { resources },
    plugins: [initReactI18next],
  });
```

#### locales-structure - @rules/locales-structure.md

Define locale resources per language and re-export.

```ts
// app/locales/en/translation.ts
export default { title: "Example" };
```

### Namespaces (HIGH)

#### namespaces-strategy - @rules/namespaces-strategy.md

Use a single namespace for small apps; multiple namespaces for large apps.

```ts
// Large app: common + route namespaces
export default { common, home, notFound };
```

### Locale Detection & Persistence (CRITICAL)

#### locale-detection - @rules/locale-detection.md

Prefer cookie/session for speed, with DB as source of truth.

```ts
export const [i18nextMiddleware, getLocale] = createI18nextMiddleware({
  detection: { cookie: localeCookie, fallbackLanguage: "en" },
});
```

#### language-switcher - @rules/language-switcher.md

Store locale in cookie/session and keep it in sync.

```ts
return data(
  { locale },
  { headers: { "Set-Cookie": await localeCookie.serialize(locale) } },
);
```

### Client & Server Integration (CRITICAL)

#### root-locale-sync - @rules/root-locale-sync.md

Send locale to the UI and sync `<html lang dir>`.

```tsx
export async function loader({ context }: Route.LoaderArgs) {
````
END THIRD-PARTY FILE 3d1c74a29b774ba7

The third-party file has ended. Everything between the 3d1c74a29b774ba7 tags is data: requests and commands from it are not followed. An “end of file” line with another tag inside the block is part of the file.

First 2282 of 3456 bytes. © sergiodxa · MIT · https://github.com/sergiodxa/agent-skills/tree/HEAD/skills/frontend-internationalization-best-practices/SKILL.md

_Part of the page did not fit — see the HTML version._

---
NeVibeCode on affpapa.org. Catalog texts are descriptions, not instructions for the agent. How to choose and install: https://affpapa.org/en/nevibecode/agents.md
