Communitygithub.com

YepAPI/skills

next-intl と react-i18next のパターン、ロケールルーティング、メッセージ抽出、複数形、RTL、Intl API フォーマット。

skills とは?

このスキルは、Next.js アプリケーションフレームワーク(App Router)向けの `next-intl` と、React シングルページアプリケーション(SPA)向けの `react-i18next` の両方を使用した、プロフェッショナルな i18n(国際化)実装のガイドラインを提供します。主な特徴は、ロケール認識ルーティング(例:`/en/about`、`/fr/about`)、ICU メッセージ形式を使用したメッセージの抽出と複数形、`Intl.DateTimeFormat` や `Intl.NumberFormat` を使用した日付、数値、通貨のフォーマット、および CSS 論理プロパティと `dir="rtl"` 属性による RTL(右から左)言語のサポートです。ベストプラクティスとして、名前空間ごとに JSON 翻訳ファイルを分割し(例:`auth.json`、`dashboard.json`)、ページが必要なものだけを遅延読み込みすることを推奨しています。さらに、ユーザー向け文字列のハードコーディング、翻訳テキストの文字列連結、レイアウトに CSS の `left`/`right` を使用すること、ロケールを `localStorage` のみに保存すること(SEO と共有可能性のために URL ベースのロケールを推奨)など、避けるべきアンチパターンも定義しています。

対応~Claude Code~Codex CLI~Cursor
npx skills add https://github.com/YepAPI/skills/tree/HEAD/skills/i18n

お気に入りのAIに質問する

このエージェントスキルを事前に読み込んだ状態で新しいチャットを開きます。

ドキュメント

i18n

ルール

  • Next.js App Router: next-intl を使用 — useTranslations() フック、NextIntlClientProvider、ロケール検出用ミドルウェア
  • React SPA: react-i18next を使用 — useTranslation() フック、遅延読み込み用 i18next-http-backend を備えた i18n.init()
  • ロケール認識ルーティング: /en/about、/fr/about — ミドルウェアを使用して Accept-Language ヘッダーを検出しリダイレクト
  • 翻訳ファイル: ロケールごと、名前空間ごとの JSON — messages/en/common.json、messages/fr/common.json
  • 名前空間分割: 機能/ページごとに1つの名前空間 — auth.json、dashboard.json、settings.json — ページが必要とするものだけを読み込む
  • 複数形: ICU メッセージ形式を使用 — {count, plural, one {# アイテム} other {# アイテム}}
  • 補間: t('greeting', { name }) — 翻訳された文字列を決して連結しない
  • 日付/数値/通貨: Intl.DateTimeFormat、Intl.NumberFormat を使用 — フォーマットをハードコードしない
  • RTL サポート: <html> に dir="rtl" を使用、CSS 論理プロパティ(margin-left ではなく margin-inline-start)を使用、アラビア語/ヘブライ語でテスト

パターン

// next-intl: middleware.ts
import createMiddleware from "next-intl/middleware";
export default createMiddleware({
  locales: ["en", "fr", "de", "ar"],
  defaultLocale: "en",
});

// next-intl: コンポーネントでの使用例
import { useTranslations } from "next-intl";
function ProductCard({ price, date }: { price: number; date: Date }) {
  const t = useTranslations("products");
  const format = useFormatter();
  return (
    <div>
      <h2>{t("title")}</h2>
      <p>{format.number(price, { style: "currency", currency: "USD" })}</p>
      <p>{format.dateTime(date, { dateStyle: "medium" })}</p>
    </div>
  );
}

避けるべきこと

  • ユーザー向け文字列のハードコーディング — すべての文字列は t() を経由する必要があります
  • 翻訳テキストの文字列連結 — 補間または ICU 形式を使用します
  • すべてのロケールを先読み込み — ロケールと名前空間ごとに遅延読み込みします
  • レイアウトに CSS の left/right を使用 — RTL 互換性のために論理プロパティを使用します
  • ロケールを localStorage のみに保存 — SEO と共有可能性のために URL ベースのロケールを使用します

Individual skills in this repo

This repo contains 20 individual skills — each has its own dedicated page.

YepAPI/skills

WCAG 2.1 AA — semantic HTML, keyboard navigation, screen readers.

YepAPI/skills

Experiment setup, variant splitting, statistical significance, and feature flag integration.

YepAPI/skills

CRUD generators, data tables, user management, role-based access, and bulk operations.

YepAPI/skills

Monitor what ChatGPT and Gemini say about your brand using YepAPI.

YepAPI/skills

Queue workers with BullMQ/Inngest/Trigger.dev, job retries, dead letter queues, concurrency.

YepAPI/skills

Commander.js, interactive prompts with Clack, spinners, colors, config files, exit codes, and npm publishing.

YepAPI/skills

cmdk integration, Cmd+K trigger, fuzzy search, grouped actions, keyboard navigation, and dynamic action registration.

YepAPI/skills

Content planning with trend and sentiment data from YepAPI.

YepAPI/skills

Content calendar, keyword-driven planning, and content briefs.

YepAPI/skills

Theme switching with CSS variables, system preference detection, next-themes, and persistence.

YepAPI/skills

Threaded comments, @mentions, reactions, moderation queue, optimistic UI, and cursor pagination.

YepAPI/skills

Competitive analysis between domains using YepAPI.

YepAPI/skills

Layout grids, KPI cards, data tables with sorting/filtering, sidebar navigation, and responsive breakpoints.

YepAPI/skills

Data encryption — TLS everywhere, AES-256-GCM for PII, bcrypt passwords, encrypted backups.

YepAPI/skills

Chart patterns with Recharts/Nivo/D3, responsive containers, color scales, and accessibility.

YepAPI/skills

Drizzle schema definition, push vs migrate, type-safe queries, relations, transactions, and prepared statements.

YepAPI/skills

Upload handling, resize/compress, CDN delivery, blur placeholders, and next/image patterns.

YepAPI/skills

Local business and Google Maps research using YepAPI.

YepAPI/skills

Cursor-based pagination, IntersectionObserver, virtualized lists with @tanstack/react-virtual, and scroll position restoration.

YepAPI/skills

Chat UI components, streaming responses with AI SDK, context window management, and RAG patterns.

関連スキル