Skip to content
Skillv1.0.0

next-intl

Internationalize Next.js apps with next-intl. Use when adding multi-language support, locale routing, date/number formatting, or translating UI content.

by terminalskills(0) 0 installs
Free
Sign in to install

Free account. Installing gives you the manifest plus copy-paste snippets.

See reviews

About

Imported from terminalskills/skills (skills/next-intl/SKILL.md). Install upstream with npx skills add terminalskills/skills --skill next-intl. Copyright stays with the author (Apache-2.0).

next-intl

Overview

next-intl is the leading i18n library for Next.js App Router. It handles locale routing, message translation, date/number formatting, and works with both server and client components. ICU message syntax for plurals and variables.

Instructions

Step 1: Setup

npm install next-intl
// i18n/request.ts — Locale detection
import { getRequestConfig } from 'next-intl/server'

export default getRequestConfig(async ({ requestLocale }) => {
  const locale = await requestLocale || 'en'
  return {
    locale,
    messages: (await import(`../messages/${locale}.json`)).default,
  }
})
// messages/en.json
{
  "HomePage": {
    "title": "Welcome to {appName}",
    "description": "The best tool for {count, plural, one {# team} other {# teams}}",
    "cta": "Get Started"
  },
  "Dashboard": {
    "greeting": "Hello, {name}",
    "lastLogin": "Last login: {date, date, medium}"
  }
}
// messages/de.json
{
  "HomePage": {
    "title": "Willkommen bei {appName}",
    "description": "Das beste Tool für {count, plural, one {# Team} other {# Teams}}",
    "cta": "Jetzt starten"
  }
}

Step 2: Server Components

// app/[locale]/page.tsx — Translated server component
import { useTranslations } from 'next-intl'

export default function HomePage() {
  const t = useTranslations('HomePage')

  return (
    <main>
      <h1>{t('title', { appName: 'MyApp' })}</h1>
      <p>{t('description', { count: 5000 })}</p>
      <a href="/signup">{t('cta')}</a>
    </main>
  )
}

Step 3: Middleware Routing

// middleware.ts — Locale routing
import createMiddleware from 'next-intl/middleware'

export default createMiddleware({
  locales: ['en', 'de', 'fr', 'ja'],
  defaultLocale: 'en',
  localePrefix: 'as-needed',        // /de/about but /about (for en)
})

export const config = { matcher: ['/((?!api|_next|.*\\..*).*)'] }

Guidelines

  • ICU message syntax: {count, plural, one {# item} other {# items}} for plurals.
  • Server components: use useTranslations() directly, no context needed.
  • Client components: wrap with NextIntlClientProvider.
  • Keep message keys namespaced by page/component for maintainability.
  • Use localePrefix: 'as-needed' to avoid /en/ prefix for default locale.

Use it

Copy one of these into your project. Installing also returns the manifest and these snippets.

yaml
targets:
  - https://api.opensmartroute.ai/api/v1/registry/terminalskills-skills-next-intl/manifest   # or paste the manifest below

Manifest

An Open Capability Manifest: the router reads it to know what this does, what it costs and when to pick it.

terminalskills-skills-next-intl.ocm.jsonjson
{
  "ocm": "1",
  "id": "terminalskills-skills-next-intl",
  "kind": "skill",
  "name": "next-intl",
  "description": "Internationalize Next.js apps with next-intl. Use when adding multi-language support, locale routing, date/number formatting, or translating UI content.",
  "publisher": "terminalskills",
  "version": "1.0.0",
  "capabilities": {
    "domains": [
      "general"
    ],
    "tags": [
      "skill-md",
      "i18n",
      "next-intl",
      "nextjs",
      "localization",
      "internationalization",
      "skills-sh"
    ],
    "languages": [
      "en"
    ]
  },
  "quality_prior": 0.6,
  "examples": [
    "Internationalize Next.js apps with next-intl. Use when adding multi-language support, locale routing, date/number formatting, or translating UI content."
  ],
  "primary": false,
  "metadata": {
    "source": {
      "provider": "skills.sh",
      "repository": "https://github.com/terminalskills/skills",
      "path": "skills/next-intl/SKILL.md",
      "ref": "HEAD",
      "url": "https://github.com/terminalskills/skills/blob/HEAD/skills/next-intl/SKILL.md",
      "key": "terminalskills/skills/skills/next-intl/SKILL.md"
    },
    "compatibility": "Next.js 13+ (App Router)",
    "license": "Apache-2.0"
  },
  "instructions": "# next-intl\n\n## Overview\n\nnext-intl is the leading i18n library for Next.js App Router. It handles locale routing, message translation, date/number formatting, and works with both server and client components. ICU message syntax for plurals and variables.\n\n## Instructions\n\n### Step 1: Setup\n\n```bash\nnpm install next-intl\n```\n\n```typescript\n// i18n/request.ts — Locale detection\nimport { getRequestConfig } from 'next-intl/server'\n\nexport default getRequestConfig(async ({ requestLocale }) => {\n  const locale = await requestLocale || 'en'\n  return {\n    locale,\n    messages: (await import(`../mess",
  "cost": {
    "context_tokens": 579
  }
}

Fetch it by URL: GET /api/v1/registry/terminalskills-skills-next-intl/manifest?version=1.0.0

Reviews

Star ratings from people who tried it. One review per account; edit yours any time.

No reviews yet. Install it, try it, and be the first to rate it.