Skip to content
项目

关于

为你的 NextJs 应用提供最简单的翻译方式。

网站与应用开发

这些数字如何统计

实测星标增长

24小时
0
7天
+2
15天
+3
1个月
+2

各周期内的星标净变化,周期相互重叠,并非每日新增。缺失的测量保持空白。星标代表关注度,不代表软件质量。

README.md

原文

next-i18next

npm version npm Socket Badge

The easiest way to translate your Next.js apps.

Supports the App Router (Server Components, Client Components, the proxy), the Pages Router, and mixed setups where both routers coexist.

If you already know i18next: next-i18next v16 is a thin layer on top of i18next and react-i18next that handles the Next.js-specific wiring (the proxy, the server/client split, handing the translations to the browser), so you don't have to.

Documentation: www.i18next.com/next

Advice:

If you don't like to manage your translation files manually or are simply looking for a better management solution, take a look at i18next-locize-backend. The i18next backend plugin for 🌐 Locize ☁️ — built by the same team behind next-i18next, with CDN delivery (works great on Vercel/serverless), AI translation, and no redeploys for copy changes.

Starting from a Next.js app with hardcoded strings? Run npx i18next-cli localize: one command that wraps strings in t() (since i18next-cli 1.90 with await getT() in Server Components and useT() in Client Components; review the diff and the warnings), extracts keys, connects to Locize and AI-translates your app. See the launch post.

Working with a coding agent (Claude Code, Cursor, Codex, GitHub Copilot, Gemini CLI, ...)? Paste this prompt; the CLI prints the steps for its installed version, you review the diff, and the translation files stay in your repository unless you choose otherwise (what the prompt tells your agent):

Localize this app with i18next.
Run `npx i18next-cli localize --print-agent-prompt` and follow
the steps it prints, in order, checking each one before the next.

Install

npm install next-i18next i18next react-i18next

Where to start

i18next-locize-backend

To load the translations from Locize, the translation management service by the i18next maintainers, add i18next-locize-backend to use in your config:

import { defineConfig } from 'next-i18next'
import LocizeBackend from 'i18next-locize-backend'

export default defineConfig({
  supportedLngs: ['en', 'de'],
  fallbackLng: 'en',
  use: [LocizeBackend],
  i18nextOptions: {
    backend: {
      projectId: 'your-project-id',
      apiKey: 'your-api-key', // only needed for saving missing keys
    },
  },
})

The apiKey is only needed to save missing keys: put it into development builds, never into production. Everything else works as with any i18next backend: Custom backends shows the server config, the backend for I18nProvider in the browser, and why backends stay out of the server render.

Moved to www.i18next.com

The sections that were in this README are pages of the documentation now:

Section Now
What's new in v16 Introduction
App Router setup App Router setup
Server module App Router setup, step 5
Hide default locale Hide default locale
Translated paths Translated paths
No-locale-path mode No-locale-path mode
Internal locale mode Internal locale mode
Static export Static export
Loading languages on demand Loading languages on demand
ICU and MF2 with the App Router ICU and MF2
Mixed router setup Mixed routers
Pages Router setup Pages Router setup
Fallback locales Pages Router setup, fallback locales
Fallback SSG pages Pages Router setup, fallback SSG pages
Loading translations on the client Pages Router setup, loading translations on the client
Reloading in development Pages Router setup, reloading in development
Missing keys with saveMissing Pages Router setup, missing keys with saveMissing
Vercel and Netlify Pages Router setup, Vercel and Netlify
Docker Pages Router setup, Docker
Unserializable configs Pages Router setup, unserializable configs
Pages Router options Config options
Multi-tenant setups Multi-tenant setups
Custom i18next backends Custom backends
API reference API reference
Config options Config options
Migration from v15 Migration from v15

Examples

Example Description
app-router-simple App Router with locale-in-path (/en/...)
app-router-no-locale-path App Router with cookie-based language (no locale in URL)
app-router-icu App Router with ICU MessageFormat: plurals, select and rich text in Server and Client Components
mixed-routers App Router + Pages Router in the same project
pages-router-simple Pages Router with getStaticProps / getServerSideProps
pages-router-ssg Pages Router with static export (output: 'export')
pages-router-auto-static-optimize Pages Router with client-side loading via chained backend

Contributors

Thanks goes to these wonderful people (emoji key):

Rob Capellini
Rob Capellini

💻 ⚠️
Alexander Kachkaev
Alexander Kachkaev

📢 💬 🤔 💻 ⚠️
Mathias Wøbbe
Mathias Wøbbe

💻 🤔 ⚠️
Lucas Feliciano
Lucas Feliciano

🤔 👀
Ryan Leung
Ryan Leung

💻
Nathan Friemel
Nathan Friemel

💻 📖 💡 🤔
Isaac Hinman
Isaac Hinman

💻 📖 🤔 🚧
Adriano Raiano
Adriano Raiano

💻 📖 🤔 🚧
Felix Mosheev
Felix Mosheev

💬 💻 ⚠️
Sébastien Vanvelthem
Sébastien Vanvelthem

💻 📖

This project follows the all-contributors specification. Contributions of any kind welcome!


Gold Sponsors


localization as a service - Locize

Needing a translation management? Want to edit your translations with an InContext Editor? Use the original provided to you by the maintainers of i18next!

Now with a Free plan for small projects! Perfect for hobbyists or getting started.

By using Locize you directly support the future of i18next and next-i18next.


探索相关项目

加载中…