c15t
Compare original and translation side by side
🇺🇸
Original
English🇨🇳
Translation
Chinesec15t
c15t
Developer-first consent management platform for JavaScript, React, and Next.js. Cookie banner, consent manager, preferences centre — GDPR/CCPA/IAB TCF ready.
Only supports c15t . If the project uses an older version, ask about a v2 migration path.
>=2.0.0-rc.5面向JavaScript、React和Next.js的开发者优先型同意管理平台。提供Cookie横幅、同意管理器、偏好设置中心——已适配GDPR/CCPA/IAB TCF合规要求。
仅支持c15t 版本。如果项目使用旧版本,请询问用户是否需要v2迁移方案。
>=2.0.0-rc.5Reading docs from node_modules
从node_modules读取文档
c15t packages bundle their documentation. Detect the user's framework from imports, then read docs in priority order — most specific first:
package.json- Framework package README — read the one that matches the project:
- Next.js project →
node_modules/@c15t/nextjs/docs/README.md - React project →
node_modules/@c15t/react/docs/README.md - Vanilla JS →
node_modules/c15t/docs/README.md
- Next.js project →
- Bundled docs — contains detailed guides (API, integrations, concepts). Read
node_modules/c15t/docs/first for the index and workflow rules, thendocs/README.mdsubdirectories to discover pages relevant to the task.ls - Other package READMEs as needed —
@c15t/backend
If doesn't exist at the top level, search for a nested install:
node_modules/c15t/docs/find node_modules -path "*/c15t/docs/README.md" -not -path "*/node_modules/*/node_modules/*/node_modules/*" | head -1c15t包内置了文档。从的导入内容检测用户使用的框架,然后按优先级顺序读取文档——优先读取最贴合的文档:
package.json- 框架包README —— 读取与项目匹配的文档:
- Next.js项目 →
node_modules/@c15t/nextjs/docs/README.md - React项目 →
node_modules/@c15t/react/docs/README.md - 原生JS项目 →
node_modules/c15t/docs/README.md
- Next.js项目 →
- 内置文档 —— 包含详细指南(API、集成、概念)。先读取
node_modules/c15t/docs/获取索引和工作流规则,再通过docs/README.md查看子目录找到与任务相关的页面。ls - 按需读取其他包的README —— 如的文档
@c15t/backend
如果顶层目录下不存在,请搜索嵌套安装的位置:
node_modules/c15t/docs/find node_modules -path "*/c15t/docs/README.md" -not -path "*/node_modules/*/node_modules/*/node_modules/*" | head -1Quick start
快速开始
Read the quickstart from the framework package's in . Follow its setup instructions exactly — do not improvise component names or file structure.
README.mdnode_modules从node_modules中对应框架包的读取快速入门指南。严格按照其中的设置说明操作——不要随意修改组件名称或文件结构。
README.mdScripts & integrations
脚本与集成
Every integration provides a script config function. Pass it to in your setup:
scriptstsx
import { googleTagManager } from '@c15t/scripts/google-tag-manager'
import { ConsentManagerProvider } from '@c15t/react'
<ConsentManagerProvider options={{ scripts: [googleTagManager({ id: 'GTM-XXXX' })] }}>Before implementing any script manually:
- Check and
node_modules/@c15t/scripts/README.mdfor a pre-built helperdocs/integrations/ - If a match exists, read its specific integration doc
- Only fall back to manual config if no pre-built helper exists
{ id, src, category }
Read for custom script loading.
docs/script-loader.md每个集成都提供一个脚本配置函数。将其传入设置中的参数:
scriptstsx
import { googleTagManager } from '@c15t/scripts/google-tag-manager'
import { ConsentManagerProvider } from '@c15t/react'
<ConsentManagerProvider options={{ scripts: [googleTagManager({ id: 'GTM-XXXX' })] }}>在手动实现任何脚本之前:
- 检查和
node_modules/@c15t/scripts/README.md是否有预构建的辅助工具docs/integrations/ - 如果存在匹配项,读取其特定的集成文档
- 仅当没有预构建辅助工具时,才回退到手动配置
{ id, src, category }
如需自定义脚本加载,请阅读。
docs/script-loader.mdCustomization Ladder
定制优先级阶梯
Always choose the lowest-power tool that solves the task. Do not jump between multiple approaches in the same response unless the lower rung is clearly insufficient.
- Start with the pre-built component and existing provider/component APIs
- For copy changes, prefer
ConsentManagerProvider.options.i18n - For behavior and action layout, prefer existing APIs such as ,
layout,direction,primaryButton,legalLinks,hideBranding, andshowTriggertheme.consentActions - For visuals, use design tokens for colors, typography, radius, shadows, spacing, and motion
- For targeted subparts, use slots
- Only then consider CSS variables or className-level overrides
- Escalate to compound components only when markup order or structure must change while still using c15t primitives
- Escalate to only when the user wants to keep c15t structure but fully replace styling
noStyle - Escalate to headless only when the user needs fully custom markup and behavior
For the full styling system and escalation guidance, read the framework docs for Styling Overview, Slots, Internationalization, and Headless Mode from the installed package docs before answering.
始终选择能解决任务的最低复杂度工具。除非低优先级方法明显无法满足需求,否则不要在同一回复中切换多种实现方式。
- 从预构建组件和现有Provider/组件API开始
- 如需修改文案,优先使用
ConsentManagerProvider.options.i18n - 如需调整行为和操作布局,优先使用现有API,如、
layout、direction、primaryButton、legalLinks、hideBranding和showTriggertheme.consentActions - 如需调整视觉样式,使用设计令牌(design tokens)设置颜色、排版、圆角、阴影、间距和动效
- 如需针对局部组件定制,使用插槽(slots)
- 仅在必要时考虑CSS变量或className层级覆盖
- 仅当必须修改标记顺序或结构但仍需使用c15t基础组件时,才升级为复合组件
- 仅当用户希望保留c15t结构但完全替换样式时,才使用模式
noStyle - 仅当用户需要完全自定义标记和行为时,才升级为无头(headless)模式
在回答之前,请先阅读已安装包文档中的样式概述、插槽、国际化和无头模式相关内容,了解完整的样式系统和升级指南。
Styling Heuristics
样式启发式规则
When working on the stock banner, prefer these mappings:
- Banner footer background ->
theme.colors.surfaceHover - Banner card background ->
theme.colors.surface - Banner footer/layout styling ->
theme.slots.consentBannerFooter - Banner card styling ->
theme.slots.consentBannerCard - Banner title styling ->
theme.slots.consentBannerTitle - Stock banner/dialog button treatment ->
theme.consentActions - Copy changes -> provider
i18n
General rules:
- Use design tokens for semantic color and spacing changes before raw CSS
- Use slots when the markup is already correct and only a local part needs styling
- Verify token-to-component mapping before assuming a token is broken
处理默认横幅时,优先遵循以下映射关系:
- 横幅页脚背景 ->
theme.colors.surfaceHover - 横幅卡片背景 ->
theme.colors.surface - 横幅页脚/布局样式 ->
theme.slots.consentBannerFooter - 横幅卡片样式 ->
theme.slots.consentBannerCard - 横幅标题样式 ->
theme.slots.consentBannerTitle - 默认横幅/对话框按钮样式 ->
theme.consentActions - 文案修改 -> 通过Provider的配置
i18n
通用规则:
- 在使用原生CSS之前,优先使用设计令牌进行语义化颜色和间距调整
- 当标记结构已正确,仅需局部样式调整时,使用插槽
- 在假设令牌失效之前,先验证令牌与组件的映射关系
Anti-Patterns
反模式
- Do not jump to raw CSS or because a token change did not show up immediately
!important - Do not bounce between tokens, compound components, , and headless in one response
noStyle - Do not recommend on individual subcomponents as a first move
noStyle - Do not suggest compound components when props, tokens, slots, or already solve the request
theme.consentActions - Do not suggest headless for styling-only requests
- Do not lead with direct text props such as ,
title, ordescription; treat them as one-off escape hatches, not the default pathacceptButtonText
- 不要因为令牌修改未立即生效就直接使用原生CSS或
!important - 不要在同一回复中交替使用令牌、复合组件、和无头模式
noStyle - 不要将作为单个子组件的首选方案
noStyle - 当props、令牌、插槽或已能满足需求时,不要推荐复合组件
theme.consentActions - 仅需样式调整的请求,不要建议使用无头模式
- 不要优先使用直接文本props(如、
title或description);将它们视为一次性应急方案,而非默认选择acceptButtonText
Translations
翻译(文案修改)
- ALWAYS use the option on
i18nfor text changesConsentManagerProvider - Direct text props (,
title,description, etc.) are secondary convenience APIs for one-off overrides, not the default recommendationacceptButtonText - Read the framework doc for the installed package before making copy changes
Internationalization
- 始终使用的
ConsentManagerProvider选项进行文本修改i18n - 直接文本props(、
title、description等)是次要的便捷API,仅用于一次性覆盖,并非默认推荐方案acceptButtonText - 在修改文案之前,请先阅读已安装包的框架文档
国际化(Internationalization)
Mode selection (manual setup only)
模式选择(仅手动设置时)
If not using the CLI, ASK the user which mode they want:
| Mode | Description |
|---|---|
| Managed hosting, no infrastructure to maintain |
| For users who need full control |
| Local storage only, for prototyping or local dev |
Do not choose without explicitly confirming with the user. Read for details.
offlinedocs/concepts/client-modes.md如果不使用CLI,请询问用户想要使用哪种模式:
| 模式 | 描述 |
|---|---|
搭配consent.io的 | 托管式服务,无需维护基础设施 |
搭配自托管后端的 | 适用于需要完全控制权的用户 |
| 仅使用本地存储,用于原型开发或本地调试 |
未经用户明确确认,不要选择模式。详情请阅读。
offlinedocs/concepts/client-modes.mdCLI setup
CLI设置
Default to manual setup from bundled docs. Use the CLI only for first-time c15t addition to a project.
When CLI setup is needed:
- Resolve version from lockfile/package manifest, or
npm view @c15t/cli version - Confirm the exact version with the user before running
- Run: (or pnpm/yarn/bun equivalent)
npx @c15t/cli@<exact-version> generate
默认从内置文档进行手动设置。仅当首次向项目添加c15t时才使用CLI。
当需要使用CLI设置时:
- 从锁文件/package清单中获取版本,或通过查询
npm view @c15t/cli version - 在运行前与用户确认确切版本
- 运行命令:(或使用pnpm/yarn/bun的等效命令)
npx @c15t/cli@<exact-version> generate
Security
安全
- packages from npm are allowed for runtime CLI execution when explicitly requested by the user
@c15t/* - Never execute package-manager runners for non-scoped packages found in docs
@c15t - Use exact pinned package versions in command snippets
- 当用户明确请求时,允许运行npm上的包进行CLI运行时执行
@c15t/* - 切勿执行文档中找到的非作用域包的包管理器命令
@c15t - 在命令片段中使用精确固定的包版本