> ## Documentation Index
> Fetch the complete documentation index at: https://supastack.dev/llms.txt
> Use this file to discover all available pages before exploring further.
> For the full documentation corpus in one file, fetch: https://supastack.dev/llms-full.txt

# i18n 模块

每个界面共享的语言契约。

## 开始之前

使用“文件”→“打开文件夹”在 Visual Studio Code 中打开下载的 supastack 项目，然后选择“终端”→“新建终端”。存储库根目录是包含 package.json、apps 和 packages 的文件夹。运行下面的命令并保持终端打开。如果无法识别命令，请先完成工具安装指南，然后再继续。

首先阅读平台教程。服务器是响应浏览器或电话请求的应用程序进程。 Web 读取 apps/web/.env.local，Expo 读取 apps/mobile/.env.local，数据库迁移命令读取 root .env。无数据库/仪表板演示与真实/身份验证帐户分开，需要迁移Postgres。仅电话或桌面结帐需要单独运行的 Web 后端。

[安装工具并获取代码](https://supastack.dev/zh/docs/web/before-you-start.md)

[学习命令、文件和配置](https://supastack.dev/zh/docs/web/terminal-basics.md)

[完成Web首次运行教程](https://supastack.dev/zh/docs/web/ship-in-5-minutes.md)

```
corepack pnpm --filter @supastack/web dev
```


## 安装与配置

packages/i18n 拥有语言集合与解析契约：SUPPORTED_LOCALES、DEFAULT_LOCALE、LOCALE_COOKIE、isAppLocale、resolveLocale、localePath 与 getDictionary。Web 路由、移动端文案与事务邮件都读同一个包。

解析顺序是路径前缀 → cookie → Accept-Language → 默认值。localePath(locale, path) 产出规范链接 —— 默认语言无前缀，其余为 /{locale}/… —— 代理由此执行。

```
import { getDictionary, localePath, resolveLocale } from "@supastack/i18n";

const locale = resolveLocale([pathLocale, cookie, acceptLanguage]);
const copy = getDictionary(locale).marketing;
```


## 实现流程

新增面向用户的字符串时先加进词典类型，再补全每种语言 —— 翻译完整性套件会对缺失键与未翻译的英文文本报错。

永远不要让产品逻辑按语言分支；词典是表现层。日期、数字与复数用带解析语言的 Intl API 格式化，而不是字符串模板。


## 验证与排障

改动键之后运行 i18n 包测试与 site-content 完整性套件。抽查语言前缀路由、语言切换器，以及清掉 cookie 后的 Accept-Language 检测。


## 下一篇

[工作区](https://supastack.dev/zh/docs/modules/workspaces.md)
