@cloudflare/polystella

中文文档
0.4.0发布于 2026/07/07MITTypeScriptES Module近 30 天下载 4323

AI-driven content localization for Astro (build-time markdown translation, R2-cached).

此软件包已被标记为弃用

Retired. Use @cloudflare/polystella-astro instead.

原始使用文档
文档目录7 节
  1. What it does
  2. Install
  3. Quick start
  4. Catalog-Only Usage
  5. Documentation
  6. Contributing
  7. License

PolyStella

⚠️ Work in progress. PolyStella is in active development. APIs, configuration shapes, and internal behaviour may change without notice. Do not adopt for new projects yet.

PolyStella is an Astro integration that translates content into additional locales at build time using AI, caches translations in Cloudflare R2, and injects locale-prefixed routes for the translated pages.

What it does

  • Build-time translation. Translates .md, .mdx, and .toml content into additional locales during astro build. Visitors get static bytes; no runtime AI calls.
  • R2-cached. Translations are content-addressed by source bytes + glossary + model. Unchanged pages cost zero on rebuild. Translations are never committed to the repo.
  • Glossary control. Per-locale YAML files pin do-not-translate terms, preferred translations, and free-form translator notes.
  • Hand-translation overrides. Drop a file at i18n/overrides/{locale}/<mirrored-path> and it wins over AI output verbatim.
  • Locale-prefixed routing. Ships its own route shims that locale-prefix pages via injected dynamic routes.
  • UI-string maintenance. Per-locale JSON files for chrome text, with build-time drift detection and a CLI for sync + AI-fill.

Install

Install from npm:

pnpm add @cloudflare/polystella

Peer dependencies: astro ^7.0.0, optionally react ^17 || ^18 || ^19.

Quick start

Four files participate in a typical setup.

1. astro.config.mjs — register the integration. Locale set lives here.

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 — provider, glossary, R2, format-specific keys. Every option is documented in the configuration reference.

3. src/content.config.ts — register sibling collections so Astro's content layer picks up translations. Locale set is auto-derived from astro.config.mjs.

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 — pick up types for PolyStella's virtual modules:

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

Catalog-Only Usage

Projects that already handle localized content and routing can adopt only PolyStella's JSON catalog flow:

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

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

This binds Astro.locals.t and Astro.locals.lhref only. It does not run content translation, route shims, R2 cache setup, or localized collection APIs.

Documentation

Full documentation lives at the Nimbus docs site (under docs/ in this repo):

Contributing

Contributions are welcome, but PolyStella is maintained by a small team and review is not guaranteed. See CONTRIBUTING.md. The agent-facing context is in AGENTS.md and ARCHITECTURE.md.

License

MIT

版本与发布记录

@cloudflare/polystella 共发布 4 个版本,首次发布于 2026/06/05;过去 12 个月发布了 4 个版本。

版本发布日期距今
0.4.0latest2026/07/074 个月前
0.3.12026/07/054 个月前
0.2.12026/06/085 个月前
0.2.02026/06/055 个月前

关于 @cloudflare/polystella 的常见问题

@cloudflare/polystella 是什么?

AI-driven content localization for Astro (build-time markdown translation, 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。作者已将其标记为弃用,新项目建议寻找替代方案。