@intlayer/docs 8.9.4-canary.0 → 8.9.5
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.
- package/dist/cjs/generated/docs.entry.cjs +20 -0
- package/dist/cjs/generated/docs.entry.cjs.map +1 -1
- package/dist/esm/generated/docs.entry.mjs +20 -0
- package/dist/esm/generated/docs.entry.mjs.map +1 -1
- package/dist/types/generated/docs.entry.d.ts +1 -0
- package/dist/types/generated/docs.entry.d.ts.map +1 -1
- package/docs/ar/benchmark/index.md +0 -3
- package/docs/ar/benchmark/nextjs.md +15 -6
- package/docs/ar/benchmark/solid.md +155 -0
- package/docs/ar/benchmark/svelte.md +148 -0
- package/docs/ar/benchmark/tanstack.md +12 -3
- package/docs/ar/benchmark/vue.md +160 -0
- package/docs/ar/configuration.md +16 -12
- package/docs/ar/dictionary/content_file.md +51 -1
- package/docs/ar/mcp_server.md +30 -17
- package/docs/ar/plugins/sync-po.md +333 -0
- package/docs/bn/configuration.md +16 -12
- package/docs/cs/configuration.md +16 -12
- package/docs/de/benchmark/index.md +0 -3
- package/docs/de/benchmark/nextjs.md +15 -6
- package/docs/de/benchmark/solid.md +155 -0
- package/docs/de/benchmark/svelte.md +148 -0
- package/docs/de/benchmark/tanstack.md +12 -3
- package/docs/de/benchmark/vue.md +160 -0
- package/docs/de/configuration.md +16 -12
- package/docs/de/dictionary/content_file.md +52 -2
- package/docs/de/mcp_server.md +29 -16
- package/docs/de/plugins/sync-po.md +332 -0
- package/docs/en/benchmark/nextjs.md +11 -2
- package/docs/en/benchmark/solid.md +22 -4
- package/docs/en/benchmark/svelte.md +17 -5
- package/docs/en/benchmark/tanstack.md +18 -3
- package/docs/en/benchmark/vue.md +17 -11
- package/docs/en/configuration.md +16 -13
- package/docs/en/dictionary/content_file.md +51 -1
- package/docs/en/mcp_server.md +31 -18
- package/docs/en/plugins/sync-po.md +333 -0
- package/docs/en-GB/benchmark/index.md +0 -3
- package/docs/en-GB/benchmark/nextjs.md +15 -6
- package/docs/en-GB/benchmark/solid.md +155 -0
- package/docs/en-GB/benchmark/svelte.md +148 -0
- package/docs/en-GB/benchmark/tanstack.md +12 -3
- package/docs/en-GB/benchmark/vue.md +160 -0
- package/docs/en-GB/configuration.md +15 -11
- package/docs/en-GB/dictionary/content_file.md +51 -1
- package/docs/en-GB/mcp_server.md +31 -18
- package/docs/en-GB/plugins/sync-po.md +333 -0
- package/docs/es/benchmark/index.md +0 -3
- package/docs/es/benchmark/nextjs.md +15 -6
- package/docs/es/benchmark/solid.md +155 -0
- package/docs/es/benchmark/svelte.md +148 -0
- package/docs/es/benchmark/tanstack.md +12 -3
- package/docs/es/benchmark/vue.md +160 -0
- package/docs/es/configuration.md +16 -12
- package/docs/es/dictionary/content_file.md +51 -1
- package/docs/es/mcp_server.md +30 -17
- package/docs/es/plugins/sync-po.md +333 -0
- package/docs/fr/benchmark/index.md +0 -3
- package/docs/fr/benchmark/nextjs.md +15 -6
- package/docs/fr/benchmark/solid.md +155 -0
- package/docs/fr/benchmark/svelte.md +148 -0
- package/docs/fr/benchmark/tanstack.md +12 -3
- package/docs/fr/benchmark/vue.md +160 -0
- package/docs/fr/configuration.md +16 -12
- package/docs/fr/dictionary/content_file.md +51 -1
- package/docs/fr/mcp_server.md +30 -17
- package/docs/fr/plugins/sync-po.md +333 -0
- package/docs/hi/benchmark/nextjs.md +15 -6
- package/docs/hi/benchmark/solid.md +155 -0
- package/docs/hi/benchmark/svelte.md +148 -0
- package/docs/hi/benchmark/tanstack.md +12 -3
- package/docs/hi/benchmark/vue.md +160 -0
- package/docs/hi/configuration.md +16 -12
- package/docs/hi/dictionary/content_file.md +51 -1
- package/docs/hi/mcp_server.md +31 -18
- package/docs/hi/plugins/sync-po.md +333 -0
- package/docs/id/benchmark/index.md +0 -3
- package/docs/id/benchmark/nextjs.md +15 -6
- package/docs/id/benchmark/solid.md +155 -0
- package/docs/id/benchmark/svelte.md +148 -0
- package/docs/id/benchmark/tanstack.md +12 -3
- package/docs/id/benchmark/vue.md +160 -0
- package/docs/id/configuration.md +16 -12
- package/docs/id/dictionary/content_file.md +51 -1
- package/docs/id/mcp_server.md +30 -17
- package/docs/id/plugins/sync-po.md +333 -0
- package/docs/it/benchmark/index.md +1 -4
- package/docs/it/benchmark/nextjs.md +15 -6
- package/docs/it/benchmark/solid.md +155 -0
- package/docs/it/benchmark/svelte.md +148 -0
- package/docs/it/benchmark/tanstack.md +12 -3
- package/docs/it/benchmark/vue.md +160 -0
- package/docs/it/configuration.md +16 -12
- package/docs/it/dictionary/content_file.md +51 -1
- package/docs/it/mcp_server.md +30 -17
- package/docs/it/plugins/sync-po.md +333 -0
- package/docs/ja/benchmark/index.md +5 -5
- package/docs/ja/benchmark/nextjs.md +15 -6
- package/docs/ja/benchmark/solid.md +155 -0
- package/docs/ja/benchmark/svelte.md +148 -0
- package/docs/ja/benchmark/tanstack.md +12 -3
- package/docs/ja/benchmark/vue.md +160 -0
- package/docs/ja/configuration.md +16 -12
- package/docs/ja/dictionary/content_file.md +50 -2
- package/docs/ja/intlayer_with_nextjs_no_locale_path.md +4 -3
- package/docs/ja/mcp_server.md +29 -16
- package/docs/ja/plugins/sync-po.md +333 -0
- package/docs/ko/benchmark/nextjs.md +15 -6
- package/docs/ko/benchmark/solid.md +155 -0
- package/docs/ko/benchmark/svelte.md +148 -0
- package/docs/ko/benchmark/tanstack.md +12 -3
- package/docs/ko/benchmark/vue.md +160 -0
- package/docs/ko/configuration.md +16 -12
- package/docs/ko/dictionary/content_file.md +51 -1
- package/docs/ko/intlayer_with_nextjs_no_locale_path.md +3 -2
- package/docs/ko/mcp_server.md +31 -18
- package/docs/ko/plugins/sync-po.md +333 -0
- package/docs/nl/configuration.md +16 -12
- package/docs/pl/benchmark/index.md +0 -3
- package/docs/pl/benchmark/nextjs.md +15 -6
- package/docs/pl/benchmark/solid.md +155 -0
- package/docs/pl/benchmark/svelte.md +148 -0
- package/docs/pl/benchmark/tanstack.md +12 -3
- package/docs/pl/benchmark/vue.md +160 -0
- package/docs/pl/configuration.md +16 -12
- package/docs/pl/dictionary/content_file.md +51 -1
- package/docs/pl/mcp_server.md +30 -17
- package/docs/pl/plugins/sync-po.md +333 -0
- package/docs/pt/benchmark/index.md +0 -3
- package/docs/pt/benchmark/nextjs.md +16 -7
- package/docs/pt/benchmark/solid.md +155 -0
- package/docs/pt/benchmark/svelte.md +148 -0
- package/docs/pt/benchmark/tanstack.md +13 -4
- package/docs/pt/benchmark/vue.md +160 -0
- package/docs/pt/configuration.md +16 -12
- package/docs/pt/dictionary/content_file.md +51 -1
- package/docs/pt/mcp_server.md +30 -17
- package/docs/pt/plugins/sync-po.md +333 -0
- package/docs/ru/benchmark/nextjs.md +15 -6
- package/docs/ru/benchmark/solid.md +155 -0
- package/docs/ru/benchmark/svelte.md +148 -0
- package/docs/ru/benchmark/tanstack.md +12 -3
- package/docs/ru/benchmark/vue.md +160 -0
- package/docs/ru/configuration.md +16 -12
- package/docs/ru/dictionary/content_file.md +52 -2
- package/docs/ru/mcp_server.md +30 -17
- package/docs/ru/plugins/sync-po.md +333 -0
- package/docs/tr/benchmark/index.md +0 -3
- package/docs/tr/benchmark/nextjs.md +15 -6
- package/docs/tr/benchmark/solid.md +155 -0
- package/docs/tr/benchmark/svelte.md +148 -0
- package/docs/tr/benchmark/tanstack.md +12 -3
- package/docs/tr/benchmark/vue.md +160 -0
- package/docs/tr/configuration.md +16 -12
- package/docs/tr/dictionary/content_file.md +51 -1
- package/docs/tr/mcp_server.md +31 -18
- package/docs/tr/plugins/sync-po.md +333 -0
- package/docs/uk/benchmark/nextjs.md +15 -6
- package/docs/uk/benchmark/solid.md +155 -0
- package/docs/uk/benchmark/svelte.md +148 -0
- package/docs/uk/benchmark/tanstack.md +12 -3
- package/docs/uk/benchmark/vue.md +160 -0
- package/docs/uk/configuration.md +16 -12
- package/docs/uk/dictionary/content_file.md +51 -1
- package/docs/uk/mcp_server.md +29 -16
- package/docs/uk/plugins/sync-po.md +333 -0
- package/docs/ur/configuration.md +16 -12
- package/docs/vi/benchmark/index.md +0 -3
- package/docs/vi/benchmark/nextjs.md +15 -6
- package/docs/vi/benchmark/solid.md +155 -0
- package/docs/vi/benchmark/svelte.md +148 -0
- package/docs/vi/benchmark/tanstack.md +12 -3
- package/docs/vi/benchmark/vue.md +160 -0
- package/docs/vi/configuration.md +16 -12
- package/docs/vi/dictionary/content_file.md +51 -1
- package/docs/vi/intlayer_with_nextjs_15.md +10 -57
- package/docs/vi/mcp_server.md +30 -17
- package/docs/vi/plugins/sync-po.md +333 -0
- package/docs/zh/benchmark/nextjs.md +15 -6
- package/docs/zh/benchmark/solid.md +155 -0
- package/docs/zh/benchmark/svelte.md +148 -0
- package/docs/zh/benchmark/tanstack.md +12 -3
- package/docs/zh/benchmark/vue.md +160 -0
- package/docs/zh/configuration.md +16 -12
- package/docs/zh/dictionary/content_file.md +51 -3
- package/docs/zh/mcp_server.md +31 -18
- package/docs/zh/plugins/sync-po.md +333 -0
- package/frequent_questions/ar/intlayerNode.md +3 -3
- package/frequent_questions/de/intlayerNode.md +3 -3
- package/frequent_questions/en/intlayerNode.md +3 -3
- package/frequent_questions/en-GB/intlayerNode.md +3 -3
- package/frequent_questions/es/intlayerNode.md +3 -3
- package/frequent_questions/fr/intlayerNode.md +3 -3
- package/frequent_questions/hi/intlayerNode.md +3 -3
- package/frequent_questions/id/intlayerNode.md +3 -3
- package/frequent_questions/it/intlayerNode.md +3 -3
- package/frequent_questions/ja/intlayerNode.md +3 -3
- package/frequent_questions/ko/intlayerNode.md +3 -3
- package/frequent_questions/pl/intlayerNode.md +3 -3
- package/frequent_questions/pt/intlayerNode.md +3 -3
- package/frequent_questions/ru/intlayerNode.md +3 -3
- package/frequent_questions/tr/intlayerNode.md +3 -3
- package/frequent_questions/uk/intlayerNode.md +3 -3
- package/frequent_questions/vi/intlayerNode.md +3 -3
- package/frequent_questions/zh/intlayerNode.md +3 -3
- package/package.json +8 -8
- package/src/generated/docs.entry.ts +20 -0
package/docs/zh/mcp_server.md
CHANGED
|
@@ -23,7 +23,7 @@ history:
|
|
|
23
23
|
changes: "添加 Claude Desktop 的设置"
|
|
24
24
|
- version: 5.5.12
|
|
25
25
|
date: 2025-07-10
|
|
26
|
-
changes: "添加
|
|
26
|
+
changes: "添加 Streamable HTTP 传输和远程服务器支持"
|
|
27
27
|
- version: 5.5.10
|
|
28
28
|
date: 2025-06-29
|
|
29
29
|
changes: "初始化历史记录"
|
|
@@ -51,12 +51,12 @@ history:
|
|
|
51
51
|
|
|
52
52
|
> 查看完整的命令和选项列表,请参阅 [Intlayer CLI 文档](https://github.com/aymericzip/intlayer/blob/main/docs/docs/zh/cli/index.md)。
|
|
53
53
|
|
|
54
|
-
## 本地服务器(stdio)与远程服务器(
|
|
54
|
+
## 本地服务器(stdio)与远程服务器(Streamable HTTP)
|
|
55
55
|
|
|
56
56
|
MCP 服务器可以通过两种方式使用:
|
|
57
57
|
|
|
58
58
|
- 本地服务器(stdio)
|
|
59
|
-
- 远程服务器(
|
|
59
|
+
- 远程服务器(Streamable HTTP)
|
|
60
60
|
|
|
61
61
|
### 本地服务器(stdio)(推荐)
|
|
62
62
|
|
|
@@ -64,9 +64,9 @@ Intlayer 提供了一个可以在您的机器上本地安装的 NPM 包。它可
|
|
|
64
64
|
|
|
65
65
|
这是使用 MCP 服务器的推荐方式,因为它集成了 MCP 服务器的所有功能,包括 CLI 工具。
|
|
66
66
|
|
|
67
|
-
### 远程服务器(
|
|
67
|
+
### 远程服务器(Streamable HTTP)
|
|
68
68
|
|
|
69
|
-
MCP 服务器也可以通过
|
|
69
|
+
MCP 服务器也可以通过 Streamable HTTP 传输方式远程使用。该服务器由 Intlayer 托管,地址为 https://mcp.intlayer.org。该服务器可公开访问,无需任何身份验证,且免费使用。
|
|
70
70
|
|
|
71
71
|
请注意,远程服务器不集成 CLI 工具、AI 自动补全等功能。远程服务器仅用于与文档交互,以帮助您的 AI 助手使用 Intlayer 生态系统。
|
|
72
72
|
|
|
@@ -97,7 +97,7 @@ bun x intlayer init mcp
|
|
|
97
97
|
此命令将:
|
|
98
98
|
|
|
99
99
|
1. 询问您正在使用的平台(Cursor、VS Code、Claude Desktop 等)。
|
|
100
|
-
2. 询问您要使用的传输方法(本地服务器 (stdio) 或远程服务器 (
|
|
100
|
+
2. 询问您要使用的传输方法(本地服务器 (stdio) 或远程服务器 (Streamable HTTP))。
|
|
101
101
|
3. 自动更新您的配置文件(例如 `.cursor/mcp.json`、`.vscode/mcp.json` 或全局 Claude Desktop 配置)。
|
|
102
102
|
|
|
103
103
|
---
|
|
@@ -107,7 +107,7 @@ bun x intlayer init mcp
|
|
|
107
107
|
1. 打开命令面板 (Ctrl+Shift+P 或 Cmd+Shift+P)。
|
|
108
108
|
2. 输入 `Intlayer: Setup AI Agent Skills`
|
|
109
109
|
3. 选择您使用的平台(例如 `VS Code`、`Cursor`、`Windsurf`、`OpenCode`、`Claude Code`、`GitHub Copilot Workspace` 等)。
|
|
110
|
-
4. 选择要安装的 MCP (stdio,
|
|
110
|
+
4. 选择要安装的 MCP (stdio, Streamable HTTP)
|
|
111
111
|
5. 按 Enter 键。
|
|
112
112
|
|
|
113
113
|
---
|
|
@@ -131,16 +131,16 @@ bun x intlayer init mcp
|
|
|
131
131
|
}
|
|
132
132
|
```
|
|
133
133
|
|
|
134
|
-
### 远程服务器(
|
|
134
|
+
### 远程服务器(Streamable HTTP)
|
|
135
135
|
|
|
136
|
-
要通过服务器发送事件(
|
|
136
|
+
要通过服务器发送事件(Streamable HTTP)连接到远程 Intlayer MCP 服务器,您可以配置 MCP 客户端以连接到托管服务。
|
|
137
137
|
|
|
138
138
|
```json fileName=".cursor/mcp.json"
|
|
139
139
|
{
|
|
140
140
|
"mcpServers": {
|
|
141
|
-
"intlayer": {
|
|
142
|
-
"
|
|
143
|
-
"
|
|
141
|
+
"intlayer-sse": {
|
|
142
|
+
"command": "npx",
|
|
143
|
+
"args": ["-y", "mcp-remote@latest", "https://mcp.intlayer.org"]
|
|
144
144
|
}
|
|
145
145
|
}
|
|
146
146
|
}
|
|
@@ -172,16 +172,16 @@ bun x intlayer init mcp
|
|
|
172
172
|
}
|
|
173
173
|
```
|
|
174
174
|
|
|
175
|
-
### 远程服务器(
|
|
175
|
+
### 远程服务器(Streamable HTTP)
|
|
176
176
|
|
|
177
|
-
要连接到使用服务器发送事件(
|
|
177
|
+
要连接到使用服务器发送事件(Streamable HTTP)的远程 Intlayer MCP 服务器,你可以配置你的 MCP 客户端以连接到托管服务。
|
|
178
178
|
|
|
179
179
|
```json fileName=".vscode/mcp.json"
|
|
180
180
|
{
|
|
181
181
|
"servers": {
|
|
182
|
-
"intlayer": {
|
|
183
|
-
"
|
|
184
|
-
"
|
|
182
|
+
"intlayer-sse": {
|
|
183
|
+
"command": "npx",
|
|
184
|
+
"args": ["-y", "mcp-remote@latest", "https://mcp.intlayer.org"]
|
|
185
185
|
}
|
|
186
186
|
}
|
|
187
187
|
}
|
|
@@ -191,7 +191,7 @@ bun x intlayer init mcp
|
|
|
191
191
|
|
|
192
192
|
## 在 ChatGPT 中设置
|
|
193
193
|
|
|
194
|
-
### 远程服务器(
|
|
194
|
+
### 远程服务器(Streamable HTTP)
|
|
195
195
|
|
|
196
196
|
请按照[官方文档](https://platform.openai.com/docs/mcp#test-and-connect-your-mcp-server)配置 ChatGPT 中的 MCP 服务器。
|
|
197
197
|
|
|
@@ -232,6 +232,19 @@ bun x intlayer init mcp
|
|
|
232
232
|
}
|
|
233
233
|
```
|
|
234
234
|
|
|
235
|
+
### 远程服务器(Streamable HTTP)
|
|
236
|
+
|
|
237
|
+
```json fileName="claude_desktop_config.json"
|
|
238
|
+
{
|
|
239
|
+
"mcpServers": {
|
|
240
|
+
"intlayer-sse": {
|
|
241
|
+
"command": "npx",
|
|
242
|
+
"args": ["-y", "mcp-remote@latest", "https://mcp.intlayer.org"]
|
|
243
|
+
}
|
|
244
|
+
}
|
|
245
|
+
}
|
|
246
|
+
```
|
|
247
|
+
|
|
235
248
|
---
|
|
236
249
|
|
|
237
250
|
## 通过命令行界面使用 MCP 服务器
|
|
@@ -0,0 +1,333 @@
|
|
|
1
|
+
---
|
|
2
|
+
createdAt: 2026-05-10
|
|
3
|
+
updatedAt: 2026-05-10
|
|
4
|
+
title: Sync PO 插件
|
|
5
|
+
description: 将 Intlayer 字典与 Gettext PO 文件同步。在使用 Intlayer 管理、翻译和测试消息的同时,保留现有的 i18n。
|
|
6
|
+
keywords:
|
|
7
|
+
- Intlayer
|
|
8
|
+
- Sync PO
|
|
9
|
+
- Gettext
|
|
10
|
+
- i18n
|
|
11
|
+
- 翻译
|
|
12
|
+
slugs:
|
|
13
|
+
- doc
|
|
14
|
+
- plugin
|
|
15
|
+
- sync-po
|
|
16
|
+
youtubeVideo: https://www.youtube.com/watch?v=MpGMxniDHNg
|
|
17
|
+
history:
|
|
18
|
+
- version: 8.9.4
|
|
19
|
+
date: 2026-05-10
|
|
20
|
+
changes: "初始 Sync PO 插件文档"
|
|
21
|
+
---
|
|
22
|
+
|
|
23
|
+
# Sync PO (i18n 桥接) - 支持 ICU / i18next 的 Sync PO
|
|
24
|
+
|
|
25
|
+
将 Intlayer 作为现有 i18n 栈的补充。此插件使您的 Gettext PO 消息与 Intlayer 字典保持同步,以便您可以:
|
|
26
|
+
|
|
27
|
+
- 保留现有的基于 PO 的翻译工作流。
|
|
28
|
+
- 使用 Intlayer (CLI、CI、供应商、CMS) 管理和翻译您的消息,无需重构您的应用。
|
|
29
|
+
- 发布针对各生态系统的教程和 SEO 内容,同时建议将 Intlayer 作为 PO 管理层。
|
|
30
|
+
|
|
31
|
+
注意事项和当前范围:
|
|
32
|
+
|
|
33
|
+
- 外部化到 CMS 适用于翻译和经典文本。
|
|
34
|
+
- 尚不支持 PO 条目内部的插值、复数/ICU 或其他库的高级运行时功能。
|
|
35
|
+
- 可视化编辑器尚不支持第三方 i18n 输出。
|
|
36
|
+
|
|
37
|
+
### 何时使用此插件
|
|
38
|
+
|
|
39
|
+
- 您已经在使用 Gettext PO 文件进行翻译。
|
|
40
|
+
- 您希望在不更改渲染运行时的情况下,获得 AI 辅助填充、CI 测试和内容运营。
|
|
41
|
+
|
|
42
|
+
## 安装
|
|
43
|
+
|
|
44
|
+
```bash
|
|
45
|
+
pnpm add -D @intlayer/sync-po-plugin
|
|
46
|
+
# 或
|
|
47
|
+
npm i -D @intlayer/sync-po-plugin
|
|
48
|
+
```
|
|
49
|
+
|
|
50
|
+
## 插件
|
|
51
|
+
|
|
52
|
+
此包提供两个插件:
|
|
53
|
+
|
|
54
|
+
- `loadPO`:将 PO 文件加载到 Intlayer 字典中。
|
|
55
|
+
- 此插件用于从源加载 PO 文件并将其载入 Intlayer 字典。它可以扫描整个代码库并搜索特定的 PO 文件。
|
|
56
|
+
此插件可用于:
|
|
57
|
+
- 如果您使用的 i18n 库强制要求 PO 文件的加载位置,但您希望将内容声明放在代码库中您喜欢的位置。
|
|
58
|
+
- 它也可以用于从远程源(如 CMS、API 等)获取消息并将消息存储在 PO 文件中。
|
|
59
|
+
|
|
60
|
+
> 在底层,此插件将扫描整个代码库并搜索特定的 PO 文件,并将其加载到 Intlayer 字典中。
|
|
61
|
+
> 请注意,此插件不会将输出和翻译写回 PO 文件。
|
|
62
|
+
|
|
63
|
+
- `syncPO`:将 PO 文件与 Intlayer 字典同步。
|
|
64
|
+
- 此插件用于将 PO 文件与 Intlayer 字典同步。它可以扫描给定位置并加载与特定 PO 文件模式匹配的 PO。如果您想在使用另一个 i18n 库的同时获得 Intlayer 的优势,此插件非常有用。
|
|
65
|
+
|
|
66
|
+
## 同时使用两个插件
|
|
67
|
+
|
|
68
|
+
```ts fileName="intlayer.config.ts"
|
|
69
|
+
import { Locales, type IntlayerConfig } from "intlayer";
|
|
70
|
+
import { loadPO, syncPO } from "@intlayer/sync-po-plugin";
|
|
71
|
+
|
|
72
|
+
const config: IntlayerConfig = {
|
|
73
|
+
internationalization: {
|
|
74
|
+
locales: [Locales.ENGLISH, Locales.FRENCH, Locales.SPANISH],
|
|
75
|
+
defaultLocale: Locales.ENGLISH,
|
|
76
|
+
},
|
|
77
|
+
|
|
78
|
+
// 使当前的 PO 文件与 Intlayer 字典保持同步
|
|
79
|
+
plugins: [
|
|
80
|
+
/**
|
|
81
|
+
* 将加载 src 中匹配 {key}.i18n.po 模式的所有 PO 文件
|
|
82
|
+
*/
|
|
83
|
+
loadPO({
|
|
84
|
+
source: ({ key }) => `./src/**/${key}.i18n.po`,
|
|
85
|
+
locale: Locales.ENGLISH,
|
|
86
|
+
priority: 1, // 确保这些 PO 文件优先于 `./locales/en/${key}.po` 处的文件
|
|
87
|
+
}),
|
|
88
|
+
/**
|
|
89
|
+
* 将加载输出和翻译并将其写回 locales 目录中的 PO 文件
|
|
90
|
+
*/
|
|
91
|
+
syncPO({
|
|
92
|
+
source: ({ key, locale }) => `./locales/${locale}/${key}.po`,
|
|
93
|
+
priority: 0,
|
|
94
|
+
}),
|
|
95
|
+
],
|
|
96
|
+
};
|
|
97
|
+
|
|
98
|
+
export default config;
|
|
99
|
+
```
|
|
100
|
+
|
|
101
|
+
## `syncPO` 插件
|
|
102
|
+
|
|
103
|
+
### 快速开始
|
|
104
|
+
|
|
105
|
+
将插件添加到您的 `intlayer.config.ts` 并指向您现有的 PO 结构。
|
|
106
|
+
|
|
107
|
+
```ts fileName="intlayer.config.ts"
|
|
108
|
+
import { Locales, type IntlayerConfig } from "intlayer";
|
|
109
|
+
import { syncPO } from "@intlayer/sync-po-plugin";
|
|
110
|
+
|
|
111
|
+
const config: IntlayerConfig = {
|
|
112
|
+
internationalization: {
|
|
113
|
+
locales: [Locales.ENGLISH, Locales.FRENCH, Locales.SPANISH],
|
|
114
|
+
defaultLocale: Locales.ENGLISH,
|
|
115
|
+
},
|
|
116
|
+
|
|
117
|
+
// 使当前的 PO 文件与 Intlayer 字典保持同步
|
|
118
|
+
plugins: [
|
|
119
|
+
syncPO({
|
|
120
|
+
// 每个语言、每个命名空间的布局
|
|
121
|
+
source: ({ key, locale }) => `./locales/${locale}/${key}.po`,
|
|
122
|
+
}),
|
|
123
|
+
],
|
|
124
|
+
};
|
|
125
|
+
|
|
126
|
+
export default config;
|
|
127
|
+
```
|
|
128
|
+
|
|
129
|
+
备选方案:每个语言一个文件:
|
|
130
|
+
|
|
131
|
+
```ts fileName="intlayer.config.ts"
|
|
132
|
+
import { Locales, type IntlayerConfig } from "intlayer";
|
|
133
|
+
import { syncPO } from "@intlayer/sync-po-plugin";
|
|
134
|
+
|
|
135
|
+
const config: IntlayerConfig = {
|
|
136
|
+
internationalization: {
|
|
137
|
+
locales: [Locales.ENGLISH, Locales.FRENCH],
|
|
138
|
+
defaultLocale: Locales.ENGLISH,
|
|
139
|
+
},
|
|
140
|
+
plugins: [
|
|
141
|
+
syncPO({
|
|
142
|
+
source: ({ locale }) => `./locales/${locale}.po`,
|
|
143
|
+
}),
|
|
144
|
+
],
|
|
145
|
+
};
|
|
146
|
+
|
|
147
|
+
export default config;
|
|
148
|
+
```
|
|
149
|
+
|
|
150
|
+
#### 工作原理
|
|
151
|
+
|
|
152
|
+
- 读取:插件从您的 `source` 构建器发现 PO 文件并将其作为 Intlayer 字典加载。
|
|
153
|
+
- 写入:构建和填充后,它将本地化的 PO 写回相同的路径(带有正确的 Gettext 头)。
|
|
154
|
+
- 自动填充:插件为每个字典声明一个 `autoFill` 路径。默认情况下,运行 `intlayer fill` 仅更新 PO 文件中缺失的翻译。
|
|
155
|
+
|
|
156
|
+
API:
|
|
157
|
+
|
|
158
|
+
```ts
|
|
159
|
+
syncPO({
|
|
160
|
+
source: ({ key, locale }) => string, // 必填
|
|
161
|
+
location?: string, // 可选标签,默认:"sync-po::path/to/source"
|
|
162
|
+
priority?: number, // 用于冲突解决的可选优先级,默认:0
|
|
163
|
+
});
|
|
164
|
+
```
|
|
165
|
+
|
|
166
|
+
### 多个 PO 源和优先级
|
|
167
|
+
|
|
168
|
+
您可以添加多个 `syncPO` 插件来同步不同的 PO 源。当您的项目中有多个翻译源或不同的 PO 结构时,这很有用。
|
|
169
|
+
|
|
170
|
+
#### 优先级系统
|
|
171
|
+
|
|
172
|
+
当多个插件针对同一个字典键时,`priority` 参数决定哪个插件优先:
|
|
173
|
+
|
|
174
|
+
- 高优先级数字胜过低优先级数字
|
|
175
|
+
- `.content` 文件的默认优先级为 `0`
|
|
176
|
+
- 插件的默认优先级为 `0`
|
|
177
|
+
- 具有相同优先级的插件按照它们在配置中出现的顺序进行处理
|
|
178
|
+
|
|
179
|
+
```ts fileName="intlayer.config.ts"
|
|
180
|
+
import { Locales, type IntlayerConfig } from "intlayer";
|
|
181
|
+
import { syncPO } from "@intlayer/sync-po-plugin";
|
|
182
|
+
|
|
183
|
+
const config: IntlayerConfig = {
|
|
184
|
+
internationalization: {
|
|
185
|
+
locales: [Locales.ENGLISH, Locales.FRENCH],
|
|
186
|
+
defaultLocale: Locales.ENGLISH,
|
|
187
|
+
},
|
|
188
|
+
|
|
189
|
+
plugins: [
|
|
190
|
+
// 主要 PO 源(最高优先级)
|
|
191
|
+
syncPO({
|
|
192
|
+
source: ({ key, locale }) => `./locales/${locale}/${key}.po`,
|
|
193
|
+
location: "main-translations",
|
|
194
|
+
priority: 10,
|
|
195
|
+
}),
|
|
196
|
+
|
|
197
|
+
// 后备 PO 源(较低优先级)
|
|
198
|
+
syncPO({
|
|
199
|
+
source: ({ locale }) => `./fallback-locales/${locale}.po`,
|
|
200
|
+
location: "fallback-translations",
|
|
201
|
+
priority: 5,
|
|
202
|
+
}),
|
|
203
|
+
|
|
204
|
+
// 遗留 PO 源(最低优先级)
|
|
205
|
+
syncPO({
|
|
206
|
+
source: ({ locale }) => `/my/other/app/legacy/${locale}/messages.po`,
|
|
207
|
+
location: "legacy-translations",
|
|
208
|
+
priority: 1,
|
|
209
|
+
}),
|
|
210
|
+
],
|
|
211
|
+
};
|
|
212
|
+
|
|
213
|
+
export default config;
|
|
214
|
+
```
|
|
215
|
+
|
|
216
|
+
## Load PO 插件
|
|
217
|
+
|
|
218
|
+
### 快速开始
|
|
219
|
+
|
|
220
|
+
将插件添加到您的 `intlayer.config.ts` 以将现有的 PO 文件作为 Intlayer 字典摄取。此插件是只读的(不会写入磁盘):
|
|
221
|
+
|
|
222
|
+
```ts fileName="intlayer.config.ts"
|
|
223
|
+
import { Locales, type IntlayerConfig } from "intlayer";
|
|
224
|
+
import { loadPO } from "@intlayer/sync-po-plugin";
|
|
225
|
+
|
|
226
|
+
const config: IntlayerConfig = {
|
|
227
|
+
internationalization: {
|
|
228
|
+
locales: [Locales.ENGLISH, Locales.FRENCH, Locales.SPANISH],
|
|
229
|
+
defaultLocale: Locales.ENGLISH,
|
|
230
|
+
},
|
|
231
|
+
|
|
232
|
+
plugins: [
|
|
233
|
+
// 摄取位于源树中任何位置的 PO 消息
|
|
234
|
+
loadPO({
|
|
235
|
+
source: ({ key }) => `./src/**/${key}.i18n.po`,
|
|
236
|
+
// 每个插件实例加载一个语言(默认为配置的 defaultLocale)
|
|
237
|
+
locale: Locales.ENGLISH,
|
|
238
|
+
priority: 0,
|
|
239
|
+
}),
|
|
240
|
+
],
|
|
241
|
+
};
|
|
242
|
+
|
|
243
|
+
export default config;
|
|
244
|
+
```
|
|
245
|
+
|
|
246
|
+
备选方案:按语言布局,仍然是只读的(仅加载选定的语言):
|
|
247
|
+
|
|
248
|
+
```ts fileName="intlayer.config.ts"
|
|
249
|
+
import { Locales, type IntlayerConfig } from "intlayer";
|
|
250
|
+
import { loadPO } from "@intlayer/sync-po-plugin";
|
|
251
|
+
|
|
252
|
+
const config: IntlayerConfig = {
|
|
253
|
+
internationalization: {
|
|
254
|
+
locales: [Locales.ENGLISH, Locales.FRENCH],
|
|
255
|
+
defaultLocale: Locales.ENGLISH,
|
|
256
|
+
},
|
|
257
|
+
plugins: [
|
|
258
|
+
loadPO({
|
|
259
|
+
// 只有 Locales.FRENCH 的文件将从此模式加载
|
|
260
|
+
source: ({ key, locale }) => `./locales/${locale}/${key}.po`,
|
|
261
|
+
locale: Locales.FRENCH,
|
|
262
|
+
}),
|
|
263
|
+
],
|
|
264
|
+
};
|
|
265
|
+
|
|
266
|
+
export default config;
|
|
267
|
+
```
|
|
268
|
+
|
|
269
|
+
### 工作原理
|
|
270
|
+
|
|
271
|
+
- 发现:从您的 `source` 构建器构建一个 glob 并收集匹配的 PO 文件。
|
|
272
|
+
- 摄取:使用提供的 `locale` 将每个 PO 文件加载为 Intlayer 字典。
|
|
273
|
+
- 只读:不写入或格式化输出文件;如果您需要双向同步,请使用 `syncPO`。
|
|
274
|
+
- 自动填充准备:定义一个 `fill` 路径,以便 `intlayer content fill` 可以填充缺失的键。
|
|
275
|
+
|
|
276
|
+
### API
|
|
277
|
+
|
|
278
|
+
```ts
|
|
279
|
+
loadPO({
|
|
280
|
+
// 构建指向您的 PO 的路径。如果您的结构没有语言段,则 `locale` 是可选的
|
|
281
|
+
source: ({ key, locale }) => string,
|
|
282
|
+
|
|
283
|
+
// 由此插件实例加载的字典的目标语言
|
|
284
|
+
// 默认为 configuration.internationalization.defaultLocale
|
|
285
|
+
locale?: Locale,
|
|
286
|
+
|
|
287
|
+
// 用于识别源的可选标签
|
|
288
|
+
location?: string, // 默认:"plugin"
|
|
289
|
+
|
|
290
|
+
// 用于与其他源进行冲突解决的优先级
|
|
291
|
+
priority?: number, // 默认:0
|
|
292
|
+
});
|
|
293
|
+
```
|
|
294
|
+
|
|
295
|
+
### 行为和约定
|
|
296
|
+
|
|
297
|
+
- 如果您的 `source` 掩码包含语言占位符,则仅摄取所选 `locale` 的文件。
|
|
298
|
+
- 如果掩码中没有 `{key}` 段,则字典键为 "index"。
|
|
299
|
+
- 键通过替换 `source` 构建器中的 `{key}` 占位符从文件路径派生。
|
|
300
|
+
- 插件仅使用发现的文件,不会伪造缺失的语言或键。
|
|
301
|
+
- `fill` 路径从您的 `source` 推导出来,并在您选择启用时用于通过 CLI 更新缺失的值。
|
|
302
|
+
|
|
303
|
+
## 冲突解决
|
|
304
|
+
|
|
305
|
+
当多个 PO 源中存在相同的翻译键时:
|
|
306
|
+
|
|
307
|
+
1. 具有最高优先级的插件决定最终值
|
|
308
|
+
2. 较低优先级的源用作缺失键的后备
|
|
309
|
+
3. 这允许您保留遗留翻译,同时逐步迁移到新结构
|
|
310
|
+
|
|
311
|
+
## CLI
|
|
312
|
+
|
|
313
|
+
同步的 PO 文件将被视为与其他 `.content` 文件相同。这意味着,所有 intlayer 命令都将可用于同步的 PO 文件。包括:
|
|
314
|
+
|
|
315
|
+
- `intlayer content test` 测试是否有缺失的翻译
|
|
316
|
+
- `intlayer content list` 列出同步的 PO 文件
|
|
317
|
+
- `intlayer content fill` 填充缺失的翻译
|
|
318
|
+
- `intlayer content push` 推送同步的 PO 文件
|
|
319
|
+
- `intlayer content pull` 拉取同步的 PO 文件
|
|
320
|
+
|
|
321
|
+
有关更多详细信息,请参阅 [Intlayer CLI](https://github.com/aymericzip/intlayer/blob/main/docs/docs/en/cli/index.md)。
|
|
322
|
+
|
|
323
|
+
## 局限性(当前)
|
|
324
|
+
|
|
325
|
+
- 针对第三方库时不支持插值或复数/ICU。
|
|
326
|
+
- 可视化编辑器尚不适用于非 Intlayer 运行时。
|
|
327
|
+
- 仅限 PO 同步;不支持非 PO 目录格式。
|
|
328
|
+
|
|
329
|
+
## 为什么这很重要
|
|
330
|
+
|
|
331
|
+
- 我们可以推荐成熟的 i18n 解决方案,并将 Intlayer 定位为补充。
|
|
332
|
+
- 我们通过教程利用他们的 SEO/关键词,教程最后建议使用 Intlayer 来管理 PO。
|
|
333
|
+
- 将目标受众从“新项目”扩展到“任何已经在使用 i18n 的团队”。
|
|
@@ -2,7 +2,7 @@
|
|
|
2
2
|
createdAt: 2026-05-07
|
|
3
3
|
updatedAt: 2026-05-07
|
|
4
4
|
title: نوع IntlayerNode. ما هو؟
|
|
5
|
-
description: ما هو نوع IntlayerNode؟ لماذا يتم تحويل سلسلتي النصية إلى IntlayerNode
|
|
5
|
+
description: ما هو نوع IntlayerNode؟ لماذا يتم تحويل سلسلتي النصية إلى IntlayerNode<string>؟
|
|
6
6
|
keywords:
|
|
7
7
|
- مقدمة
|
|
8
8
|
- ابدأ الآن
|
|
@@ -57,7 +57,7 @@ import { useIntlayer } from "react-intlayer";
|
|
|
57
57
|
const AppContent = () => {
|
|
58
58
|
const { title } = useIntlayer("app");
|
|
59
59
|
|
|
60
|
-
return title; // يرجع النوع: IntlayerNode
|
|
60
|
+
return title; // يرجع النوع: IntlayerNode<string>
|
|
61
61
|
};
|
|
62
62
|
```
|
|
63
63
|
|
|
@@ -80,7 +80,7 @@ const AppContent = () => {
|
|
|
80
80
|
const content = useIntlayer("app");
|
|
81
81
|
|
|
82
82
|
// حالة السلسلة النصية (String)
|
|
83
|
-
content.title; // يرجع IntlayerNode
|
|
83
|
+
content.title; // يرجع IntlayerNode<string>
|
|
84
84
|
content.title.value; // يرجع المحتوى الأساسي، هنا سلسلة نصية
|
|
85
85
|
|
|
86
86
|
content.title.toString(); // يرجع سلسلة نصية
|
|
@@ -2,7 +2,7 @@
|
|
|
2
2
|
createdAt: 2026-05-07
|
|
3
3
|
updatedAt: 2026-05-07
|
|
4
4
|
title: IntlayerNode Typ. Was ist das?
|
|
5
|
-
description: Was ist der IntlayerNode-Typ? Warum wird mein String in einen IntlayerNode
|
|
5
|
+
description: Was ist der IntlayerNode-Typ? Warum wird mein String in einen IntlayerNode<string> umgewandelt?
|
|
6
6
|
keywords:
|
|
7
7
|
- Einführung
|
|
8
8
|
- Erste Schritte
|
|
@@ -57,7 +57,7 @@ import { useIntlayer } from "react-intlayer";
|
|
|
57
57
|
const AppContent = () => {
|
|
58
58
|
const { title } = useIntlayer("app");
|
|
59
59
|
|
|
60
|
-
return title; // gibt Typ zurück: IntlayerNode
|
|
60
|
+
return title; // gibt Typ zurück: IntlayerNode<string>
|
|
61
61
|
};
|
|
62
62
|
```
|
|
63
63
|
|
|
@@ -80,7 +80,7 @@ Zum Beispiel:
|
|
|
80
80
|
const content = useIntlayer("app");
|
|
81
81
|
|
|
82
82
|
// Fall von String
|
|
83
|
-
content.title; // Gibt IntlayerNode
|
|
83
|
+
content.title; // Gibt IntlayerNode<string> zurück
|
|
84
84
|
content.title.value; // Gibt den Basisinhalt zurück, hier ein String
|
|
85
85
|
|
|
86
86
|
content.title.toString(); // Gibt String zurück
|
|
@@ -2,7 +2,7 @@
|
|
|
2
2
|
createdAt: 2026-05-07
|
|
3
3
|
updatedAt: 2026-05-07
|
|
4
4
|
title: IntlayerNode type. What is it?
|
|
5
|
-
description: What is it the IntlayerNode type? Why my string is transformed as an IntlayerNode
|
|
5
|
+
description: What is it the IntlayerNode type? Why my string is transformed as an IntlayerNode<string>?
|
|
6
6
|
keywords:
|
|
7
7
|
- Introduction
|
|
8
8
|
- Get started
|
|
@@ -57,7 +57,7 @@ import { useIntlayer } from "react-intlayer";
|
|
|
57
57
|
const AppContent = () => {
|
|
58
58
|
const { title } = useIntlayer("app");
|
|
59
59
|
|
|
60
|
-
return title; // returns type: IntlayerNode
|
|
60
|
+
return title; // returns type: IntlayerNode<string>
|
|
61
61
|
};
|
|
62
62
|
```
|
|
63
63
|
|
|
@@ -80,7 +80,7 @@ For instance:
|
|
|
80
80
|
const content = useIntlayer("app");
|
|
81
81
|
|
|
82
82
|
// Case of String
|
|
83
|
-
content.title; // Returns IntlayerNode
|
|
83
|
+
content.title; // Returns IntlayerNode<string>
|
|
84
84
|
content.title.value; // Returns the base content, here a string
|
|
85
85
|
|
|
86
86
|
content.title.toString(); // Returns string
|
|
@@ -2,7 +2,7 @@
|
|
|
2
2
|
createdAt: 2026-05-07
|
|
3
3
|
updatedAt: 2026-05-07
|
|
4
4
|
title: IntlayerNode type. What is it?
|
|
5
|
-
description: What is it the IntlayerNode type? Why my string is transformed as an IntlayerNode
|
|
5
|
+
description: What is it the IntlayerNode type? Why my string is transformed as an IntlayerNode<string>?
|
|
6
6
|
keywords:
|
|
7
7
|
- Introduction
|
|
8
8
|
- Get started
|
|
@@ -57,7 +57,7 @@ import { useIntlayer } from "react-intlayer";
|
|
|
57
57
|
const AppContent = () => {
|
|
58
58
|
const { title } = useIntlayer("app");
|
|
59
59
|
|
|
60
|
-
return title; // returns type: IntlayerNode
|
|
60
|
+
return title; // returns type: IntlayerNode<string>
|
|
61
61
|
};
|
|
62
62
|
```
|
|
63
63
|
|
|
@@ -80,7 +80,7 @@ For instance:
|
|
|
80
80
|
const content = useIntlayer("app");
|
|
81
81
|
|
|
82
82
|
// Case of String
|
|
83
|
-
content.title; // Returns IntlayerNode
|
|
83
|
+
content.title; // Returns IntlayerNode<string>
|
|
84
84
|
content.title.value; // Returns the base content, here a string
|
|
85
85
|
|
|
86
86
|
content.title.toString(); // Returns string
|
|
@@ -2,7 +2,7 @@
|
|
|
2
2
|
createdAt: 2026-05-07
|
|
3
3
|
updatedAt: 2026-05-07
|
|
4
4
|
title: Tipo IntlayerNode. ¿Qué es?
|
|
5
|
-
description: ¿Qué es el tipo IntlayerNode? ¿Por qué mi cadena se transforma en un IntlayerNode
|
|
5
|
+
description: ¿Qué es el tipo IntlayerNode? ¿Por qué mi cadena se transforma en un IntlayerNode<string>?
|
|
6
6
|
keywords:
|
|
7
7
|
- Introducción
|
|
8
8
|
- Empezar
|
|
@@ -57,7 +57,7 @@ import { useIntlayer } from "react-intlayer";
|
|
|
57
57
|
const AppContent = () => {
|
|
58
58
|
const { title } = useIntlayer("app");
|
|
59
59
|
|
|
60
|
-
return title; // devuelve tipo: IntlayerNode
|
|
60
|
+
return title; // devuelve tipo: IntlayerNode<string>
|
|
61
61
|
};
|
|
62
62
|
```
|
|
63
63
|
|
|
@@ -80,7 +80,7 @@ Por ejemplo:
|
|
|
80
80
|
const content = useIntlayer("app");
|
|
81
81
|
|
|
82
82
|
// Caso de cadena (String)
|
|
83
|
-
content.title; // Devuelve IntlayerNode
|
|
83
|
+
content.title; // Devuelve IntlayerNode<string>
|
|
84
84
|
content.title.value; // Devuelve el contenido base, aquí una cadena
|
|
85
85
|
|
|
86
86
|
content.title.toString(); // Devuelve cadena
|
|
@@ -2,7 +2,7 @@
|
|
|
2
2
|
createdAt: 2026-05-07
|
|
3
3
|
updatedAt: 2026-05-07
|
|
4
4
|
title: Type IntlayerNode. Qu'est-ce que c'est ?
|
|
5
|
-
description: Qu'est-ce que le type IntlayerNode ? Pourquoi ma chaîne est-elle transformée en IntlayerNode
|
|
5
|
+
description: Qu'est-ce que le type IntlayerNode ? Pourquoi ma chaîne est-elle transformée en IntlayerNode<string> ?
|
|
6
6
|
keywords:
|
|
7
7
|
- Introduction
|
|
8
8
|
- Commencer
|
|
@@ -57,7 +57,7 @@ import { useIntlayer } from "react-intlayer";
|
|
|
57
57
|
const AppContent = () => {
|
|
58
58
|
const { title } = useIntlayer("app");
|
|
59
59
|
|
|
60
|
-
return title; // retourne le type : IntlayerNode
|
|
60
|
+
return title; // retourne le type : IntlayerNode<string>
|
|
61
61
|
};
|
|
62
62
|
```
|
|
63
63
|
|
|
@@ -80,7 +80,7 @@ Par exemple :
|
|
|
80
80
|
const content = useIntlayer("app");
|
|
81
81
|
|
|
82
82
|
// Cas d'une chaîne (String)
|
|
83
|
-
content.title; // Retourne IntlayerNode
|
|
83
|
+
content.title; // Retourne IntlayerNode<string>
|
|
84
84
|
content.title.value; // Retourne le contenu de base, ici une chaîne
|
|
85
85
|
|
|
86
86
|
content.title.toString(); // Retourne une chaîne
|
|
@@ -2,7 +2,7 @@
|
|
|
2
2
|
createdAt: 2026-05-07
|
|
3
3
|
updatedAt: 2026-05-07
|
|
4
4
|
title: IntlayerNode प्रकार। यह क्या है?
|
|
5
|
-
description: IntlayerNode प्रकार क्या है? मेरी स्ट्रिंग IntlayerNode
|
|
5
|
+
description: IntlayerNode प्रकार क्या है? मेरी स्ट्रिंग IntlayerNode<string> में क्यों बदल गई है?
|
|
6
6
|
keywords:
|
|
7
7
|
- परिचय
|
|
8
8
|
- शुरू करें
|
|
@@ -57,7 +57,7 @@ import { useIntlayer } from "react-intlayer";
|
|
|
57
57
|
const AppContent = () => {
|
|
58
58
|
const { title } = useIntlayer("app");
|
|
59
59
|
|
|
60
|
-
return title; // प्रकार लौटाता है: IntlayerNode
|
|
60
|
+
return title; // प्रकार लौटाता है: IntlayerNode<string>
|
|
61
61
|
};
|
|
62
62
|
```
|
|
63
63
|
|
|
@@ -80,7 +80,7 @@ Intlayer CMS / विजुअल एडिटर के संदर्भ म
|
|
|
80
80
|
const content = useIntlayer("app");
|
|
81
81
|
|
|
82
82
|
// स्ट्रिंग का मामला
|
|
83
|
-
content.title; // IntlayerNode
|
|
83
|
+
content.title; // IntlayerNode<string> लौटाता है
|
|
84
84
|
content.title.value; // बेस कंटेंट लौटाता है, यहाँ एक स्ट्रिंग
|
|
85
85
|
|
|
86
86
|
content.title.toString(); // स्ट्रिंग लौटाता है
|
|
@@ -2,7 +2,7 @@
|
|
|
2
2
|
createdAt: 2026-05-07
|
|
3
3
|
updatedAt: 2026-05-07
|
|
4
4
|
title: Tipe IntlayerNode. Apa itu?
|
|
5
|
-
description: Apa itu tipe IntlayerNode? Mengapa string saya diubah menjadi IntlayerNode
|
|
5
|
+
description: Apa itu tipe IntlayerNode? Mengapa string saya diubah menjadi IntlayerNode<string>?
|
|
6
6
|
keywords:
|
|
7
7
|
- Pendahuluan
|
|
8
8
|
- Memulai
|
|
@@ -57,7 +57,7 @@ import { useIntlayer } from "react-intlayer";
|
|
|
57
57
|
const AppContent = () => {
|
|
58
58
|
const { title } = useIntlayer("app");
|
|
59
59
|
|
|
60
|
-
return title; // mengembalikan tipe: IntlayerNode
|
|
60
|
+
return title; // mengembalikan tipe: IntlayerNode<string>
|
|
61
61
|
};
|
|
62
62
|
```
|
|
63
63
|
|
|
@@ -80,7 +80,7 @@ Sebagai contoh:
|
|
|
80
80
|
const content = useIntlayer("app");
|
|
81
81
|
|
|
82
82
|
// Kasus String
|
|
83
|
-
content.title; // Mengembalikan IntlayerNode
|
|
83
|
+
content.title; // Mengembalikan IntlayerNode<string>
|
|
84
84
|
content.title.value; // Mengembalikan konten dasar, dalam hal ini sebuah string
|
|
85
85
|
|
|
86
86
|
content.title.toString(); // Mengembalikan string
|