@arronqzy/i18n 0.1.14 → 0.1.16
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/README.md +28 -6
- package/package.json +1 -1
- package/src/locales/en-US.ts +74 -8
- package/src/locales/zh-CN.ts +71 -8
- package/src/react/I18nProvider.tsx +19 -0
- package/src/react/index.ts +1 -1
package/README.md
CHANGED
|
@@ -1,6 +1,8 @@
|
|
|
1
1
|
# @arronqzy/i18n
|
|
2
2
|
|
|
3
|
-
Abuilder
|
|
3
|
+
Abuilder 的中英文案,React 和 Vue 共用同一套 key。默认 `zh-CN`,也可切到 `en-US`。
|
|
4
|
+
|
|
5
|
+
编辑器里的「设置 → 语言」写的是 `localStorage` key `abuilder.locale`。面板、物料名、蓝图节点、配置提示都走这里,不要在视图包里再写一份硬编码中文。
|
|
4
6
|
|
|
5
7
|
## 安装
|
|
6
8
|
|
|
@@ -8,6 +10,8 @@ Abuilder 共享国际化包,默认支持 **zh-CN** / **en-US**,可同时用
|
|
|
8
10
|
pnpm add @arronqzy/i18n
|
|
9
11
|
```
|
|
10
12
|
|
|
13
|
+
React 和 Vue 都是 optional peer。只用一端时不必装另一端。
|
|
14
|
+
|
|
11
15
|
## React
|
|
12
16
|
|
|
13
17
|
```tsx
|
|
@@ -21,22 +25,40 @@ const { t, locale, setLocale } = useI18n();
|
|
|
21
25
|
t("panel.menubar.file");
|
|
22
26
|
```
|
|
23
27
|
|
|
28
|
+
`useI18n()` 必须在 **同一份包实例** 的 `I18nProvider` 下面。Umi / pnpm 有时会打出两份 `@arronqzy/i18n`,面板的 Provider 和蓝图的 hook 对不上,就会报 `useI18n must be used within I18nProvider`。
|
|
29
|
+
|
|
30
|
+
处理方式:
|
|
31
|
+
|
|
32
|
+
- 库代码用 `useI18nOptional()`:没有 Provider 时回退中文,不抛错。
|
|
33
|
+
- 入口用 `EnsureI18nProvider`:本包实例上方没有 Provider 时自己包一层。
|
|
34
|
+
- 宿主用 `overrides` / `resolutions` 把 `@arronqzy/i18n` 收成一份,语言切换才能两端同步。
|
|
35
|
+
|
|
36
|
+
```tsx
|
|
37
|
+
import { EnsureI18nProvider, useI18nOptional } from "@arronqzy/i18n/react";
|
|
38
|
+
```
|
|
39
|
+
|
|
24
40
|
## Vue
|
|
25
41
|
|
|
26
42
|
```ts
|
|
27
43
|
import { abuilderI18n, useI18n, provideI18n } from "@arronqzy/i18n/vue";
|
|
28
44
|
|
|
29
45
|
app.use(abuilderI18n, { locale: "en-US" });
|
|
30
|
-
//
|
|
46
|
+
// 或在 setup 里 provideI18n({ locale: "zh-CN" })
|
|
47
|
+
|
|
48
|
+
const { t, locale, setLocale } = useI18n();
|
|
31
49
|
```
|
|
32
50
|
|
|
33
|
-
|
|
51
|
+
没有 `provide` 时 `useI18n()` 会抛错。`useI18nOptional()` 回退到中文。
|
|
52
|
+
|
|
53
|
+
## 语言怎么定
|
|
34
54
|
|
|
35
|
-
1. 显式 `locale`
|
|
36
|
-
2. `localStorage`(默认 key
|
|
37
|
-
3. 浏览器语言(`zh*` → zh-CN
|
|
55
|
+
1. 显式 `locale`
|
|
56
|
+
2. `localStorage`(默认 key `abuilder.locale`)
|
|
57
|
+
3. 浏览器语言(`zh*` → `zh-CN`,否则 `en-US`)
|
|
38
58
|
4. 回退 `zh-CN`
|
|
39
59
|
|
|
60
|
+
文案在 `src/locales/zh-CN.ts` 和 `en-US.ts`。加 key 时两份一起加,缺的 key 会显示 key 本身。
|
|
61
|
+
|
|
40
62
|
## 许可证
|
|
41
63
|
|
|
42
64
|
MIT
|
package/package.json
CHANGED
package/src/locales/en-US.ts
CHANGED
|
@@ -111,6 +111,7 @@ export const enUS = {
|
|
|
111
111
|
importPanelJson: "Import panel JSON",
|
|
112
112
|
exportBlueprint: "Export blueprint",
|
|
113
113
|
importBlueprint: "Import blueprint",
|
|
114
|
+
apiCollections: "API collections",
|
|
114
115
|
undo: "Undo",
|
|
115
116
|
redo: "Redo",
|
|
116
117
|
bringForward: "Bring forward",
|
|
@@ -1163,8 +1164,12 @@ export const enUS = {
|
|
|
1163
1164
|
updated: "Updated",
|
|
1164
1165
|
expand: "Expand scope",
|
|
1165
1166
|
collapse: "Collapse scope",
|
|
1166
|
-
usageHint1:
|
|
1167
|
-
|
|
1167
|
+
usageHint1:
|
|
1168
|
+
"Use template strings in forms. scope is data passed between blueprint nodes, e.g. {scope?.a||0}, {scope?.name||''}. system is built-in tools/vars: {system?.time} (dayjs now), {system?.math} (Math), {system?.location} (Location). They nest together, e.g. startTime:{system?.time?.subtract(scope?.value?.days||7,'d')}. Supports ?. and ||.",
|
|
1169
|
+
usageHint2:
|
|
1170
|
+
"Array-spread templates [...{scope?.a?.b}], [...{scope?.data?.data?.statusName}]: comma-separated strings in text fields; expand to n items in chart categories. system is for expression tools, not array spread.",
|
|
1171
|
+
usageHintSystem:
|
|
1172
|
+
"scope vs system: scope is workflow payload data; system is a toolbox (time / math / location). Example: {system?.time?.subtract(system?.math?.random(),'d')}. Mix with scope freely.",
|
|
1168
1173
|
previewTitle: "Resolved preview",
|
|
1169
1174
|
previewArray: "Array · {count} item(s)",
|
|
1170
1175
|
expandPreview: "Expand",
|
|
@@ -1296,6 +1301,33 @@ export const enUS = {
|
|
|
1296
1301
|
deleteNode: "Delete node",
|
|
1297
1302
|
deleteEdge: "Delete edge",
|
|
1298
1303
|
},
|
|
1304
|
+
apiCollection: {
|
|
1305
|
+
managerTitle: "API collections",
|
|
1306
|
+
managerDescription:
|
|
1307
|
+
"Upload local JSON API collections for Fetch nodes when Swagger URLs are blocked by CORS. Choose whether to persist to IndexedDB. String values in url / params / headers / body / baseUrl support {scope?...} templates.",
|
|
1308
|
+
upload: "Upload JSON",
|
|
1309
|
+
create: "Create / paste",
|
|
1310
|
+
downloadTemplate: "Download template",
|
|
1311
|
+
persistLocal: "Persist to IndexedDB",
|
|
1312
|
+
persistLocalHint: "If off, collections stay in memory only and are lost on refresh.",
|
|
1313
|
+
empty: "No collections yet. Download the template, edit it, then upload.",
|
|
1314
|
+
apiCount: "{count} APIs",
|
|
1315
|
+
persisted: "Persisted",
|
|
1316
|
+
memoryOnly: "Memory only",
|
|
1317
|
+
confirmDelete: "Delete this API collection?",
|
|
1318
|
+
sync: "Sync",
|
|
1319
|
+
syncHint:
|
|
1320
|
+
"Match Fetch nodes in the current blueprint by URL (query ignored) and refill method, headers, body, and params. Nodes with unmatched URLs are left unchanged.",
|
|
1321
|
+
syncSuccess: "Updated {count} blueprint node(s)",
|
|
1322
|
+
syncSuccessDetail: "Synced {count} node(s): {names}",
|
|
1323
|
+
syncNone: "No Fetch nodes matched by URL",
|
|
1324
|
+
syncUnavailable: "This panel cannot sync blueprint nodes",
|
|
1325
|
+
editTitle: "Edit API collection",
|
|
1326
|
+
createTitle: "Create API collection",
|
|
1327
|
+
editorDescription:
|
|
1328
|
+
"Edit JSON using the template shape. It is validated before save. String fields (url, params values, headers values, body, baseUrl) may use {scope?...} and resolve from upstream Scope at runtime.",
|
|
1329
|
+
jsonEditor: "JSON",
|
|
1330
|
+
},
|
|
1299
1331
|
dialog: {
|
|
1300
1332
|
renameTitle: "Rename blueprint",
|
|
1301
1333
|
renameDescription: "Change the display name of this library item.",
|
|
@@ -1437,11 +1469,13 @@ export const enUS = {
|
|
|
1437
1469
|
taskChain: "Task chain",
|
|
1438
1470
|
allowFalsePropagateDefault: "Allow false-signal propagation: by default false blocks the chain; when on, false signals and errors continue downstream.",
|
|
1439
1471
|
fetchTitle: "Fetch",
|
|
1440
|
-
fetchHint:
|
|
1472
|
+
fetchHint:
|
|
1473
|
+
"On a true signal, send an HTTP request. URL / headers / body / Base URL can use {scope?...} for upstream data, and {system?.time} / {system?.math} / {system?.location} for system vars.",
|
|
1441
1474
|
fetchScopeTitle: "Upstream scope",
|
|
1442
1475
|
fetchScopeHint:
|
|
1443
|
-
"One upstream node: {scope?.value}, {scope?.id}, {scope?.name}, {scope?.type}. Multiple upstream nodes are keyed by node id, e.g. {scope?.node_abc?.value}. value is the output; other fields are node details. Header templates can live in JSON string values, or the whole field can be {scope?.value?.headers}.",
|
|
1444
|
-
fetchScopeEmpty:
|
|
1476
|
+
"One upstream node: {scope?.value}, {scope?.id}, {scope?.name}, {scope?.type}. Multiple upstream nodes are keyed by node id, e.g. {scope?.node_abc?.value}. value is the output; other fields are node details. Also {system?.time?.subtract(7,'d')} and nesting with scope. Header templates can live in JSON string values, or the whole field can be {scope?.value?.headers}.",
|
|
1477
|
+
fetchScopeEmpty:
|
|
1478
|
+
"No upstream edges yet. {system?...} still works; connect a node to use scope templates for its output and details.",
|
|
1445
1479
|
fetchScopePending: "Upstream has not run yet, so value is empty; id / name / type are already available.",
|
|
1446
1480
|
fetchScopeResolvedUrl: "Resolved URL",
|
|
1447
1481
|
fetchScopeResolvedHeaders: "Resolved headers",
|
|
@@ -1479,6 +1513,33 @@ export const enUS = {
|
|
|
1479
1513
|
fillSwaggerUrlFirst: "Enter a Swagger document URL first",
|
|
1480
1514
|
fillRequestUrlFirst: "Enter a request URL first",
|
|
1481
1515
|
noMatchingEndpoint: "No matching endpoints",
|
|
1516
|
+
fetchSourceMode: "Config source",
|
|
1517
|
+
fetchSourceDirect: "Manual / Swagger",
|
|
1518
|
+
fetchSourceCollection: "API collection",
|
|
1519
|
+
fetchSourceDirectHint:
|
|
1520
|
+
"Parse endpoints from a Swagger URL, or type the request URL manually. Cross-origin docs may fail to load.",
|
|
1521
|
+
fetchSourceCollectionHint:
|
|
1522
|
+
"Pick a collection and API uploaded under Blueprint → API collections. URL, method, headers, and body are filled in. Collection string values support {scope?...}; hover the API name to see its description.",
|
|
1523
|
+
apiCollectionSelect: "API collection",
|
|
1524
|
+
apiCollectionSelectPlaceholder: "Select an uploaded collection",
|
|
1525
|
+
apiCollectionEmpty: "No collections yet — upload from the Blueprint menu",
|
|
1526
|
+
apiCollectionEndpoint: "API name",
|
|
1527
|
+
apiCollectionEndpointPlaceholder: "Select an API",
|
|
1528
|
+
apiCollectionNoEndpoints: "This collection has no APIs",
|
|
1529
|
+
apiCollectionFilledHint:
|
|
1530
|
+
"Selecting an API fills the form below; you can still edit fields. Hover the API name to see its description.",
|
|
1531
|
+
apiCollectionSyncUpdatedTitle: "Updated",
|
|
1532
|
+
apiCollectionSyncUpdatedSource: "Source: API collection sync",
|
|
1533
|
+
apiCollectionSyncUpdatedCollection: "Collection “{collection}” · API “{endpoint}”",
|
|
1534
|
+
apiCollectionSyncUpdatedFields: "Changed: {fields}",
|
|
1535
|
+
apiCollectionSyncUpdatedNoFieldChange: "Changed: aligned with collection (no field diff)",
|
|
1536
|
+
apiCollectionSyncField: {
|
|
1537
|
+
url: "Request URL",
|
|
1538
|
+
method: "Method",
|
|
1539
|
+
headers: "Headers",
|
|
1540
|
+
body: "Body",
|
|
1541
|
+
apiBaseUrl: "API host / Base URL",
|
|
1542
|
+
},
|
|
1482
1543
|
swaggerParseFailed: "Failed to parse Swagger document",
|
|
1483
1544
|
enterSwaggerUrl: "Enter a Swagger document URL",
|
|
1484
1545
|
cannotFetchSwagger: "Cannot fetch Swagger document",
|
|
@@ -1486,12 +1547,17 @@ export const enUS = {
|
|
|
1486
1547
|
swaggerHtmlReturned: "Response is HTML; provide an OpenAPI/Swagger JSON URL",
|
|
1487
1548
|
swaggerInvalidJson: "Swagger document is not valid JSON",
|
|
1488
1549
|
jsonTitle: "JSON node",
|
|
1489
|
-
jsonHint:
|
|
1490
|
-
|
|
1491
|
-
|
|
1550
|
+
jsonHint:
|
|
1551
|
+
"On a true signal, parse the JSON below into an object/array and emit true. Supports {scope?...} / {system?...} templates resolved at runtime. On parse failure emit false. Invalid spots are highlighted in red (e.g. curly quotes “”).",
|
|
1552
|
+
jsonScopeHint:
|
|
1553
|
+
"Write {scope?.value} / {system?.time} anywhere in the JSON; inside strings it is escaped, in value position it becomes a JSON literal. Use ASCII double quotes \", not curly “”.",
|
|
1554
|
+
jsonScopeDeferred: "Contains scope/system templates; validated after runtime resolution",
|
|
1492
1555
|
jsonContent: "JSON content",
|
|
1493
1556
|
jsonFormatError: "Invalid JSON: {error}",
|
|
1494
1557
|
jsonFormatOk: "JSON is valid",
|
|
1558
|
+
jsonErrorPreviewHint:
|
|
1559
|
+
"Red highlights below mark problem spots (edit in the box above)",
|
|
1560
|
+
jsonJumpToError: "Jump to error",
|
|
1495
1561
|
storageTitle: "Storage node",
|
|
1496
1562
|
storageHint: "On a true signal, write first then read. Skip write if set is empty; output empty if read is empty. When both are configured, set runs before read.",
|
|
1497
1563
|
storageReadTitle: "Read",
|
package/src/locales/zh-CN.ts
CHANGED
|
@@ -110,6 +110,7 @@ export const zhCN = {
|
|
|
110
110
|
importPanelJson: "导入面板 JSON",
|
|
111
111
|
exportBlueprint: "导出蓝图",
|
|
112
112
|
importBlueprint: "导入蓝图",
|
|
113
|
+
apiCollections: "接口集合",
|
|
113
114
|
undo: "撤销",
|
|
114
115
|
redo: "重做",
|
|
115
116
|
bringForward: "上移一层",
|
|
@@ -1159,8 +1160,12 @@ export const zhCN = {
|
|
|
1159
1160
|
updated: "已更新",
|
|
1160
1161
|
expand: "展开 Scope",
|
|
1161
1162
|
collapse: "收起 Scope",
|
|
1162
|
-
usageHint1:
|
|
1163
|
-
|
|
1163
|
+
usageHint1:
|
|
1164
|
+
"表单中可使用模版字符串。scope 是蓝图流程里节点互相传递的数据,例如 {scope?.a||0}、{scope?.name||''}。system 是系统内置工具与变量:{system?.time}(dayjs 当前时间)、{system?.math}(Math)、{system?.location}(Location)。二者可互相嵌套,例如 startTime:{system?.time?.subtract(scope?.value?.days||7,'d')}。支持 ?. 与 || 占位。",
|
|
1165
|
+
usageHint2:
|
|
1166
|
+
"数组展开模版 [...{scope?.a?.b}]、[...{scope?.data?.data?.statusName}]:在文本字段输出逗号分隔字符串;在图表「类目」等数组字段会展开为 n 个独立项(如 3 条数据对应 3 个类目)。system 不用于数组展开,只作表达式工具。",
|
|
1167
|
+
usageHintSystem:
|
|
1168
|
+
"system 与 scope 区别:scope 像流程里的业务数据包;system 像全局工具箱(time / math / location)。可写 {system?.time?.subtract(system?.math?.random(),'d')},也可与 scope 混用。",
|
|
1164
1169
|
previewTitle: "解析预览",
|
|
1165
1170
|
previewArray: "数组 · {count} 项",
|
|
1166
1171
|
expandPreview: "展开",
|
|
@@ -1292,6 +1297,33 @@ export const zhCN = {
|
|
|
1292
1297
|
deleteNode: "删除节点",
|
|
1293
1298
|
deleteEdge: "删除连线",
|
|
1294
1299
|
},
|
|
1300
|
+
apiCollection: {
|
|
1301
|
+
managerTitle: "接口集合",
|
|
1302
|
+
managerDescription:
|
|
1303
|
+
"上传本地 JSON 接口集合,供数据获取节点在跨域无法拉取 Swagger 时选用。可勾选是否写入 IndexedDB。url / params / headers / body / baseUrl 的字符串值均支持 {scope?...} 模版。",
|
|
1304
|
+
upload: "上传 JSON",
|
|
1305
|
+
create: "新建 / 粘贴",
|
|
1306
|
+
downloadTemplate: "下载模版",
|
|
1307
|
+
persistLocal: "本地化保存到 IndexedDB",
|
|
1308
|
+
persistLocalHint: "关闭后仅保存在当前会话内存,刷新页面会丢失。",
|
|
1309
|
+
empty: "还没有接口集合。可下载模版编辑后再上传。",
|
|
1310
|
+
apiCount: "{count} 个接口",
|
|
1311
|
+
persisted: "已本地化",
|
|
1312
|
+
memoryOnly: "仅内存",
|
|
1313
|
+
confirmDelete: "确定删除该接口集合?",
|
|
1314
|
+
sync: "同步",
|
|
1315
|
+
syncHint:
|
|
1316
|
+
"按 URL(忽略查询参数)匹配当前蓝图中的数据获取节点,回填方法、请求头、请求体与参数;URL 对不上的节点不会改。",
|
|
1317
|
+
syncSuccess: "已同步更新 {count} 个蓝图节点",
|
|
1318
|
+
syncSuccessDetail: "已同步 {count} 个节点:{names}",
|
|
1319
|
+
syncNone: "没有找到 URL 匹配的数据获取节点",
|
|
1320
|
+
syncUnavailable: "当前面板无法同步蓝图节点",
|
|
1321
|
+
editTitle: "编辑接口集合",
|
|
1322
|
+
createTitle: "新建接口集合",
|
|
1323
|
+
editorDescription:
|
|
1324
|
+
"请按模版结构编辑 JSON,保存前会校验类型。字符串字段(url、params 值、headers 值、body、baseUrl)可写 {scope?...},运行时按上游 Scope 解析。",
|
|
1325
|
+
jsonEditor: "JSON 内容",
|
|
1326
|
+
},
|
|
1295
1327
|
dialog: {
|
|
1296
1328
|
renameTitle: "重命名蓝图",
|
|
1297
1329
|
renameDescription: "修改蓝图库中该项的显示名称。",
|
|
@@ -1433,11 +1465,13 @@ export const zhCN = {
|
|
|
1433
1465
|
taskChain: "任务链执行",
|
|
1434
1466
|
allowFalsePropagateDefault: "允许假信号传递:默认假信号会阻塞任务链;开启后继续向下游传递假信号与错误信息。",
|
|
1435
1467
|
fetchTitle: "数据源获取 (Fetch)",
|
|
1436
|
-
fetchHint:
|
|
1468
|
+
fetchHint:
|
|
1469
|
+
"收到真信号后发起 HTTP 请求。URL / 请求头 / 请求体 / Base URL 可用 {scope?...} 引用上游数据,也可用 {system?.time} / {system?.math} / {system?.location} 等系统变量。",
|
|
1437
1470
|
fetchScopeTitle: "上游输入 Scope",
|
|
1438
1471
|
fetchScopeHint:
|
|
1439
|
-
"单路上游:{scope?.value}、{scope?.id}、{scope?.name}、{scope?.type}。多路上游按节点 id 取值,例如 {scope?.node_abc?.value}。value
|
|
1440
|
-
fetchScopeEmpty:
|
|
1472
|
+
"单路上游:{scope?.value}、{scope?.id}、{scope?.name}、{scope?.type}。多路上游按节点 id 取值,例如 {scope?.node_abc?.value}。value 为上游输出,其余为节点详情。另可用 {system?.time?.subtract(7,'d')} 等系统模版,并可与 scope 嵌套。请求头可把模板写在 JSON 字符串值内,也可整段写成 {scope?.value?.headers}。",
|
|
1473
|
+
fetchScopeEmpty:
|
|
1474
|
+
"暂无上游连线。无 scope 时仍可用 {system?...};连接上游后可用 scope 模板引用其输出与节点信息。",
|
|
1441
1475
|
fetchScopePending: "上游尚未执行,value 暂空;id / name / type 已可引用。",
|
|
1442
1476
|
fetchScopeResolvedUrl: "解析后的 URL",
|
|
1443
1477
|
fetchScopeResolvedHeaders: "解析后的请求头",
|
|
@@ -1475,6 +1509,31 @@ export const zhCN = {
|
|
|
1475
1509
|
fillSwaggerUrlFirst: "请先填写 Swagger 文档 URL",
|
|
1476
1510
|
fillRequestUrlFirst: "请先填写请求 URL",
|
|
1477
1511
|
noMatchingEndpoint: "无匹配接口",
|
|
1512
|
+
fetchSourceMode: "配置来源",
|
|
1513
|
+
fetchSourceDirect: "手动 / Swagger",
|
|
1514
|
+
fetchSourceCollection: "接口集合",
|
|
1515
|
+
fetchSourceDirectHint: "填写 Swagger 文档地址解析接口,或手动输入请求 URL。跨域时文档地址可能无法请求。",
|
|
1516
|
+
fetchSourceCollectionHint:
|
|
1517
|
+
"从顶栏「蓝图 → 接口集合」上传的 JSON 中选择集合与接口,自动回填 URL / 方法 / 请求头 / 请求体。集合内字符串值支持 {scope?...};悬停接口名称可查看 description。",
|
|
1518
|
+
apiCollectionSelect: "接口集合",
|
|
1519
|
+
apiCollectionSelectPlaceholder: "选择已上传的集合",
|
|
1520
|
+
apiCollectionEmpty: "暂无集合,请先在蓝图菜单上传",
|
|
1521
|
+
apiCollectionEndpoint: "接口名称",
|
|
1522
|
+
apiCollectionEndpointPlaceholder: "选择接口",
|
|
1523
|
+
apiCollectionNoEndpoints: "该集合没有接口",
|
|
1524
|
+
apiCollectionFilledHint: "选中接口后会回填下方表单,仍可继续修改。悬停接口名称可查看接口说明。",
|
|
1525
|
+
apiCollectionSyncUpdatedTitle: "已更新",
|
|
1526
|
+
apiCollectionSyncUpdatedSource: "更新来源:数据集合更新",
|
|
1527
|
+
apiCollectionSyncUpdatedCollection: "集合「{collection}」· 接口「{endpoint}」",
|
|
1528
|
+
apiCollectionSyncUpdatedFields: "更新内容:{fields}",
|
|
1529
|
+
apiCollectionSyncUpdatedNoFieldChange: "更新内容:与集合对齐(字段无变化)",
|
|
1530
|
+
apiCollectionSyncField: {
|
|
1531
|
+
url: "请求 URL",
|
|
1532
|
+
method: "请求方法",
|
|
1533
|
+
headers: "请求头",
|
|
1534
|
+
body: "请求体",
|
|
1535
|
+
apiBaseUrl: "API 主机 / Base URL",
|
|
1536
|
+
},
|
|
1478
1537
|
swaggerParseFailed: "Swagger 文档解析失败",
|
|
1479
1538
|
enterSwaggerUrl: "请输入 Swagger 文档 URL",
|
|
1480
1539
|
cannotFetchSwagger: "无法请求 Swagger 文档",
|
|
@@ -1482,12 +1541,16 @@ export const zhCN = {
|
|
|
1482
1541
|
swaggerHtmlReturned: "返回内容为 HTML,请填写 OpenAPI/Swagger 的 JSON 地址",
|
|
1483
1542
|
swaggerInvalidJson: "Swagger 文档不是有效的 JSON",
|
|
1484
1543
|
jsonTitle: "JSON 节点",
|
|
1485
|
-
jsonHint:
|
|
1486
|
-
|
|
1487
|
-
|
|
1544
|
+
jsonHint:
|
|
1545
|
+
"收到真信号后,将下方 JSON 解析为 object/array 并发出真信号;支持 {scope?...} / {system?...} 模板(运行时替换)。解析失败则发出假信号。不合规处会在编辑器内标红(如误用中文引号 “”)。",
|
|
1546
|
+
jsonScopeHint:
|
|
1547
|
+
"可在 JSON 任意位置写 {scope?.value} / {system?.time};位于字符串内会转义,位于值位置会写入 JSON 字面量。请使用英文双引号 \",避免中文 “”。",
|
|
1548
|
+
jsonScopeDeferred: "含 scope/system 模板,将在运行时解析后校验",
|
|
1488
1549
|
jsonContent: "JSON 内容",
|
|
1489
1550
|
jsonFormatError: "JSON 格式错误:{error}",
|
|
1490
1551
|
jsonFormatOk: "JSON 格式正确",
|
|
1552
|
+
jsonErrorPreviewHint: "下方预览标红为异常位置(编辑请用上方输入框)",
|
|
1553
|
+
jsonJumpToError: "定位到错误",
|
|
1491
1554
|
storageTitle: "存储节点",
|
|
1492
1555
|
storageHint: "收到真信号后先写入再读取。不配置设置则不写入;不配置读取则输出空。设置与读取同时配置时按「先设置、后读取」执行。",
|
|
1493
1556
|
storageReadTitle: "读取",
|
|
@@ -81,6 +81,25 @@ export function useI18n(): I18nContextValue {
|
|
|
81
81
|
return ctx;
|
|
82
82
|
}
|
|
83
83
|
|
|
84
|
+
/** Whether the nearest I18nProvider from *this* package instance is present. */
|
|
85
|
+
export function useHasI18nProvider(): boolean {
|
|
86
|
+
return useContext(I18nContext) != null;
|
|
87
|
+
}
|
|
88
|
+
|
|
89
|
+
/**
|
|
90
|
+
* If no I18nProvider from this package is above, wrap children with one.
|
|
91
|
+
* Fixes Umi/npm duplicate-`@arronqzy/i18n` cases where the panel Provider
|
|
92
|
+
* comes from a different copy than react-blueprint's `useI18n`.
|
|
93
|
+
*/
|
|
94
|
+
export function EnsureI18nProvider({
|
|
95
|
+
children,
|
|
96
|
+
...providerProps
|
|
97
|
+
}: I18nProviderProps) {
|
|
98
|
+
const hasProvider = useHasI18nProvider();
|
|
99
|
+
if (hasProvider) return <>{children}</>;
|
|
100
|
+
return <I18nProvider {...providerProps}>{children}</I18nProvider>;
|
|
101
|
+
}
|
|
102
|
+
|
|
84
103
|
/** Safe hook: returns zh-CN translator when outside provider (for utilities). */
|
|
85
104
|
export function useI18nOptional(): I18nContextValue {
|
|
86
105
|
const ctx = useContext(I18nContext);
|
package/src/react/index.ts
CHANGED
|
@@ -1,2 +1,2 @@
|
|
|
1
|
-
export { I18nProvider, useI18n, useI18nOptional } from "./I18nProvider";
|
|
1
|
+
export { I18nProvider, EnsureI18nProvider, useI18n, useI18nOptional, useHasI18nProvider } from "./I18nProvider";
|
|
2
2
|
export type { I18nContextValue, I18nProviderProps } from "./I18nProvider";
|