# General Translation Changelog: gt 2.11.0: 将任意文件类型发布到 CDN
URL: https://generaltranslation.com/zh/blog/gt-cli_v2_11_0.mdx
Docs index: https://generaltranslation.com/llms.txt
Description: 
Authors: Fernando Aviles
Published: 2026-03-18

## 概述

GT CLI 现在可以将**任意翻译后的文件类型**发布到 GT CDN。JSON、MDX、YAML 以及所有其他[受支持的文件类型](/docs/cli/reference/formats/gt-jsx-files)，现在都可以直接通过 [`translate`](/docs/cli/reference/commands/translate)、[`upload`](/docs/cli/reference/commands/upload) 和 [`save-local`](/docs/cli/reference/commands/save-local) 命令发布。

## 配置

### 全局发布标志

为任何受支持的命令添加 `--publish`：

```bash
npx gt translate --publish
```

或者在 `gt.config.json` 中设置：

```json title="gt.config.json"
{
  "publish": true
}
```

这会将**所有**翻译后的文件 (包括 GT JSON) 发布到 CDN。

### 按文件控制发布

你可以使用 `include` 模式语法，单独控制某个文件是否发布。不要再使用普通的 glob 字符串，而要改用带有 `publish` 标志的对象：

```json title="gt.config.json"
{
  "defaultLocale": "en",
  "locales": ["fr", "es"],
  "files": {
    "json": {
      "include": [
        { "pattern": "locales/[locale]/*.json", "publish": true },
        { "pattern": "locales/[locale]/internal/**/*.json", "publish": false }
      ]
    }
  }
}
```

在此示例中，`locales/[locale]/` 下的所有 JSON 文件都会发布到 CDN，`internal/` 子目录下的文件除外。


### GT JSON 发布控制

GT 的内部格式在 `gt` 键下也有自己的发布标志：

```json title="gt.config.json"
{
  "files": {
    "gt": {
      "output": "public/i18n/[locale].json",
      "publish": true
    }
  }
}
```


### 判定顺序

对于任意文件，CLI 会按以下顺序判定是否发布：

1. **显式禁用** — 文件匹配某个 `include` 条目，且 `"publish": false` → 不发布，或从 CDN 中移除
2. **显式启用** — 文件匹配某个 `include` 条目，且 `"publish": true` → 发布到 CDN
3. **全局回退** — 使用顶层 `publish` 设置 (未设置时默认为 `false`) 

如果任何层级都没有设置发布配置，则会完全跳过发布步骤——不会发起任何 API 调用。

## 支持发布的命令

| 命令                                                         | 行为                 |
| ---------------------------------------------------------- | ------------------ |
| [`gt translate`](/docs/cli/reference/commands/translate)   | 下载翻译后发布            |
| [`gt upload`](/docs/cli/reference/commands/upload)         | 上传源文件后发布           |
| [`gt save-local`](/docs/cli/reference/commands/save-local) | 保存 local edits 后发布 |

## 链接

* [CLI 配置参考](/docs/cli/reference/config)
* [PR #1122](https://github.com/generaltranslation/gt/pull/1122) — 初步支持文件发布
* [PR #1132](https://github.com/generaltranslation/gt/pull/1132) — 修复启用问题
* [PR #1133](https://github.com/generaltranslation/gt/pull/1133) — 在保存或执行 upload 时发布

## Sitemap

See the full [sitemap](https://generaltranslation.com/sitemap.md) for all pages.
