# General Translation Integrations: 配置 URL: https://generaltranslation.com/zh/docs/integrations/mintlify/reference/config.mdx --- title: 配置 description: General Translation 为 Mintlify 项目生成的 gt.config.json 参考文档。Mintlify 集成配置参考文档。 --- # 配置 General Translation 会在设置过程中为你的 Mintlify 项目生成一个 `gt.config.json`,无需你手动编写。本页说明该文件包含的内容,方便你在用于设置的 pull request 合并后进行检查或微调。 该配置是标准的 General Translation CLI 配置。所有通用键都已在 [CLI 配置参考](/docs/cli/reference/config) 中统一说明;本页只介绍 Mintlify 特有的配置选项,以及该集成生成的两种模式。 ## 模式 [#modes] 生成的配置取决于 **在 URL 路径中隐藏默认区域设置** 设置 (参见[配置 Mintlify](/docs/integrations/mintlify/guides/configuring-mintlify)) 。两种模式都会翻译 `docs.json` 和每个 `.mdx`/`.md` 页面;区别在于文件布局以及默认区域设置的访问方式。 | 键 | 说明 | 隐藏默认区域设置 | 显示默认区域设置 | | --------------------------------------------------- | ---------------------- | ----------------------------------------------------------- | ------------------------------------------------------------------- | | [`files.mdx.include`](#files) | 要翻译的页面的 Glob 模式。 | `./**/*.mdx`, `./**/*.md` (原地翻译) | `./[locale]/**/*.mdx`、`./snippets/[locale]/**/*.mdx` 以及对应的 `.md` 文件 | | [`files.mdx.transform`](#files) | 将源路径重写到区域设置文件夹中。 | `{ match: "^(snippets/)?(.*)$", replace: "$1{locale}/$2" }` | *(无)* | | [`options.jsonSchema`](#options) | 用于本地化 `docs.json` 的预设。 | `mintlify-hide-default` | `mintlify` | | [`options.docsHideDefaultLocaleImport`](#options) | 在导入路径中隐藏默认区域设置。 | `true` | *(省略)* | | [`options.experimentalHideDefaultLocale`](#options) | 默认区域设置的访问不带区域设置前缀。 | `true` | *(省略)* | ## 文件 [#files] `files` 块用于告诉 General Translation CLI 需要翻译哪些内容。对于 Mintlify 项目,它始终包含 `docs.json` 和文档页面。 * `files.json.include` — 始终为 `['./docs.json']`。`docs.json` 中的导航和 labels 会通过 `options.jsonSchema` 中的预设进行本地化。 * `files.mdx.include` — 要翻译的 `.mdx` 和 `.md` 页面。在 hide-default-locale 模式下,这里包含整个目录树 (`./**/*.mdx`, `./**/*.md`) ,文件会通过 transform 移动到区域设置文件夹中;在 show-default-locale 模式下,它则以现有的各区域设置文件夹为目标。 * `files.mdx.transform` — 在 hide-default-locale 模式下,将每个 source 路径重写到 `{locale}/` 文件夹中 (保留开头的 `snippets/` prefix 不变) 。show-default-locale 模式下会省略 transform,因为内容已经位于区域设置文件夹中。 * `files.mdx.exclude` — 区域设置文件夹本身,以及绝不应翻译的常见仓库文件 (参见[支持的内容](/docs/integrations/mintlify/reference/supported-content#excluded)) 。 有关 `files`、`include`、`exclude` 和 `transform` 的完整语义,请参阅 [CLI 配置参考](/docs/cli/reference/config);有关各格式的具体行为,请参阅 [MDX 和 Markdown 格式页面](/docs/cli/reference/formats/mdx-md-files) 和 [JSON 格式页面](/docs/cli/reference/formats/json-files)。 ## 选项 [#options] `options` 块用于配置 Mintlify 的特定行为。除非特别注明仅适用于某种模式,否则这些键会为每个 Mintlify 项目设置。 * `mintlify.inferTitleFromFilename` — `true`。当页面没有显式指定标题时,根据文件名推导页面标题。 * `jsonSchema` — 将 `./docs.json` 映射到一个预设,该预设知道如何本地化 Mintlify 导航:隐藏默认区域设置时使用 `mintlify-hide-default`,否则使用 `mintlify`。 * `docsUrlPattern` — `/[locale]`。用于本地化文档 URL 的模式。 * `docsImportPattern` — `/snippets/[locale]`。用于本地化代码片段导入的模式。 * `generateRedirects` — `./docs.json`。在 `docs.json` 中生成重定向,这样在重构导航后,现有链接仍可继续解析。 * `experimentalLocalizeStaticImports` — `true`。本地化静态导入路径 (例如代码片段) 。 * `experimentalLocalizeStaticUrls` — `true`。本地化内部静态 URL,使链接始终保留在读者当前语言下。 * `experimentalLocalizeRelativeAssets` — `true`。本地化相对资源引用。 * `experimentalAddHeaderAnchorIds` — `'mintlify'`。添加稳定的标题锚点 ID,以便页内链接在不同语言版本中仍能正常工作。 * `docsHideDefaultLocaleImport` — `true` *(仅适用于 hide-default-locale 模式)*。在生成的导入中隐藏默认区域设置。 * `experimentalHideDefaultLocale` — `true` *(仅适用于 hide-default-locale 模式)*。默认区域设置在提供时不带区域设置前缀。 ## 示例 [#example] 为隐藏默认区域设置的项目生成的配置如下 (源语言为英语,目标语言为西班牙语和法语) : ```json title="gt.config.json" { "$schema": "https://assets.gtx.dev/config-schema.json", "files": { "json": { "include": ["./docs.json"] }, "mdx": { "include": ["./**/*.mdx", "./**/*.md"], "transform": { "match": "^(snippets/)?(.*)$", "replace": "$1{locale}/$2" }, "exclude": [ "./[locales]/**/*.mdx", "./snippets/[locales]/**/*.mdx", "./[locales]/**/*.md", "./snippets/[locales]/**/*.md" // 以及仓库文件,例如 README.md、LICENSE.md、CHANGELOG.md ] } }, "defaultLocale": "en", "locales": ["es", "fr"], "options": { "mintlify": { "inferTitleFromFilename": true }, "jsonSchema": { "./docs.json": { "preset": "mintlify-hide-default" } }, "docsUrlPattern": "/[locale]", "docsImportPattern": "/snippets/[locale]", "generateRedirects": "./docs.json", "experimentalLocalizeStaticImports": true, "experimentalLocalizeStaticUrls": true, "experimentalLocalizeRelativeAssets": true, "docsHideDefaultLocaleImport": true, "experimentalHideDefaultLocale": true, "experimentalAddHeaderAnchorIds": "mintlify" } } ``` *注意:完成 setup 后,CLI 会将 `[locales]` 这个排除占位符解析为你的实际目标区域设置。请检查生成的 `gt.config.json`;如果你的代码仓库将可翻译内容保存在某个被排除的路径下,请调整排除的文件。*