frontend-internationalization-best-practices — скилл для Claude Code
Скилл frontend-internationalization-best-practices для Claude Code описывает настройку i18n в React Router с remix-i18next: middleware, SSR-синхронизацию и словари.
MIT 195 установок ★ 92 обновлён 2026-02-01
npx skills add sergiodxa/agent-skills --skill frontend-internationalization-best-practices -a claude-codeЧто делает frontend-internationalization-best-practices
Скилл содержит архитектурные правила интеграции remix-i18next в приложения на React Router. Он объясняет модели перевода, организацию файлов в app/locales, деление на пространства имён и настройку функции createI18nextMiddleware с обработкой кук и запасного языка.
В правилах зафиксированы конкретные паттерны: отдача словарей через ресурсный маршрут /api/locales/:lng/:ns с кэшированием, проброс локали в атрибуты тега <html lang dir>, привязка инстанса в entry.server через I18nextProvider и вызов getFixedT внутри серверных загрузчиков loader.
Этот скилл рассчитан именно на связку React Router и remix-i18next; для других библиотек локализации эти соглашения не подойдут.
Какие задачи решает
- настроить middleware и детекцию языка через куки в React Router
- организовать структуру файлов переводов и пространства имён
- синхронизировать локаль между сервером, клиентом и HTML-тегами
- создать ресурсный маршрут для загрузки переводов с кэшированием
Примеры запросов агенту
- Настрой middleware для remix-i18next с поддержкой английского и испанского языков
- Добавь синхронизацию текущей локали в корневой loader и html-тег
- Создай ресурсный маршрут /api/locales/:lng/:ns для отдачи переводов
Как установить frontend-internationalization-best-practices
1Через Skills CLI (Vercel)
npx skills add sergiodxa/agent-skills --skill frontend-internationalization-best-practices -a claude-code2Вручную: положить файлы
~/.claude/skills/frontend-internationalization-best-practices/SKILL.mdПапка скилла целиком; для одного проекта — .claude/skills/frontend-internationalization-best-practices/
1Через Skills CLI (Vercel)
npx skills add sergiodxa/agent-skills --skill frontend-internationalization-best-practices -a codex2Вручную: положить файлы
.agents/skills/frontend-internationalization-best-practices/SKILL.mdДля всех проектов — ~/.agents/skills/
1Через Skills CLI (Vercel)
npx skills add sergiodxa/agent-skills --skill frontend-internationalization-best-practices -a cursor2Вручную: положить файлы
.cursor/skills/frontend-internationalization-best-practices/SKILL.mdCursor читает и .agents/skills/, и .claude/skills/
1GitHub CLI
gh skill install sergiodxa/agent-skills skills/frontend-internationalization-best-practices2Вручную: положить файлы
.github/skills/frontend-internationalization-best-practices/SKILL.md1Через Skills CLI (Vercel)
npx skills add sergiodxa/agent-skills --skill frontend-internationalization-best-practices -a gemini-cli2Командой платформы
gemini skills install https://github.com/sergiodxa/agent-skills --path skills/frontend-internationalization-best-practicesВручную: положить файлы
.devin/skills/frontend-internationalization-best-practices/SKILL.mdСтарый путь .windsurf/skills/ тоже читается
Через Skills CLI (Vercel)
npx skills add sergiodxa/agent-skills --skill frontend-internationalization-best-practices -a opencodeClaude.ai
Упакуйте папку в zip и загрузите в Settings → Capabilities → Skills
По шагам, с командами для каждой платформы: Как установить скилл в Claude Code: пять способов
Вопросы о frontend-internationalization-best-practices
Как установить frontend-internationalization-best-practices в Claude Code?
Выполните команду npx skills add sergiodxa/agent-skills --skill frontend-internationalization-best-practices -a claude-code. Файлы скилла сохранятся по пути ~/.claude/skills/frontend-internationalization-best-practices/SKILL.md.
Для какого стека предназначен этот скилл?
Он ориентирован на React Router в режиме фреймворка и библиотеку remix-i18next.
Как скилл предлагает сохранять выбранный пользователем язык?
Основным быстрым хранилищем выступают куки или сессия через Set-Cookie, а база данных используется как надёжный источник истины при авторизации.
Исходный текст
SKILL.md · MIT
---
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) {
let locale = getLocale(context);
return data(
{ locale },
{ headers: { "Set-Cookie": await localeCookie.serialize(locale) } },
);
}
```
#### entry-client-init - @rules/entry-client-init.md
Initialize i18next client with `htmlTag` detection.
```ts
i18next.init({ detection: { order: ["htmlTag"], caches: [] } });
```
#### entry-server-provider - @rules/entry-server-provider.md
Reuse the middleware instance in SSR with `I18nextProvider`.
```tsx
<I18nextProvider i18n={getInstance(routerContext)}>
<ServerRouter context={entryContext} url={request.url} />
</I18nextProvider>
```
### Resource Routes & Caching (HIGH)
#### locales-resource-route - @rules/locales-resource-route.md
Serve `/api/locales/:lng/:ns` with validation and cache headers.
```ts
return data(namespaces[ns.data], { headers });
```
### UI Usage (MEDIUM)
#### use-bound-t-in-loader - @rules/use-bound-t-in-loader.md
Use the bound `t()` in loaders and `useTranslation` in components.
```ts
let t = getInstance(context).getFixedT(locale);
```
### Not Found (MEDIUM)
#### not-found-i18n - @rules/not-found-i18n.md
Provide a 404 route so middleware runs and translations load.
© sergiodxa · MIT · sergiodxa/agent-skills