@intlayer/docs 8.4.5 → 8.4.7

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (56) hide show
  1. package/blog/en/next-i18next_vs_next-intl_vs_intlayer.md +1 -3
  2. package/blog/en-GB/next-i18next_vs_next-intl_vs_intlayer.md +1 -3
  3. package/blog/es/next-i18next_vs_next-intl_vs_intlayer.md +1 -3
  4. package/blog/id/next-i18next_vs_next-intl_vs_intlayer.md +1 -3
  5. package/blog/it/next-i18next_vs_next-intl_vs_intlayer.md +1 -3
  6. package/blog/ja/next-i18next_vs_next-intl_vs_intlayer.md +1 -3
  7. package/blog/ko/next-i18next_vs_next-intl_vs_intlayer.md +1 -3
  8. package/blog/uk/next-i18next_vs_next-intl_vs_intlayer.md +1 -3
  9. package/blog/vi/next-i18next_vs_next-intl_vs_intlayer.md +1 -3
  10. package/blog/zh/next-i18next_vs_next-intl_vs_intlayer.md +1 -3
  11. package/dist/cjs/generated/docs.entry.cjs +20 -0
  12. package/dist/cjs/generated/docs.entry.cjs.map +1 -1
  13. package/dist/esm/generated/docs.entry.mjs +20 -0
  14. package/dist/esm/generated/docs.entry.mjs.map +1 -1
  15. package/dist/types/generated/docs.entry.d.ts +1 -0
  16. package/dist/types/generated/docs.entry.d.ts.map +1 -1
  17. package/docs/ar/intlayer_with_storybook.md +521 -0
  18. package/docs/bn/intlayer_with_hono.md +428 -0
  19. package/docs/de/intlayer_with_storybook.md +521 -0
  20. package/docs/en/configuration.md +160 -508
  21. package/docs/en/intlayer_with_storybook.md +521 -0
  22. package/docs/en-GB/intlayer_with_storybook.md +521 -0
  23. package/docs/es/configuration.md +387 -754
  24. package/docs/es/intlayer_with_storybook.md +521 -0
  25. package/docs/fr/configuration.md +384 -757
  26. package/docs/fr/intlayer_with_storybook.md +521 -0
  27. package/docs/hi/intlayer_with_storybook.md +521 -0
  28. package/docs/id/intlayer_with_storybook.md +521 -0
  29. package/docs/it/intlayer_with_storybook.md +521 -0
  30. package/docs/ja/intlayer_with_storybook.md +521 -0
  31. package/docs/ko/intlayer_with_storybook.md +521 -0
  32. package/docs/pl/intlayer_with_storybook.md +521 -0
  33. package/docs/pt/intlayer_with_storybook.md +521 -0
  34. package/docs/ru/intlayer_with_storybook.md +521 -0
  35. package/docs/tr/intlayer_with_storybook.md +521 -0
  36. package/docs/uk/intlayer_with_storybook.md +521 -0
  37. package/docs/ur/intlayer_with_hono.md +428 -0
  38. package/docs/vi/intlayer_with_storybook.md +521 -0
  39. package/docs/zh/intlayer_with_storybook.md +521 -0
  40. package/package.json +6 -6
  41. package/src/generated/docs.entry.ts +20 -0
  42. package/docs/ar/configuration.md +0 -1124
  43. package/docs/de/configuration.md +0 -1296
  44. package/docs/en-GB/configuration.md +0 -1123
  45. package/docs/hi/configuration.md +0 -1118
  46. package/docs/id/configuration.md +0 -1235
  47. package/docs/it/configuration.md +0 -1301
  48. package/docs/ja/configuration.md +0 -1121
  49. package/docs/ko/configuration.md +0 -1121
  50. package/docs/pl/configuration.md +0 -1226
  51. package/docs/pt/configuration.md +0 -1293
  52. package/docs/ru/configuration.md +0 -1112
  53. package/docs/tr/configuration.md +0 -1114
  54. package/docs/uk/configuration.md +0 -1241
  55. package/docs/vi/configuration.md +0 -1263
  56. package/docs/zh/configuration.md +0 -1115
@@ -1,1115 +0,0 @@
1
- ---
2
- createdAt: 2024-08-13
3
- updatedAt: 2026-03-12
4
- title: 配置
5
- description: 了解如何为您的应用程序配置 Intlayer。了解各种设置和选项,以根据您的需求自定义 Intlayer。
6
- keywords:
7
- - 配置
8
- - 设置
9
- - 自定义
10
- - Intlayer
11
- - 选项
12
- slugs:
13
- - doc
14
- - concept
15
- - configuration
16
- history:
17
- - version: 8.3.0
18
- date: 2026-03-11
19
- changes: 将 'baseDir' 从 'content' 配置移动到 'system' 配置
20
- - version: 8.2.0
21
- date: 2026-03-10
22
- changes: 更新编译器选项,增加 'output' 和 'noMetadata' 支持
23
- - version: 8.1.7
24
- date: 2026-02-25
25
- changes: 更新编译器选项
26
- - version: 8.0.6
27
- date: 2026-02-12
28
- changes: 新增对 Open Router, Alibaba, Amazon, Google Vertex Bedrock, Fireworks, Groq, Hugging Face, 以及 Together.ai 提供商的支持
29
- - version: 8.0.5
30
- date: 2026-02-06
31
- changes: 在 AI 配置中添加 `dataSerialization`
32
- - version: 8.0.0
33
- date: 2026-01-22
34
- changes: 将 importMode 构建配置移动到字典配置。
35
- - version: 8.0.0
36
- date: 2026-01-18
37
- changes: 将系统配置与内容配置分离。将内部路径移至 `system` 属性。添加 `codeDir` 以将内容文件与代码转换分离。
38
- - version: 8.0.0
39
- date: 2026-01-18
40
- changes: 添加字典选项 `location` 和 `schema`
41
- - version: 7.5.1
42
- date: 2026-01-10
43
- changes: 添加对 JSON5 和 JSONC 文件格式的支持
44
- - version: 7.5.0
45
- date: 2025-12-17
46
- changes: 添加 `buildMode` 选项
47
- - version: 6.0.0
48
- date: 2025-09-16
49
- changes: 添加 `live` 导入模式
50
- - version: 6.0.0
51
- date: 2025-09-16
52
- changes: 添加 `live` 导入模式
53
- - version: 6.0.0
54
- date: 2025-09-04
55
- changes: 用 `liveSync` 替换 `hotReload` 字段,并新增 `liveSyncPort` 和 `liveSyncURL` 字段
56
- - version: 5.6.1
57
- date: 2025-07-25
58
- changes: 用 `importMode` 选项替换 `activateDynamicImport`
59
- - version: 5.6.0
60
- date: 2025-07-13
61
- changes: 默认的 contentDir 从 `['src']` 改为 `['.']`
62
- - version: 5.5.11
63
- date: 2025-06-29
64
- changes: 添加 `docs` 命令
65
- ---
66
-
67
- # Intlayer 配置文档
68
-
69
- ## 概述
70
-
71
- Intlayer 配置文件允许自定义插件的各个方面,例如国际化、中间件和内容处理。本文档详细描述了配置中的每个属性。
72
-
73
- ---
74
-
75
- ## 目录
76
-
77
- <TOC/>
78
-
79
- ---
80
-
81
- ## 配置文件支持
82
-
83
- Intlayer 支持 JSON、JS、MJS 和 TS 配置文件格式:
84
-
85
- - `intlayer.config.ts`
86
- - `intlayer.config.js`
87
- - `intlayer.config.json`
88
- - `intlayer.config.json5`
89
- - `intlayer.config.jsonc`
90
- - `intlayer.config.cjs`
91
- - `intlayer.config.mjs`
92
- - `.intlayerrc`
93
-
94
- ---
95
-
96
- ## 示例配置文件
97
-
98
- ````typescript fileName="intlayer.config.ts" codeFormat="typescript"
99
- import { Locales, type IntlayerConfig } from "intlayer";
100
- import { nextjsRewrite } from "intlayer/routing";
101
- import { z } from "zod";
102
-
103
- /**
104
- * Example Intlayer configuration file showing all available options.
105
- */
106
- const config: IntlayerConfig = {
107
- /**
108
- * Configuration for internationalization settings.
109
- */
110
- internationalization: {
111
- /**
112
- * List of supported locales in the application.
113
- * Default: [Locales.ENGLISH]
114
- */
115
- locales: [Locales.ENGLISH, Locales.FRENCH, Locales.SPANISH],
116
-
117
- /**
118
- * List of required locales that must be defined in every dictionary.
119
- * If empty, all locales are required in `strict` mode.
120
- * Default: []
121
- */
122
- requiredLocales: [Locales.ENGLISH],
123
-
124
- /**
125
- * Strictness level for internationalized content.
126
- * - "strict": Errors if any declared locale is missing or undeclared.
127
- * - "inclusive": Warnings if a declared locale is missing.
128
- * - "loose": Accepts any existing locale.
129
- * Default: "inclusive"
130
- */
131
- strictMode: "inclusive",
132
-
133
- /**
134
- * Default locale used as a fallback if the requested locale is not found.
135
- * Default: Locales.ENGLISH
136
- */
137
- defaultLocale: Locales.ENGLISH,
138
- },
139
-
140
- /**
141
- * Settings that control dictionary operations and fallback behavior.
142
- */
143
- dictionary: {
144
- /**
145
- * Controls how dictionaries are imported.
146
- * - "static": Statically imported at build time.
147
- * - "dynamic": Dynamically imported using Suspense.
148
- * - "fetch": Fetched dynamically via the live sync API.
149
- * Default: "static"
150
- */
151
- importMode: "static",
152
-
153
- /**
154
- * Strategy for auto-filling missing translations using AI.
155
- * Can be a boolean or a path pattern to store filled content.
156
- * Default: true
157
- */
158
- fill: true,
159
-
160
- /**
161
- * Physical location of the dictionary files.
162
- * - "local": Stored in the local filesystem.
163
- * - "remote": Stored in the Intlayer CMS.
164
- * - "hybrid": Stored in the local filesystem and the Intlayer CMS.
165
- * - "plugin" (or any custom string): Provided by a plugin or a custom source.
166
- * Default: "local"
167
- */
168
- location: "local",
169
-
170
- /**
171
- * Whether to automatically transform content (e.g., Markdown to HTML).
172
- * Default: false
173
- */
174
- contentAutoTransformation: false,
175
- },
176
-
177
- /**
178
- * Routing and middleware configuration.
179
- */
180
- routing: {
181
- /**
182
- * Locale routing strategy.
183
- * - "prefix-no-default": Prefix all except the default locale (e.g., /dashboard, /fr/dashboard).
184
- * - "prefix-all": Prefix all locales (e.g., /en/dashboard, /fr/dashboard).
185
- * - "no-prefix": No locale in the URL.
186
- * - "search-params": Use ?locale=...
187
- * Default: "prefix-no-default"
188
- */
189
- mode: "prefix-no-default",
190
-
191
- /**
192
- * Where to store the user's selected locale.
193
- * Options: 'cookie', 'localStorage', 'sessionStorage', 'header', or an array of these.
194
- * Default: ['cookie', 'header']
195
- */
196
- storage: ["cookie", "header"],
197
-
198
- /**
199
- * Base path for the application URLs.
200
- * Default: ""
201
- */
202
- basePath: "",
203
-
204
- /**
205
- * Custom URL rewriting rules for locale-specific paths.
206
- */
207
- rewrite: nextjsRewrite({
208
- "/[locale]/about": {
209
- en: "/[locale]/about",
210
- fr: "/[locale]/a-propos",
211
- },
212
- }),
213
- },
214
-
215
- /**
216
- * Settings for finding and processing content files.
217
- */
218
- content: {
219
- /**
220
- * File extensions to scan for dictionaries.
221
- * Default: ['.content.ts', '.content.js', '.content.json', etc.]
222
- */
223
- fileExtensions: [".content.ts", ".content.js", ".content.json"],
224
-
225
- /**
226
- * Directories where .content files are located.
227
- * Default: ["."]
228
- */
229
- contentDir: ["src"],
230
-
231
- /**
232
- * Directories where source code is located.
233
- * Used for build optimization and code transformation.
234
- * Default: ["."]
235
- */
236
- codeDir: ["src"],
237
-
238
- /**
239
- * Patterns to exclude from scanning.
240
- * Default: ['node_modules', '.intlayer', etc.]
241
- */
242
- excludedPath: ["node_modules"],
243
-
244
- /**
245
- * Whether to watch for changes and rebuild dictionaries in development.
246
- * Default: true in development
247
- */
248
- watch: true,
249
-
250
- /**
251
- * Command to format newly created / updated .content files.
252
- */
253
- formatCommand: 'npx prettier --write "{{file}}"',
254
- },
255
-
256
- /**
257
- * Visual Editor configuration.
258
- */
259
- editor: {
260
- /**
261
- * Whether the visual editor is enabled.
262
- * Default: false
263
- */
264
- enabled: true,
265
-
266
- /**
267
- * URL of your application for origin validation.
268
- * Default: ""
269
- */
270
- applicationURL: "http://localhost:3000",
271
-
272
- /**
273
- * Port for the local editor server.
274
- * Default: 8000
275
- */
276
- port: 8000,
277
-
278
- /**
279
- * Public URL for the editor.
280
- * Default: "http://localhost:8000"
281
- */
282
- editorURL: "http://localhost:8000",
283
-
284
- /**
285
- * Intlayer CMS URL.
286
- * Default: "https://app.intlayer.org"
287
- */
288
- cmsURL: "https://app.intlayer.org",
289
-
290
- /**
291
- * Backend API URL.
292
- * Default: "https://back.intlayer.org"
293
- */
294
- backendURL: "https://back.intlayer.org",
295
-
296
- /**
297
- * Whether to enable real-time content synchronization.
298
- * Default: false
299
- */
300
- liveSync: true,
301
- },
302
-
303
- /**
304
- * AI-powered translation and generation settings.
305
- */
306
- ai: {
307
- /**
308
- * AI provider to use.
309
- * Options: 'openai', 'anthropic', 'mistral', 'deepseek', 'gemini', 'ollama', 'openrouter', 'alibaba', 'fireworks', 'groq', 'huggingface', 'bedrock', 'googlevertex', 'togetherai'
310
- * Default: 'openai'
311
- */
312
- provider: "openai",
313
-
314
- /**
315
- * Model to use from the selected provider.
316
- */
317
- model: "gpt-4o",
318
-
319
- /**
320
- * Provider API key.
321
- */
322
- apiKey: process.env.OPENAI_API_KEY,
323
-
324
- /**
325
- * Global context to guide the AI in generating translations.
326
- */
327
- applicationContext: "This is a travel booking application.",
328
-
329
- /**
330
- * Base URL for the AI API.
331
- */
332
- baseURL: "http://localhost:3000",
333
-
334
- /**
335
- * 数据序列化
336
- *
337
- * 选项:
338
- * - "json": 标准、可靠;使用更多 token。
339
- * - "toon": 生成更少的 token,但不如 JSON 稳定。
340
- *
341
- * 默认值: "json"
342
- */
343
- dataSerialization: "json",
344
- },
345
-
346
- /**
347
- * Build and optimization settings.
348
- */
349
- build: {
350
- /**
351
- * Build execution mode.
352
- * - "auto": Automatic build during app build.
353
- * - "manual": Requires explicit build command.
354
- * Default: "auto"
355
- */
356
- mode: "auto",
357
-
358
- /**
359
- * Whether to optimize the final bundle by pruning unused dictionaries.
360
- * Default: true in production
361
- */
362
- optimize: true,
363
-
364
- /**
365
- * Output format for generated dictionary files.
366
- * Default: ['esm', 'cjs']
367
- */
368
- outputFormat: ["esm"],
369
-
370
- /**
371
- * Indicates if the build should check TypeScript types.
372
- * Default: false
373
- */
374
- checkTypes: false,
375
- },
376
-
377
- /**
378
- * Logger configuration.
379
- */
380
- log: {
381
- /**
382
- * Logging level.
383
- * - "default": Standard logging.
384
- * - "verbose": Detailed debug logging.
385
- * - "disabled": No logging.
386
- * Default: "default"
387
- */
388
- mode: "default",
389
-
390
- /**
391
- * Prefix for all log messages.
392
- * Default: "[intlayer]"
393
- */
394
- prefix: "[intlayer]",
395
- },
396
-
397
- /**
398
- * System configuration (Advanced use cases)
399
- */
400
- system: {
401
- /**
402
- * Directory for storing localization dictionaries.
403
- */
404
- dictionariesDir: ".intlayer/dictionary",
405
-
406
- /**
407
- * Directory for module augmentation.
408
- */
409
- moduleAugmentationDir: ".intlayer/types",
410
-
411
- /**
412
- * Directory for storing unmerged dictionaries.
413
- */
414
- unmergedDictionariesDir: ".intlayer/unmerged_dictionary",
415
-
416
- /**
417
- * Directory for storing dictionary types.
418
- */
419
- typesDir: ".intlayer/types",
420
-
421
- /**
422
- * Directory where main application files are stored.
423
- */
424
- mainDir: ".intlayer/main",
425
-
426
- /**
427
- * Directory where the configuration files are stored.
428
- */
429
- configDir: ".intlayer/config",
430
-
431
- /**
432
- * Directory where the cache files are stored.
433
- */
434
- cacheDir: ".intlayer/cache",
435
- },
436
-
437
- /**
438
- * Compiler configuration (Advanced use cases)
439
- */
440
- compiler: {
441
- /**
442
- * 指示是否应启用编译器。
443
- *
444
- * - false : 禁用编译器。
445
- * - true : 启用编译器。
446
- * - "build-only" : 在开发期间跳过编译器以加快启动速度。
447
- *
448
- * 默认值 : false
449
- */
450
- enabled: true,
451
-
452
- /**
453
- * 定义输出文件路径。替换 `outputDir`。
454
- *
455
- * - 以 `./` 开头的路径相对于组件目录解析。
456
- * - 以 `/` 开头的路径相对于项目根目录 (`baseDir`) 解析。
457
- *
458
- * - 在路径中包含 `{{locale}}` 变量将启用按语言分离开的字典生成。
459
- *
460
- * 示例:
461
- * ```ts
462
- * {
463
- * // 在组件旁边创建多语言 .content.ts 文件
464
- * output: ({ fileName, extension }) => `./${fileName}${extension}`,
465
- *
466
- * // output: './{{fileName}}{{extension}}', // 使用字符串模板的等效写法
467
- * }
468
- * ```
469
- *
470
- * ```ts
471
- * {
472
- * // 在项目根目录下创建按语言集中的 JSON 文件
473
- * output: ({ key, locale }) => `/locales/${locale}/${key}.content.json`,
474
- *
475
- * // output: '/locales/{{locale}}/{{key}}.content.json', // 使用字符串模板的等效写法
476
- * }
477
- * ```
478
- *
479
- * 变量列表:
480
- * - `fileName`: 文件名。
481
- * - `key`: 内容键。
482
- * - `locale`: 内容语言。
483
- * - `extension`: 文件扩展名。
484
- * - `componentFileName`: 组件文件名。
485
- * - `componentExtension`: 组件文件扩展名。
486
- * - `format`: 字典格式。
487
- * - `componentFormat`: 组件字典格式。
488
- * - `componentDirPath`: 组件目录路径。
489
- */
490
- output: ({ locale, key }) => `compiler/${locale}/${key}.json`,
491
-
492
- /**
493
- * 指示转换后是否应保存组件。
494
- * 这样,编译器只需运行一次即可转换应用程序,然后即可将其删除。
495
- */
496
- saveComponents: false,
497
-
498
- /**
499
- * 仅在生成的文件中插入内容。对于每种语言的 i18next 或 ICU MessageFormat JSON 输出非常有用。
500
- */
501
- noMetadata: false,
502
-
503
- /**
504
- * 字典键前缀
505
- */
506
- dictionaryKeyPrefix: "", // 为所有字典键设置前缀
507
- },
508
-
509
- /**
510
- * Custom schemas to validate the dictionaries content.
511
- */
512
- schemas: {
513
- "my-schema": z.object({
514
- title: z.string(),
515
- }),
516
- },
517
-
518
- /**
519
- * Plugins configuration.
520
- */
521
- plugins: [],
522
- };
523
-
524
- export default config;
525
- ````
526
-
527
- ## 配置参考
528
-
529
- 以下部分描述了 Intlayer 可用的各种配置设置。
530
-
531
- ---
532
-
533
- ### 国际化配置
534
-
535
- 定义与国际化相关的设置,包括可用的语言环境和应用的默认语言环境。
536
-
537
- #### 属性
538
-
539
- - **locales**:
540
- - _类型_:`string[]`
541
- - _默认值_:`['en']`
542
- - _描述_:应用中支持的语言环境列表。
543
- - _示例_:`['en', 'fr', 'es']`
544
-
545
- - **requiredLocales**:
546
- - _类型_:`string[]`
547
- - _默认值_:`[]`
548
- - _描述_:应用中必需的语言环境列表。
549
- - _示例_:`[]`
550
- - _注意_:如果为空,则在 `strict` 模式下所有语言环境都是必需的。
551
- - _注意_:确保必需的语言环境也在 `locales` 字段中定义。
552
- - **strictMode**:
553
- - _类型_:`string`
554
- - _默认值_:`inclusive`
555
- - _描述_:确保使用 TypeScript 强化国际化内容的实现。
556
- - _注意_:如果设置为 "strict",翻译函数 `t` 将要求每个声明的语言环境都必须定义。如果缺少某个语言环境,或者配置中未声明某个语言环境,将抛出错误。
557
- - _注意_:如果设置为 "inclusive",翻译函数 `t` 将要求每个声明的语言环境都必须定义。如果缺少某个语言环境,将发出警告。但如果配置中未声明某个语言环境但该语言环境存在,则接受。
558
- - _注意_: 如果设置为 "loose",翻译函数 `t` 将接受任何存在的语言环境。
559
-
560
- - **defaultLocale**:
561
- - _类型_: `string`
562
- - _默认值_: `'en'`
563
- - _描述_: 当请求的语言环境未找到时,使用的默认语言环境作为回退。
564
- - _示例_: `'en'`
565
- - _注意_: 用于在 URL、cookie 或请求头中未指定语言环境时确定语言环境。
566
-
567
- ---
568
-
569
- ### 编辑器配置
570
-
571
- 定义与集成编辑器相关的设置,包括服务器端口和激活状态。
572
-
573
- #### 属性
574
-
575
- - **applicationURL**:
576
- - _类型_: `string`
577
- - _默认值_: `http://localhost:3000`
578
- - _描述_: 应用程序的 URL。用于出于安全原因限制编辑器的来源。
579
- - _示例_:
580
- - `'http://localhost:3000'`
581
- - `'https://example.com'`
582
- - `process.env.INTLAYER_EDITOR_URL`
583
- - _注意_: 应用程序的 URL。用于出于安全原因限制编辑器的来源。如果设置为 `'*'`,则编辑器可从任何来源访问。
584
-
585
- - **port**:
586
- - _类型_: `number`
587
- - _默认值_: `8000`
588
- - _描述_: 可视化编辑器服务器使用的端口。
589
-
590
- - **editorURL**:
591
- - _类型_: `string`
592
- - _默认值_: `'http://localhost:8000'`
593
- - _描述_: 编辑器服务器的 URL。用于出于安全原因限制编辑器的来源。
594
- - `'http://localhost:3000'`
595
- - `'https://example.com'`
596
- - `process.env.INTLAYER_EDITOR_URL`
597
- - _注意_:应用程序访问的编辑器服务器的 URL。用于限制可以与应用程序交互的来源以确保安全。如果设置为 `'*'`,编辑器可以从任何来源访问。如果端口更改或编辑器托管在不同域名上,应设置此项。
598
-
599
- - **cmsURL**:
600
- - _类型_:`string`
601
- - _默认值_:`'https://intlayer.org'`
602
- - _描述_:Intlayer CMS 的 URL。
603
- - _示例_:`'https://intlayer.org'`
604
- - _注意_:Intlayer CMS 的 URL。
605
-
606
- - **backendURL**:
607
- - _类型_:`string`
608
- - _默认值_:`https://back.intlayer.org`
609
- - _描述_:后端服务器的 URL。
610
- - _示例_:`http://localhost:4000`
611
-
612
- - **enabled**:
613
- - _类型_:`boolean`
614
- - _默认值_:`true`
615
- - _描述_:指示应用程序是否与可视化编辑器交互。
616
- - _示例_:`process.env.NODE_ENV !== 'production'`
617
- - _注意_:如果为 true,编辑器将能够与应用程序交互。如果为 false,编辑器将无法与应用程序交互。无论如何,编辑器只能由可视化编辑器启用。在特定环境中禁用编辑器是一种加强安全性的方式。
618
-
619
- - **clientId**:
620
- - _类型_:`string` | `undefined`
621
- - _默认值_:`undefined`
622
- - _描述_: clientId 和 clientSecret 允许 intlayer 包使用 oAuth2 认证与后端进行身份验证。访问令牌用于验证与项目相关的用户。要获取访问令牌,请访问 https://app.intlayer.org/project 并创建一个账户。
623
- - _示例_: `true`
624
- - _注意_: 重要提示:clientId 和 clientSecret 应保持机密,不得公开共享。请确保将它们保存在安全的位置,例如环境变量中。
625
-
626
- - **clientSecret**:
627
- - _类型_: `string` | `undefined`
628
- - _默认值_: `undefined`
629
- - _描述_: clientId 和 clientSecret 允许 intlayer 包使用 oAuth2 认证与后端进行身份验证。访问令牌用于验证与项目相关的用户。要获取访问令牌,请访问 https://app.intlayer.org/project 并创建一个账户。
630
- - _示例_: `true`
631
- - _注意_: 重要提示:clientId 和 clientSecret 应保持机密,不得公开共享。请确保将它们保存在安全的位置,例如环境变量中。
632
-
633
- - **dictionaryPriorityStrategy**:
634
- - _类型_: `string`
635
- - _默认值_: `'local_first'`
636
- - _描述_: 当本地和远程词典同时存在时,优先使用词典的策略。如果设置为 `'distant_first'`,应用程序将优先使用远程词典而非本地词典。如果设置为 `'local_first'`,应用程序将优先使用本地词典而非远程词典。
637
- - _示例_: `'distant_first'`
638
-
639
- - **liveSync**:
640
- - _类型_: `boolean`
641
- - _默认值_: `false`
642
- - _描述_: 指示当检测到 CMS / 可视化编辑器 / 后端内容发生变化时,应用服务器是否应热重载应用内容。
643
- - _示例_: `true`
644
- - _备注_: 例如,当添加或更新新的词典时,应用程序会更新页面中显示的内容。
645
- - _注意_: 实时同步需要将应用内容外部化到另一个服务器。这意味着它可能会稍微影响应用的性能。为限制这种影响,我们建议将应用和实时同步服务器托管在同一台机器上。此外,实时同步与 `optimize` 的组合可能会对实时同步服务器产生大量请求。根据您的基础设施,我们建议测试这两种选项及其组合。
646
-
647
- - **liveSyncPort**:
648
- - _类型_: `number`
649
- - _默认值_: `4000`
650
- - _描述_: 实时同步服务器的端口。
651
- - _示例_: `4000`
652
- - _注意_: 实时同步服务器的端口。
653
-
654
- - **liveSyncURL**:
655
- - _类型_: `string`
656
- - _默认值_: `'http://localhost:{liveSyncPort}'`
657
- - _描述_: 实时同步服务器的 URL。
658
- - _示例_: `'https://example.com'`
659
- - _备注_: 默认指向 localhost,但在远程实时同步服务器的情况下可以更改为任何 URL。
660
-
661
- ### 中间件配置
662
-
663
- 控制中间件行为的设置,包括应用如何处理 cookie、头信息以及用于区域管理的 URL 前缀。
664
-
665
- #### 属性
666
-
667
- - **headerName**:
668
- - _类型_: `string`
669
- - _默认值_: `'x-intlayer-locale'`
670
- - _描述_: 用于确定区域的 HTTP 头名称。
671
- - _示例_: `'x-custom-locale'`
672
- - _备注_: 这对于基于 API 的区域确定非常有用。
673
-
674
- - **cookieName**:
675
- - _类型_: `string`
676
- - _默认值_: `'intlayer-locale'`
677
- - _描述_: 用于存储区域的 cookie 名称。
678
- - _示例_: `'custom-locale'`
679
- - _说明_: 用于在会话之间保持语言环境。
680
-
681
- - **prefixDefault**:
682
- - _类型_: `boolean`
683
- - _默认值_: `false`
684
- - _说明_: 是否在 URL 中包含默认语言环境。
685
- - _示例_: `true`
686
- - _说明_:
687
- - 如果为 `true` 且 `defaultLocale = 'en'`:路径为 `/en/dashboard` 或 `/fr/dashboard`
688
- - 如果为 `false` 且 `defaultLocale = 'en'`:路径为 `/dashboard` 或 `/fr/dashboard`
689
-
690
- - **basePath**:
691
- - _类型_: `string`
692
- - _默认值_: `''`
693
- - _说明_: 应用程序 URL 的基础路径。
694
- - _示例_: `'/my-app'`
695
- - _说明_:
696
- - 如果应用托管在 `https://example.com/my-app`
697
- - 基础路径为 `'/my-app'`
698
- - URL 将是 `https://example.com/my-app/en`
699
- - 如果未设置基础路径,URL 将是 `https://example.com/en`
700
-
701
- - **rewrite**:
702
- - _类型_: `Record<string, StrictModeLocaleMap<string>>`
703
- - _默认值_: `undefined`
704
- - _说明_: 自定义 URL 重写规则,用于覆盖特定路径的默认路由模式。允许定义与标准路由行为不同的特定语言路径。支持使用 `[param]` 语法的动态路由参数。
705
- - _示例_:
706
- ```typescript
707
- routing: {
708
- mode: "prefix-no-default", // 回退策略
709
- rewrite: nextjsRewrite({
710
- "/[locale]/about": {
711
- en: "/[locale]/about",
712
- fr: "/[locale]/a-propos",
713
- },
714
- "/[locale]/product/[slug]": {
715
- en: "/[locale]/product/[slug]",
716
- fr: "/[locale]/produit/[slug]",
717
- },
718
- "/[locale]/blog/[category]/[id]": {
719
- en: "/[locale]/blog/[category]/[id]",
720
- fr: "/[locale]/journal/[category]/[id]",
721
- },
722
- }),
723
- }
724
- ```
725
- - _说明_: 重写规则优先于默认的 `mode` 行为。如果路径匹配重写规则,将使用重写配置中的本地化路径,而不是标准语言前缀。
726
- - _说明_: 支持使用方括号表示法的动态路由参数(例如 `[slug]`、`[id]`)。参数值会自动从 URL 中提取并插入到重写的路径中。
727
- - _说明_: 适用于 Next.js 和 Vite 应用程序。中间件/代理会自动重写传入的请求以匹配内部路由结构。
728
- - _说明_: 使用 `getLocalizedUrl()` 生成 URL 时,如果重写规则与提供的路径匹配,将自动应用这些规则。
729
- - _参考_: 有关更多信息,请参阅 [自定义 URL 重写](https://github.com/aymericzip/intlayer/blob/main/docs/docs/zh/custom_url_rewrites.md)。
730
-
731
- - **serverSetCookie**:
732
- - _类型_:`string`
733
- - _默认值_:`'always'`
734
- - _描述_:服务器端设置语言环境 Cookie 的规则。
735
- - _选项_:`'always'`,`'never'`
736
- - _示例_:`'never'`
737
- - _说明_:控制是否在每次请求时设置语言环境 Cookie,或者从不设置。
738
-
739
- - **noPrefix**:
740
- - _类型_:`boolean`
741
- - _默认值_:`false`
742
- - _描述_:是否在 URL 中省略语言环境前缀。
743
- - _示例_:`true`
744
- - _说明_:
745
- - 如果为 `true`:URL 中无前缀
746
- - 如果为 `false`:URL 中有前缀
747
- - 以 `basePath = '/my-app'` 为例:
748
- - 如果 `noPrefix = false`:URL 将是 `https://example.com/my-app/en`
749
- - 如果 `noPrefix = true`:URL 将是 `https://example.com`
750
-
751
- ---
752
-
753
- ### 内容配置
754
-
755
- 与应用内内容处理相关的设置,包括目录名称、文件扩展名及派生配置。
756
-
757
- #### 属性
758
-
759
- - **autoFill**:
760
- - _类型_:`boolean | string | FilePathPattern | { [key in Locales]?: string }`
761
- - _默认值_:`undefined`
762
- - _描述_:指示内容应如何使用 AI 自动填充。可以在 `intlayer.config.ts` 文件中全局声明。
763
- - _示例_:true
764
- - _示例_:'./{{fileName}}.content.json'
765
- - _示例_:{ fr: './{{fileName}}.fr.content.json', es: './{{fileName}}.es.content.json' }
766
- - _备注_:自动填充配置。它可以是:
767
- - boolean:为所有语言启用自动填充
768
- - string:单个文件路径或带变量的模板路径
769
- - object:每个语言的文件路径
770
-
771
- - **watch**:
772
- - _类型_:`boolean`
773
- - _默认值_:`process.env.NODE_ENV === 'development'`
774
- - _描述_:指示 Intlayer 是否应监视应用中内容声明文件的更改,以重建相关字典。
775
-
776
- - **fileExtensions**:
777
- - _类型_:`string[]`
778
- - _默认值_: `['.content.ts', '.content.js', '.content.cjs', '.content.mjs', '.content.json', '.content.tsx', '.content.jsx']`
779
- - _描述_: 构建字典时要查找的文件扩展名。
780
- - _示例_: `['.data.ts', '.data.js', '.data.json']`
781
- - _备注_: 自定义文件扩展名可以帮助避免冲突。
782
-
783
- - **dictionaryOutput**:
784
- - _类型_: `string[]`
785
- - _默认值_: `['intlayer']`
786
- - _描述_: 使用的字典输出类型,例如 `'intlayer'` 或 `'i18next'`。
787
-
788
- - **contentDir**:
789
- - _类型_: `string[]`
790
- - _默认值_: `['.']`
791
- - _示例_: `['src', '../../ui-library', require.resolve("@my-package/content")]`
792
- - _描述_: 存储内容定义文件(`.content.*`)的目录路径。
793
- - _备注_: 用于监视内容文件以重建字典。
794
-
795
- - **codeDir**:
796
- - _类型_: `string[]`
797
- - _默认值_: `['.']`
798
- - _示例_: `['src', '../../ui-library']`
799
- - _描述_: 存储代码的目录路径,相对于基础目录。
800
- - _备注_: 用于监视代码文件以进行转换(修剪、优化)。将此与 `contentDir` 分开可以提高构建性能,避免不必要地扫描内容文件。
801
-
802
- ---
803
-
804
- ### 系统配置
805
-
806
- 与 Intlayer 内部路径和输出结果相关的设置。这些设置通常是内部的,用户无需修改。
807
-
808
- #### 属性
809
-
810
- - **baseDir**:
811
- - _类型_: `string`
812
- - _默认值_: `process.cwd()`
813
- - _描述_: 项目的基础目录。
814
- - _示例_: `'/path/to/project'`
815
- - _备注_: 用于解析所有与 Intlayer 相关的目录。
816
-
817
- - **dictionariesDir**:
818
- - _类型_: `string`
819
- - _默认值_: `'.intlayer/dictionary'`
820
- - _描述_: 用于存储本地化词典的目录。
821
- - _示例_: `'translations'`
822
-
823
- - **moduleAugmentationDir**:
824
- - _类型_: `string`
825
- - _默认_: `'.intlayer/types'`
826
- - _描述_: 模块增强目录,允许更好的 IDE 提示和类型检查。
827
- - _示例_: `'intlayer-types'`
828
- - _注意_: 确保在 `tsconfig.json` 中包含此目录。
829
-
830
- - **unmergedDictionariesDir**:
831
- - _类型_: `string`
832
- - _默认_: `'.intlayer/unmerged_dictionary'`
833
- - _描述_: 用于存储未合并字典的目录。
834
- - _示例_: `'translations'`
835
-
836
- - **typesDir**:
837
- - _类型_: `string`
838
- - _默认值_: `'types'`
839
- - _描述_: 用于存储词典类型的目录。
840
- - _示例_: `'intlayer-types'`
841
-
842
- - **mainDir**:
843
- - _类型_: `string`
844
- - _默认值_: `'main'`
845
- - _描述_: 存放主应用程序文件的目录。
846
- - _示例_: `'intlayer-main'`
847
-
848
- - **excludedPath**:
849
- - _类型_: `string[]`
850
- - _默认值_: `['node_modules']`
851
- - _描述_: 排除内容搜索的目录。
852
- - _备注_: 此设置尚未使用,但计划在未来实现。
853
-
854
- ### 字典配置
855
-
856
- 控制字典操作的设置,包括自动填充行为和内容生成。
857
-
858
- 此字典配置有两个主要目的:
859
-
860
- 1. **默认值**:在创建内容声明文件时定义默认值
861
- 2. **回退行为**:当未定义特定字段时提供回退值,允许您全局定义字典操作行为
862
-
863
- 有关内容声明文件以及如何应用配置值的更多信息,请参阅[内容文件文档](https://github.com/aymericzip/intlayer/blob/main/docs/docs/zh/dictionary/content_file.md)。
864
-
865
- #### 属性
866
-
867
- - **fill**
868
- - **description**
869
- - **locale**
870
- - **location**
871
- - **importMode**:
872
- - _注意_: **Deprecated**: Use `dictionary.importMode` instead.
873
- - _类型_: `'static' | 'dynamic' | 'fetch'`
874
- - _默认值_: `'static'`
875
- - _描述_: Controls how dictionaries are imported.
876
- - _示例_: `'dynamic'`
877
- - **priority**
878
- - **live**
879
- - **schema**
880
- - **title**
881
- - **tags**
882
- - **version**
883
-
884
- ---
885
-
886
- ### 日志配置
887
-
888
- 控制日志记录器的设置,包括使用的前缀。
889
-
890
- #### 属性
891
-
892
- - **mode**:
893
- - _类型_: `string`
894
- - _默认值_: `default`
895
- - _描述_: 指示日志记录器的模式。
896
- - _选项_: `default`,`verbose`,`disabled`
897
- - _示例_: `default`
898
- - _备注_: 日志记录器的模式。详细模式将记录更多信息,可用于调试。禁用模式将关闭日志记录器。
899
-
900
- - **prefix**:
901
- - _类型_: `string`
902
- - _默认值_: `'[intlayer] '`
903
- - _描述_: 日志记录器的前缀。
904
- - _示例_: `'[my custom prefix] '`
905
- - _注释_: 日志器的前缀。
906
-
907
- ### AI 配置
908
-
909
- 控制 Intlayer AI 功能的设置,包括提供商、模型和 API 密钥。
910
-
911
- 如果您已使用访问密钥在[Intlayer 控制面板](https://app.intlayer.org/project)注册,则此配置是可选的。Intlayer 会自动管理最有效且具有成本效益的 AI 解决方案以满足您的需求。使用默认选项可确保更好的长期可维护性,因为 Intlayer 会持续更新以使用最相关的模型。
912
-
913
- 如果您希望使用自己的 API 密钥或特定模型,可以定义自定义的 AI 配置。
914
- 此 AI 配置将在整个 Intlayer 环境中全局使用。CLI 命令将使用这些设置作为命令的默认值(例如 `fill`),同时 SDK、可视化编辑器和 CMS 也会使用这些默认值。您可以通过命令参数覆盖这些默认值以满足特定用例。
915
-
916
- Intlayer 支持多个 AI 提供商,以增强灵活性和选择。目前支持的提供商有:
917
-
918
- - **OpenAI**(默认)
919
- - **Anthropic Claude**
920
- - **Mistral AI**
921
- - **DeepSeek**
922
- - **Google Gemini**
923
- - **Meta Llama**
924
- - **Ollama**
925
- - **OpenRouter**
926
- - **Alibaba Cloud**
927
- - **Fireworks**
928
- - **Hugging Face**
929
- - **Groq**
930
- - **Amazon Bedrock**
931
- - **Google AI Studio**
932
- - **Google Vertex**
933
- - **Together.ai**
934
- - **ollama**
935
-
936
- #### 属性
937
-
938
- - **provider**:
939
- - _类型_:`string`
940
- - _默认值_:`'openai'`
941
- - _描述_:用于 Intlayer AI 功能的提供商。
942
- - _选项_:`'openai'`、`'anthropic'`、`'mistral'`、`'deepseek'`、`'gemini'`
943
- - _示例_:`'anthropic'`
944
- - _注意_: 不同的提供商可能需要不同的 API 密钥,并且有不同的定价模型。
945
-
946
- - **model**:
947
- - _类型_: `string`
948
- - _默认值_: 无
949
- - _描述_: 用于 Intlayer AI 功能的模型。
950
- - _示例_: `'gpt-4o-2024-11-20'`
951
- - _注意_: 具体使用的模型因提供商而异。
952
-
953
- - **temperature**:
954
- - _类型_: `number`
955
- - _默认值_: 无
956
- - _描述_: temperature 控制 AI 回答的随机性。
957
- - _示例_: `0.1`
958
- - _注意_: 较高的 temperature 会使 AI 更具创造性且不可预测。
959
-
960
- - **apiKey**:
961
- - _类型_: `string`
962
- - _默认值_: 无
963
- - _描述_: 你为所选提供商提供的 API 密钥。
964
- - _示例_: `process.env.OPENAI_API_KEY`
965
- - _注意_: 重要提示:API 密钥应保密,切勿公开共享。请确保将其保存在安全的位置,例如环境变量中。
966
-
967
- - **applicationContext**:
968
- - _类型_: `string`
969
- - _默认值_: 无
970
- - _描述_: 向 AI 模型提供有关您的应用程序的额外上下文,帮助其生成更准确且符合上下文的翻译。这可以包括您的应用领域、目标受众、语气或特定术语的信息。
971
-
972
- - **baseURL**:
973
- - _类型_: `string`
974
- - _默认值_: 无
975
- - _描述_: AI API 的基础 URL。
976
- - _示例_: `'https://api.openai.com/v1'`
977
- - _注意_: 可用于指向本地或自定义的 AI API 端点。
978
-
979
- - **dataSerialization**:
980
- - _类型_: `'json' | 'toon'`
981
- - _默认值_: `'json'`
982
- - _描述_: 用于 Intlayer AI 功能的数据序列化格式。
983
- - _示例_: `'toon'`
984
- - _注意_: `json`: 标准、可靠;使用更多令牌。`toon`: 令牌更少,但不如 JSON 一致。
985
-
986
- ### 构建配置
987
-
988
- 控制 Intlayer 如何优化和构建您的应用程序国际化的设置。
989
-
990
- 构建选项适用于 `@intlayer/babel` 和 `@intlayer/swc` 插件。
991
-
992
- > 在开发模式下,Intlayer 使用静态导入字典,以简化开发体验。
993
-
994
- > 在优化模式下,Intlayer 会替换字典调用以优化代码分块,因此最终打包只会导入实际使用的字典。
995
-
996
- #### 属性
997
-
998
- - **mode**:
999
- - _类型_:`'auto' | 'manual'`
1000
- - _默认值_:`'auto'`
1001
- - _描述_:控制构建的模式。
1002
- - _示例_:`'manual'`
1003
- - _注意_:如果为 'auto',构建将在应用程序构建时自动启用。
1004
- - _注意_:如果为 'manual',构建仅在执行构建命令时设置。
1005
- - _注意_:可用于禁用字典构建,例如当应避免在 Node.js 环境中执行时。
1006
-
1007
- - **checkTypes**:
1008
- - _类型_: `boolean`
1009
- - _默认值_: `false`
1010
- - _描述_: 指示构建是否应检查 TypeScript 类型并记录错误。
1011
- - _注意_: 这可能会减慢构建速度。
1012
-
1013
- - **optimize**:
1014
- - _类型_:`boolean`
1015
- - _默认值_:`process.env.NODE_ENV === 'production'`
1016
- - _描述_:控制构建是否应进行优化。
1017
- - _示例_:`true`
1018
- - _注意_:启用时,Intlayer 会替换所有字典调用以优化代码分块。这样最终打包只会导入被使用的字典。所有导入将保持为静态导入,以避免加载字典时的异步处理。
1019
- - _注意_: Intlayer 会根据 `importMode` 选项定义的模式替换所有 `useIntlayer` 的调用,并将 `getIntlayer` 替换为 `getDictionary`。
1020
- - _注意_: 此选项依赖于 `@intlayer/babel` 和 `@intlayer/swc` 插件。
1021
- - _注意_: 确保所有键在 `useIntlayer` 调用中是静态声明的。例如 `useIntlayer('navbar')`。
1022
-
1023
- - **outputFormat**:
1024
- - _类型_: `'esm' | 'cjs'`
1025
- - _默认值_: `'esm'`
1026
- - _描述_: 控制字典的输出格式。
1027
- - _示例_: `'cjs'`
1028
- - _注意_: 字典的输出格式。
1029
-
1030
- - **traversePattern**:
1031
- - _类型_: `string[]`
1032
- - _默认值_: `['**\/*.{js,ts,mjs,cjs,jsx,tsx}', '!**\/node_modules/**']`
1033
- - _描述_:定义在优化过程中应遍历哪些文件的模式。
1034
- - _示例_:`['src/**\/*.{ts,tsx}', '../ui-library/**\/*.{ts,tsx}', '!**/node_modules/**']`
1035
- - _注意_:使用此选项限制优化范围到相关代码文件,以提升构建性能。
1036
- - _注意_:如果禁用 `optimize`,此选项将被忽略。
1037
- - _注意_:使用 glob 模式。
1038
-
1039
- ---
1040
-
1041
- ### 编译器配置
1042
-
1043
- 控制 Intlayer 编译器的设置,该编译器直接从您的组件中提取字典。
1044
-
1045
- #### 属性
1046
-
1047
- - **enabled**:
1048
- - _类型_:`boolean | 'build-only'`
1049
- - _默认值_:`true`
1050
- - _描述_:指示是否应启用编译器以提取字典。
1051
- - _示例_:`'build-only'`
1052
- - _注意_:设置为 `'build-only'` 将在开发模式下跳过编译器,以加快启动速度。它仅在构建命令时运行。
1053
-
1054
- - **dictionaryKeyPrefix**:
1055
- - _类型_:`string`
1056
- - _默认值_:`''`
1057
- - _描述_:提取的字典键的前缀。
1058
- - _示例_:`'my-key-'`
1059
- - _注意_:提取字典时,键是根据文件名生成的。此前缀会添加到生成的键中,以防止冲突。
1060
-
1061
- - **saveComponents**:
1062
- - _类型_:`boolean`
1063
- - _默认值_:`false`
1064
- - _描述_:指示是否应在转换后保存组件。
1065
- - _注意_:如果为 true,编译器将用转换后的文件替换原始文件。这样,编译器只需运行一次来转换应用,然后即可移除。
1066
-
1067
- - **transformPattern**:
1068
- - _类型_:`string | string[]`
1069
- - _默认值_:`['**/*.{ts,tsx,jsx,js,cjs,mjs,svelte,vue}', '!**/node_modules/**']`
1070
- - _描述_:定义在优化过程中应遍历哪些文件的模式。
1071
- - _示例_:`['src/**/*.{ts,tsx}', '!**/node_modules/**']`
1072
- - _注意_:使用此选项限制优化范围到相关代码文件,以提升构建性能。
1073
-
1074
- - **excludePattern**:
1075
- - _类型_:`string | string[]`
1076
- - _默认值_:`['**/node_modules/**']`
1077
- - _描述_:定义在优化过程中应排除哪些文件的模式。
1078
- - _示例_:`['**/node_modules/**', '!**/node_modules/react/**']`
1079
-
1080
- - **output**:
1081
- - _类型_: `FilePathPattern`
1082
- - _默认值_: `undefined`
1083
- - _描述_: 定义输出文件路径。替换 `outputDir`。通过字符串模板或函数支持动态变量。支持的变量:`{{fileName}}`, `{{key}}`, `{{locale}}`, `{{extension}}`, `{{componentFileName}}`, `{{componentExtension}}`, `{{format}}`, `{{componentFormat}}`, `{{componentDirPath}}`。
1084
- - _注意_: 以 `./` 开头的路径相对于组件目录解析。以 `/` 开头的路径相对于项目根目录 (`baseDir`) 解析。
1085
- - _注意_: 在路径中包含 `{{locale}}` 变量将启用按语言环境分离开的字典生成。
1086
- - _示例_:
1087
- - **在组件旁边创建多语言文件**:
1088
- - 字符串: `'./{{fileName}}{{extension}}'`
1089
- - 函数: `({ fileName, extension }) => \`./${fileName}${extension}\``
1090
-
1091
- - **输出按语言环境集中的 JSON**:
1092
- - 字符串: `'/locales/{{locale}}/{{key}}.content.json'`
1093
- - 函数: `({ key, locale }) => \`/locales/${locale}/${key}.content.json\``
1094
-
1095
- - **noMetadata**:
1096
- - _类型_: `boolean`
1097
- - _默认值_: `false`
1098
- - _描述_: 指示是否应在文件中保存元数据。如果为 true,编译器将不会保存字典的元数据(键、内容包装器)。
1099
- - _注意_: 如果与 `loadJSON` 插件一起使用,则非常有用。对于每种语言的 i18next 或 ICU MessageFormat JSON 输出非常有用。
1100
- - _示例_:
1101
- 如果为 `true`:
1102
- ```json
1103
- {
1104
- "key": "value"
1105
- }
1106
- ```
1107
- 如果为 `false`:
1108
- ```json
1109
- {
1110
- "key": "value",
1111
- "content": {
1112
- "key": "value"
1113
- }
1114
- }
1115
- ```