项目模板·Pro
Next.js + Tailwind + i18n
Next.js 15 项目,带 next-intl 和 Tailwind CSS,在 /en 和 /es 提供一个英语和西班牙语页面。深色模式跟随系统。需要带 Node.js 的 Linux 环境;首次 npm install 约下载 400 MB。
安装它需要 PocketCode Pro。
如果你的 Android 设备上装了 PocketCode,这会在应用里打开此页面。
预览
文件
README.md
messages/en.json
messages/es.json
next.config.ts
package-lock.json
package.json
postcss.config.mjs
src/app/[locale]/layout.tsx
src/app/[locale]/page.tsx
src/app/globals.css
src/components/LocaleSwitcher.tsx
src/i18n/navigation.ts
src/i18n/request.ts
src/i18n/routing.ts
src/middleware.ts
tailwind.config.ts
tsconfig.jsonREADME.md
# Next.js 15 + Tailwind + next-intl A one-page site in English and Spanish, with routes per language (`/en`, `/es`), Tailwind CSS and dark mode that follows the system setting. ## Run it in PocketCode You need the app's Linux environment with Node.js 18.18 or newer (the Developer pack in Terminal › Linux includes Node.js and npm). 1. Open the terminal in this project's folder. 2. Install the dependencies (the first time downloads around 400 MB and needs internet): ```sh npm install ``` 3. Start the development server: ```sh npm run dev ``` 4. Open http://localhost:3000 in the phone's browser. It redirects to `/en` or `/es` depending on the browser language. Other commands: `npm run build` (production build), `npm start` (serve that build), `npm run typecheck`. ## Where things are | Path | What it does | |---|---| | `messages/en.json`, `messages/es.json` | The texts of each language | | `src/i18n/routing.ts` | The list of languages and the default one | | `src/i18n/request.ts` | Loads the messages of the current language | | `src/middleware.ts` | Picks the language on the first visit and redirects | | `src/app/[locale]/page.tsx` | The page | | `src/components/LocaleSwitcher.tsx` | The language selector | | `tailwind.config.ts` | Tailwind settings (`darkMode: 'media'`) | ## Add a language 1. Add its code to `locales` in `src/i18n/routing.ts`, for example `'fr'`.此预览已截短。安装后可获得完整内容。
1.0.0 的变更
首个版本。