# @cloudflare/polystella 中文文档

规范地址：https://npmcn.com/package/%40cloudflare/polystella/

版本：0\.4\.0
npm 元数据更新时间：2026-10-21T14:10:20.300Z
中文译文更新时间：2026-11-10T03:43:31.831Z
软件包许可：MIT

本文由上游 README 翻译，可能存在偏差，请结合原文核对 API、命令与配置。版权与许可归原作者所有。

原始 npm 页面：https://www.npmjs.com/package/%40cloudflare/polystella
原文对照：https://npmcn.com/package/%40cloudflare/polystella/?lang=original
项目主页：https://github.com/cloudflare/polystella
源码仓库：https://github.com/cloudflare/polystella

弃用说明：Retired\. Use @cloudflare/polystella-astro instead\.

## 关键信息（来自 npm 元数据）

- 包体积（解压后）：1.8 MB，399 个文件
- 模块格式：ES Module
- TypeScript 类型：包内自带
- 运行依赖：12 个
- peer 依赖：astro ^7\.0\.0，react ^17\.0\.0 \|\| ^18\.0\.0 \|\| ^19\.0\.0
- 首次发布：2026-06-05T15:51:09.068Z
- 最新版本发布：2026-07-07T08:42:04.792Z
- 近 30 天下载量：4323（2026-10-10 至 2026-11-08，npm 官方下载统计）
- 已发布版本数：4（近 12 个月 4 个）

## 中文简介

Astro 的 AI 驱动内容本地化(构建-时间标记下行翻译,R2-cached).

## 安装

```sh
npm install @cloudflare/polystella
```

也可以使用：`pnpm add @cloudflare/polystella`、`yarn add @cloudflare/polystella`、`bun add @cloudflare/polystella`

## README

# PolyStella 单体

> ⚠️ **工作正在进行中.** PolyStella正在积极发展. API,配置形状,以及内部行为可能不经通知而改变. 尚未通过新项目.

PolyStella是一个 [天体](https://astro.build/) 集成在构建时使用AI将内容翻译为附加地语,缓存Cloudflare R2中的翻译,并给被翻译的页面注入地语前缀路由.

## 它会做什么

-   **Build-time翻译.** 翻译 `.md`, (中文(简体) ), `.mdx`,以及 `.toml` 内容包含到其它区域 `astro build`。访客得到静态字节;没有运行时间 AI 呼叫.
-   **R2号.** 翻译内容由源字节+词汇+模型处理. 未更改的页面重建费用为零 。 译出从不执入回向.
-   **词汇控制.** Per-locale YAML 文件 pin do-not- translate terms, 首选翻译, 和免费格式的翻译注释.
-   **手语翻译超载.** 丢弃文件到 `i18n/overrides/{locale}/<mirrored-path>` 它胜过人工智能的逐字输出.
-   **地方前置路由.** 船舶通过注入的动态航道,将本地化前缀页标出.
-   **UI-string 维护.** 用于铬文本的Per-locale JSON文件,有构建时漂移检测和同步+AI-fill的CLI.

## 安装

从 npm 安装 :

```bash
pnpm add @cloudflare/polystella
```

同伴依赖性 : `astro ^7.0.0`,可选 `react ^17 || ^18 || ^19`。 。 。 .

## 快开始

四个文件参与一个典型的设置.

**1\. 联合国. `astro.config.mjs`** 登记合并。 当地人在这里生活.

```js
import { defineConfig } from "astro/config";
import polystella from "@cloudflare/polystella";
import polystellaConfig from "./polystella.config.mjs";

export default defineConfig({
  i18n: {
    defaultLocale: "en-US",
    locales: ["en-US", "pt-BR", "ja-JP"],
  },
  integrations: [polystella(polystellaConfig)],
});
```

**2\. 联合国. `polystella.config.mjs`** ——提供方,词汇,R2,格式专用密钥. 每个选项都记录在 [配置参考](https://polystella-docs.pcx-team.workers.dev/configuration/reference/)。 。 。 .

**3个. `src/content.config.ts`** ——注册兄弟会收藏,使Astro的内容层能取出翻译. 语言集是自动生成的 `astro.config.mjs`。 。 。 .

```ts
import { defineCollection } from "astro:content";
import { polystellaCollections } from "@cloudflare/polystella/content";
import { i18nLoader, i18nSchema } from "@cloudflare/polystella/i18n";

import { blog, authors } from "./content-schemas";

export const collections = {
  ...polystellaCollections({
    source: { blog, authors },
  }),
  i18n: defineCollection({ loader: i18nLoader(), schema: i18nSchema() }),
};
```

**4.四. `src/env.d.ts`** ——取取PolyStella虚拟模块的类型:

```ts
/// <reference types="@cloudflare/polystella/client" />
```

## 仅限使用目录

已经处理本地化内容和路由的项目只能采用 PolyStella的JSON目录流:

```ts
import catalogAstro from "@cloudflare/polystella/catalog/astro";

export default defineConfig({
  i18n: { defaultLocale: "en-US", locales: ["en-US", "pt-BR"] },
  integrations: [catalogAstro({ baseDir: "./src/i18n" })],
});
```

这个束缚 `Astro.locals.t` 财务报告和审定财务报表 `Astro.locals.lhref` 只有这个 没有 运行内容翻译、 路由shims、 R2 缓存设置或本地化 收集 API.

## 文档

完整的文献资料在Nimbus Docs网站(下) `docs/` 在此重播中 :

-   [开始](https://polystella-docs.pcx-team.workers.dev/getting-started/install/) 安装、快速启动、心理模型
-   [概念](https://polystella-docs.pcx-team.workers.dev/concepts/how-it-works/) ——管线,缓存,覆接,跑时桥
-   [配置参考](https://polystella-docs.pcx-team.workers.dev/configuration/reference/) - 每一个选择
-   [国 际](https://polystella-docs.pcx-team.workers.dev/cli/) —— 说 `translate`, (中文(简体) ), `check-ui`, (中文(简体) ), `sync-ui`, (中文(简体) ), `translate-ui`
-   [运行时间 API](https://polystella-docs.pcx-team.workers.dev/runtime-api/locals/) —— 说 `Astro.locals`,中间软件,反应钩
-   [路线图](https://polystella-docs.pcx-team.workers.dev/roadmap/) - 已运出/计划特性

## 捐款

捐款是受欢迎的,但PolyStella是由一个小的 团队和审查没有保障。 见 [`CONTRIBUTING.md`](https://npmcn.com/package/%40cloudflare/polystella/CONTRIBUTING.md)。代理上下文存在于 [`AGENTS.md`](https://npmcn.com/package/%40cloudflare/polystella/AGENTS.md) 财务报告和审定财务报表 [`ARCHITECTURE.md`](https://npmcn.com/package/%40cloudflare/polystella/ARCHITECTURE.md)。 。 。 .

## 许可证

[麻省理工学院](https://npmcn.com/package/%40cloudflare/polystella/LICENSE)

## 常见问题

### @cloudflare/polystella 是什么？

Astro 的 AI 驱动内容本地化\(构建-时间标记下行翻译,R2-cached\)\.注意：该包已被作者标记为弃用——Retired\. Use @cloudflare/polystella-astro instead\.

### 如何安装 @cloudflare/polystella？

在项目目录运行 npm install @cloudflare/polystella，或使用 pnpm add / yarn add / bun add。它还需要宿主项目提供 peer 依赖：astro（^7\.0\.0）。npm 7 及以上与 pnpm 8 及以上默认会自动安装必需的 peer 依赖，Yarn 需要手动安装。它还提供命令行工具 polystella，可以用 npx polystella 直接运行。

### @cloudflare/polystella 支持 TypeScript 吗？

支持。包内自带 TypeScript 类型声明（package\.json 声明了 types 入口），安装后即可获得类型提示，无需再安装 @types 包。

### @cloudflare/polystella 支持 ESM 还是 CommonJS？

以 ES Module 形式发布，推荐使用 import 引入。在 CommonJS 项目中，Node\.js 20\.19\+ / 22\.12\+ 可以直接 require\(\) 不含顶层 await 的 ES Module，更早的版本需要改用动态 import\(\)。

### @cloudflare/polystella 可以商用吗？

@cloudflare/polystella 使用 MIT 许可。宽松许可：允许商业使用、修改和再分发，通常只需在分发时保留原版权与许可声明。以上为概括，不构成法律意见，请以许可原文为准。

### @cloudflare/polystella 的下载量有多少？

根据 npm 官方下载统计，@cloudflare/polystella 在 2026/10/10 – 2026/11/08 这 30 天内被下载 4,323 次，日均约 144 次。下载量会把 CI 构建、镜像同步和作为其他包依赖的安装一并计入，适合横向比较热度，不能直接等同于使用人数。

### @cloudflare/polystella 还在维护吗？

最新版本 0\.4\.0 发布于 2026/07/07（4 个月前）；至今共发布 4 个版本，其中过去 12 个月发布了 4 个；首次发布于 2026/06/05。作者已将其标记为弃用，新项目建议寻找替代方案。

