@open-document/core 0.9.1 → 0.10.0
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/{build-B0GJXy8I.js → build-DJMLK50m.js} +1 -1
- package/dist/{check-CuDIWsPT.js → check-CUKuufBm.js} +3 -3
- package/dist/cli/bin.js +10 -6
- package/dist/{config-CAZ7Z_va.js → config-CvzpyAUA.js} +558 -546
- package/dist/{context-PWAh9qbf.js → context-B4ip7SoI.js} +1 -1
- package/dist/{dev-CYqppXDI.js → dev-dnH7DTlD.js} +1 -1
- package/dist/{diagram-CCaUUnRe.js → diagram-BK4jTZr4.js} +146 -146
- package/dist/diff-QTo0A5Rx.js +44 -0
- package/dist/{export-1JtO2OMC.js → export-BrRFrexj.js} +3 -3
- package/dist/{import-CsrdBOZ8.js → import-C14Vn9ER.js} +2 -2
- package/dist/index.d.ts +53 -2
- package/dist/index.js +457 -18
- package/dist/ops/index.d.ts +72 -17
- package/dist/ops/index.js +3 -3
- package/dist/{ops-B2y9BMpk.js → ops-DKidjLXP.js} +642 -124
- package/dist/{preview-DW3PM-JV.js → preview-wKM4C6Uk.js} +1 -1
- package/dist/{sdk-BqU6mwD_.d.ts → sdk-CpDEGRIo.d.ts} +2 -0
- package/dist/vite/index.js +1 -1
- package/package.json +2 -2
- package/skills/doc-authoring/SKILL.md +9 -4
- package/skills/doc-authoring/references/pagination.md +1 -1
- package/skills/doc-authoring/references/tables-and-charts.md +18 -1
- package/src/app/components/browser/browser-ui.tsx +105 -0
- package/src/app/components/chart.tsx +239 -0
- package/src/app/components/command-palette.tsx +284 -0
- package/src/app/components/design-panel/design-panel.tsx +22 -20
- package/src/app/components/design-panel/design-provider.tsx +4 -2
- package/src/app/components/diagram.tsx +11 -1
- package/src/app/components/doc-assets.tsx +6 -5
- package/src/app/components/doc-search.tsx +12 -10
- package/src/app/components/doc-sidebar.tsx +24 -18
- package/src/app/components/flow-page.tsx +2 -0
- package/src/app/components/inspector/inspector.tsx +75 -48
- package/src/app/components/language-toggle.tsx +38 -0
- package/src/app/components/palette-items.ts +128 -0
- package/src/app/components/panel/edit-save-card.tsx +4 -2
- package/src/app/components/panel/fields.tsx +5 -2
- package/src/app/components/panel/save-card.tsx +18 -10
- package/src/app/components/sidebar/folder-item.tsx +10 -8
- package/src/app/components/sidebar/icon-picker.tsx +3 -1
- package/src/app/components/sidebar/sidebar.tsx +44 -13
- package/src/app/components/theme-toggle.tsx +5 -3
- package/src/app/components/ui/menu.tsx +5 -0
- package/src/app/lib/agent-bridge.ts +8 -2
- package/src/app/lib/chart.test.ts +108 -0
- package/src/app/lib/chart.ts +343 -0
- package/src/app/lib/doc-preview.tsx +0 -10
- package/src/app/lib/docs.ts +3 -0
- package/src/app/lib/docx/from-dom.ts +11 -11
- package/src/app/lib/docx/ooxml.test.ts +25 -9
- package/src/app/lib/docx/ooxml.ts +58 -37
- package/src/app/lib/export-docx.ts +13 -8
- package/src/app/lib/flow.ts +1 -1
- package/src/app/lib/i18n-ja/browser.ts +88 -0
- package/src/app/lib/i18n-ja/doc.ts +65 -0
- package/src/app/lib/i18n-ja/index.ts +5 -0
- package/src/app/lib/i18n-ja/panels.ts +104 -0
- package/src/app/lib/i18n-ko/browser.ts +87 -0
- package/src/app/lib/i18n-ko/doc.ts +65 -0
- package/src/app/lib/i18n-ko/index.ts +5 -0
- package/src/app/lib/i18n-ko/panels.ts +102 -0
- package/src/app/lib/i18n-zh-cn/browser.ts +84 -0
- package/src/app/lib/i18n-zh-cn/doc.ts +64 -0
- package/src/app/lib/i18n-zh-cn/index.ts +5 -0
- package/src/app/lib/i18n-zh-cn/panels.ts +98 -0
- package/src/app/lib/i18n-zh-tw/browser.ts +84 -0
- package/src/app/lib/i18n-zh-tw/doc.ts +64 -0
- package/src/app/lib/i18n-zh-tw/index.ts +5 -0
- package/src/app/lib/i18n-zh-tw/panels.ts +99 -0
- package/src/app/lib/i18n.test.ts +24 -0
- package/src/app/lib/i18n.tsx +109 -0
- package/src/app/lib/outline.ts +23 -0
- package/src/app/lib/page-range.test.ts +10 -1
- package/src/app/lib/page-range.ts +26 -0
- package/src/app/lib/sdk.ts +2 -0
- package/src/app/main.tsx +4 -1
- package/src/app/routes/assets.tsx +193 -132
- package/src/app/routes/doc.tsx +666 -310
- package/src/app/routes/home-shell.tsx +115 -88
- package/src/app/routes/home.tsx +200 -67
- package/src/app/routes/themes.tsx +42 -35
- package/src/app/styles.css +84 -5
- package/src/app/virtual.d.ts +1 -0
|
@@ -0,0 +1,84 @@
|
|
|
1
|
+
export const BROWSER: Record<string, string> = {
|
|
2
|
+
Documents: '文档',
|
|
3
|
+
Themes: '主题',
|
|
4
|
+
Assets: '资源',
|
|
5
|
+
Unfiled: '未分类',
|
|
6
|
+
Folders: '文件夹',
|
|
7
|
+
Folder: '文件夹',
|
|
8
|
+
'New folder': '新建文件夹',
|
|
9
|
+
'Folder name': '文件夹名称',
|
|
10
|
+
Search: '搜索',
|
|
11
|
+
Menu: '菜单',
|
|
12
|
+
'Change icon': '更换图标',
|
|
13
|
+
'{name} options': '{name} 选项',
|
|
14
|
+
Rename: '重命名',
|
|
15
|
+
Duplicate: '创建副本',
|
|
16
|
+
'Move to': '移动到',
|
|
17
|
+
Delete: '删除',
|
|
18
|
+
'Delete folder': '删除文件夹',
|
|
19
|
+
'Delete document': '删除文档',
|
|
20
|
+
'Document title': '文档标题',
|
|
21
|
+
'Delete "{title}"? This removes docs/{id}/ from disk.':
|
|
22
|
+
'要删除“{title}”吗?这会从磁盘中移除 docs/{id}/。',
|
|
23
|
+
emoji: '表情',
|
|
24
|
+
color: '颜色',
|
|
25
|
+
Newest: '最新',
|
|
26
|
+
Oldest: '最早',
|
|
27
|
+
'A–Z': 'A–Z',
|
|
28
|
+
'Z–A': 'Z–A',
|
|
29
|
+
'Sort: {label}': '排序:{label}',
|
|
30
|
+
'Filter documents': '筛选文档',
|
|
31
|
+
'{size} landscape': '{size} 横向',
|
|
32
|
+
'Nothing matches “{query}”': '没有与“{query}”匹配的结果',
|
|
33
|
+
'Try another word from the title.': '试试标题中的其他词。',
|
|
34
|
+
'Nothing here yet': '这里还没有内容',
|
|
35
|
+
'Ask your agent to write a document, and it appears here.':
|
|
36
|
+
'让你的 agent 写一篇文档,它就会出现在这里。',
|
|
37
|
+
'Drag a document onto this folder, or use Move to on its card.':
|
|
38
|
+
'把文档拖到这个文件夹,或使用卡片上的“移动到”。',
|
|
39
|
+
'No themes yet': '还没有主题',
|
|
40
|
+
'Ask your agent to create a theme from a document you like.':
|
|
41
|
+
'让你的 agent 根据你喜欢的文档创建一个主题。',
|
|
42
|
+
'Theme “{id}” not found.': '未找到主题“{id}”。',
|
|
43
|
+
'Back to themes': '返回主题',
|
|
44
|
+
'Used by': '使用该主题的文档',
|
|
45
|
+
Upload: '上传',
|
|
46
|
+
Project: '项目',
|
|
47
|
+
'This document': '当前文档',
|
|
48
|
+
'Drop files here to upload': '将文件拖放到此处即可上传',
|
|
49
|
+
'No assets yet': '还没有资源',
|
|
50
|
+
'Drop images here or choose Upload.': '将图片拖放到此处,或选择“上传”。',
|
|
51
|
+
'"{name}" already exists in {scope}. Replace it?': '{scope} 中已存在“{name}”,要替换吗?',
|
|
52
|
+
'New file name': '新文件名',
|
|
53
|
+
'Delete "{name}"? This removes the file from disk.': '要删除“{name}”吗?这会从磁盘中移除该文件。',
|
|
54
|
+
' · unused': ' · 未使用',
|
|
55
|
+
'Copy the import line for {name}': '复制 {name} 的 import 语句',
|
|
56
|
+
'Copy import line': '复制 import 语句',
|
|
57
|
+
'Copy import': '复制 import',
|
|
58
|
+
Copied: '已复制',
|
|
59
|
+
'No assets yet. Add images from the Assets page.': '还没有资源。请从“资源”页面添加图片。',
|
|
60
|
+
pages: '页面',
|
|
61
|
+
outline: '大纲',
|
|
62
|
+
assets: '资源',
|
|
63
|
+
'Page {page}': '第 {page} 页',
|
|
64
|
+
'No headings yet.': '还没有标题。',
|
|
65
|
+
'Toggle theme': '切换主题',
|
|
66
|
+
Theme: '主题',
|
|
67
|
+
Light: '浅色',
|
|
68
|
+
Dark: '深色',
|
|
69
|
+
System: '跟随系统',
|
|
70
|
+
Language: '语言',
|
|
71
|
+
'Search documents, sections and actions': '搜索文档、章节和操作',
|
|
72
|
+
Close: '关闭',
|
|
73
|
+
'Command menu': '命令面板',
|
|
74
|
+
Results: '结果',
|
|
75
|
+
'Nothing matches “{query}”.': '没有与“{query}”匹配的结果。',
|
|
76
|
+
Navigate: '导航',
|
|
77
|
+
Open: '打开',
|
|
78
|
+
'Go to': '转到',
|
|
79
|
+
'All documents': '所有文档',
|
|
80
|
+
Appearance: '外观',
|
|
81
|
+
'Light theme': '浅色主题',
|
|
82
|
+
'Dark theme': '深色主题',
|
|
83
|
+
'System theme': '跟随系统主题',
|
|
84
|
+
};
|
|
@@ -0,0 +1,64 @@
|
|
|
1
|
+
export const DOC: Record<string, string> = {
|
|
2
|
+
'Back to workspace': '返回工作区',
|
|
3
|
+
'Back to documents': '返回文档列表',
|
|
4
|
+
'Print & share': '打印与分享',
|
|
5
|
+
Edit: '编辑',
|
|
6
|
+
Images: '图片',
|
|
7
|
+
Word: 'Word',
|
|
8
|
+
'True page size, print-ready': '实际页面尺寸,可直接打印',
|
|
9
|
+
'One self-contained file': '单个独立文件',
|
|
10
|
+
'Editable; Word lays out the pages': '可编辑;由 Word 自行排版页面',
|
|
11
|
+
'Pixels at 2×, for slides and chat': '2× 分辨率位图,适合演示文稿和聊天',
|
|
12
|
+
'Vector, text stays text': '矢量图,文字仍保留为文字',
|
|
13
|
+
'This document': '当前文档',
|
|
14
|
+
'Go to page {page}': '转到第 {page} 页',
|
|
15
|
+
Sections: '章节',
|
|
16
|
+
'p. {page}': '第 {page} 页',
|
|
17
|
+
Actions: '操作',
|
|
18
|
+
'Download as {format}': '下载为 {format}',
|
|
19
|
+
'Continuous layout': '连续布局',
|
|
20
|
+
'Two-up layout': '双页布局',
|
|
21
|
+
'Grid layout': '网格布局',
|
|
22
|
+
Fullscreen: '全屏',
|
|
23
|
+
'Leave edit mode': '退出编辑模式',
|
|
24
|
+
'Edit on the page': '在页面上编辑',
|
|
25
|
+
'Close the design panel': '关闭设计面板',
|
|
26
|
+
'Open the design panel': '打开设计面板',
|
|
27
|
+
'Could not load “{id}”.': '无法加载“{id}”。',
|
|
28
|
+
'Search sections, pages, actions and documents': '搜索章节、页面、操作和文档',
|
|
29
|
+
'Page layout': '页面布局',
|
|
30
|
+
Continuous: '连续',
|
|
31
|
+
'Two-up': '双页',
|
|
32
|
+
Grid: '网格',
|
|
33
|
+
'Exit fullscreen (F)': '退出全屏 (F)',
|
|
34
|
+
'Fullscreen (F)': '全屏 (F)',
|
|
35
|
+
Mode: '模式',
|
|
36
|
+
Preview: '预览',
|
|
37
|
+
Design: '设计',
|
|
38
|
+
'Design tokens (D)': '设计变量 (D)',
|
|
39
|
+
Download: '下载',
|
|
40
|
+
All: '全部',
|
|
41
|
+
'This page': '当前页',
|
|
42
|
+
Range: '范围',
|
|
43
|
+
'No such pages — this document has {total}': '没有这些页面,该文档共 {total} 页',
|
|
44
|
+
'Type pages, like 1-3, 6': '输入页码,例如 1-3, 6',
|
|
45
|
+
'All 1 page': '全部 1 页',
|
|
46
|
+
'All {count} pages': '全部 {count} 页',
|
|
47
|
+
'Page {pages} · 1 page': '第 {pages} 页 · 1 页',
|
|
48
|
+
'Pages {pages} · {count} pages': '第 {pages} 页 · 共 {count} 页',
|
|
49
|
+
Pages: '页面',
|
|
50
|
+
'Pages to download': '要下载的页面',
|
|
51
|
+
'Page range': '页面范围',
|
|
52
|
+
'Page number, {total} pages': '页码,共 {total} 页',
|
|
53
|
+
'Go to page': '转到页面',
|
|
54
|
+
'Zoom out': '缩小',
|
|
55
|
+
'Zoom in': '放大',
|
|
56
|
+
'Zoom level, percent': '缩放比例(百分比)',
|
|
57
|
+
'Type a zoom level': '输入缩放比例',
|
|
58
|
+
'Zoom options': '缩放选项',
|
|
59
|
+
'Fit width': '适合宽度',
|
|
60
|
+
'Fit page': '适合页面',
|
|
61
|
+
'Actual size (100%)': '实际大小 (100%)',
|
|
62
|
+
'Link copied': '已复制链接',
|
|
63
|
+
'Copy link': '复制链接',
|
|
64
|
+
};
|
|
@@ -0,0 +1,98 @@
|
|
|
1
|
+
export const PANELS: Record<string, string> = {
|
|
2
|
+
Design: '设计',
|
|
3
|
+
'This document has no design const yet — saving writes one':
|
|
4
|
+
'该文档还没有 design 常量,保存时会写入一个',
|
|
5
|
+
Draft: '草稿',
|
|
6
|
+
'Unsaved changes': '未保存的更改',
|
|
7
|
+
'Shuffle preset': '随机应用预设',
|
|
8
|
+
'Reset to defaults': '恢复默认值',
|
|
9
|
+
'Close design panel (D)': '关闭设计面板 (D)',
|
|
10
|
+
Palette: '配色',
|
|
11
|
+
Fonts: '字体',
|
|
12
|
+
'Type scale': '字号',
|
|
13
|
+
Page: '页面',
|
|
14
|
+
Sheet: '纸张',
|
|
15
|
+
Text: '文字',
|
|
16
|
+
Muted: '次要文字',
|
|
17
|
+
Accent: '强调色',
|
|
18
|
+
Rule: '线条',
|
|
19
|
+
Heading: '标题',
|
|
20
|
+
Body: '正文',
|
|
21
|
+
Mono: '等宽',
|
|
22
|
+
Title: '大标题',
|
|
23
|
+
Caption: '图注',
|
|
24
|
+
'System sans': '系统无衬线体',
|
|
25
|
+
'Georgia serif': 'Georgia 衬线体',
|
|
26
|
+
'Times serif': 'Times 衬线体',
|
|
27
|
+
'Body under 12px prints below 9pt — hard to read on paper.':
|
|
28
|
+
'正文小于 12px 时打印出来不到 9pt,在纸上难以阅读。',
|
|
29
|
+
Margin: '页边距',
|
|
30
|
+
Leading: '行高',
|
|
31
|
+
Radius: '圆角',
|
|
32
|
+
'Failed to save': '保存失败',
|
|
33
|
+
'{label} swatch': '{label}色板',
|
|
34
|
+
'Custom (from source)': '自定义(来自源代码)',
|
|
35
|
+
Undo: '撤销',
|
|
36
|
+
Redo: '重做',
|
|
37
|
+
Saved: '已保存',
|
|
38
|
+
'{count} unsaved change': '{count} 项未保存的更改',
|
|
39
|
+
'{count} unsaved changes': '{count} 项未保存的更改',
|
|
40
|
+
Discard: '放弃',
|
|
41
|
+
Save: '保存',
|
|
42
|
+
Saving: '正在保存',
|
|
43
|
+
'Not everything was saved': '部分更改未能保存',
|
|
44
|
+
'Find in document': '在文档中查找',
|
|
45
|
+
Find: '查找',
|
|
46
|
+
'Previous match': '上一个匹配项',
|
|
47
|
+
'Next match': '下一个匹配项',
|
|
48
|
+
'Close search': '关闭搜索',
|
|
49
|
+
'Text formatting': '文字格式',
|
|
50
|
+
'Link address': '链接地址',
|
|
51
|
+
'https://… or #section': 'https://… 或 #章节',
|
|
52
|
+
'Only web, mail, phone, or in-document addresses': '仅支持网址、电子邮件、电话或文档内位置',
|
|
53
|
+
'Apply link': '应用链接',
|
|
54
|
+
Apply: '应用',
|
|
55
|
+
'Remove link': '移除链接',
|
|
56
|
+
Bold: '加粗',
|
|
57
|
+
Italic: '斜体',
|
|
58
|
+
Code: '代码',
|
|
59
|
+
'Already bold — this element’s own style sets it': '已是粗体:该元素自身的样式已设置为粗体',
|
|
60
|
+
Link: '链接',
|
|
61
|
+
'Clear formatting': '清除格式',
|
|
62
|
+
'Select words to format': '请先选中要设置格式的文字',
|
|
63
|
+
'This text is passed in as a string — formatting needs text written in the document':
|
|
64
|
+
'这段文字是以字符串传入的,只有直接写在文档中的文字才能设置格式',
|
|
65
|
+
'The text on the page does not line up with its source, so it cannot be edited here.':
|
|
66
|
+
'页面上的文字与源代码不一致,因此无法在此编辑。',
|
|
67
|
+
'Discarded unsaved edits': '已放弃未保存的编辑',
|
|
68
|
+
'Save failed': '保存失败',
|
|
69
|
+
'Saved to source': '已保存到源代码',
|
|
70
|
+
'{failed} of {total} not saved — {reason}': '{total} 项中有 {failed} 项未保存:{reason}',
|
|
71
|
+
refused: '被拒绝',
|
|
72
|
+
'The document reloaded with new text here — {count} unsaved edit was lost':
|
|
73
|
+
'文档已重新加载,此处文字已更改,{count} 项未保存的编辑已丢失',
|
|
74
|
+
'The document reloaded with new text here — {count} unsaved edits were lost':
|
|
75
|
+
'文档已重新加载,此处文字已更改,{count} 项未保存的编辑已丢失',
|
|
76
|
+
'Type inside one run of text — the markup between runs stays as written.':
|
|
77
|
+
'请在同一段文字内输入,段落之间的标记会保持原样。',
|
|
78
|
+
'source text does not match this element': '源代码中的文字与该元素不匹配',
|
|
79
|
+
'could not read source': '无法读取源代码',
|
|
80
|
+
'This text cannot be edited here.': '这段文字无法在此编辑。',
|
|
81
|
+
'Marked in source — run /apply-comments': '已在源代码中标记,请运行 /apply-comments',
|
|
82
|
+
'Could not add comment': '无法添加注释',
|
|
83
|
+
'Enter to keep · Shift+Enter for a new line · Esc to revert':
|
|
84
|
+
'Enter 保留 · Shift+Enter 换行 · Esc 还原',
|
|
85
|
+
'Double-click or Enter to edit text · Esc to deselect': '双击或按 Enter 编辑文字 · Esc 取消选中',
|
|
86
|
+
'Click to select · double-click to edit · Esc to leave': '单击选中 · 双击编辑 · Esc 退出',
|
|
87
|
+
Element: '元素',
|
|
88
|
+
Close: '关闭',
|
|
89
|
+
'Editing on the page. Enter keeps the change, Shift+Enter starts a new line, Esc reverts it.':
|
|
90
|
+
'正在页面上编辑。按 Enter 保留更改,Shift+Enter 换行,Esc 还原。',
|
|
91
|
+
'Double-click the text on the page, or press Enter, to edit it where it is printed.':
|
|
92
|
+
'在页面上双击文字或按 Enter,即可在其打印位置直接编辑。',
|
|
93
|
+
'Inline markup stays as written.': '行内标记会保持原样。',
|
|
94
|
+
'Not editable here.': '无法在此编辑。',
|
|
95
|
+
'Comment for the agent': '给 agent 的注释',
|
|
96
|
+
'make this bold, shorten to one line…': '改为粗体、缩短为一行…',
|
|
97
|
+
'Mark comment': '标记注释',
|
|
98
|
+
};
|
|
@@ -0,0 +1,84 @@
|
|
|
1
|
+
export const BROWSER: Record<string, string> = {
|
|
2
|
+
Documents: '文件',
|
|
3
|
+
Themes: '主題',
|
|
4
|
+
Assets: '素材',
|
|
5
|
+
Unfiled: '未分類',
|
|
6
|
+
Folders: '資料夾',
|
|
7
|
+
Folder: '資料夾',
|
|
8
|
+
'New folder': '新增資料夾',
|
|
9
|
+
'Folder name': '資料夾名稱',
|
|
10
|
+
Search: '搜尋',
|
|
11
|
+
Menu: '選單',
|
|
12
|
+
'Change icon': '更換圖示',
|
|
13
|
+
'{name} options': '{name} 選項',
|
|
14
|
+
Rename: '重新命名',
|
|
15
|
+
Duplicate: '複製',
|
|
16
|
+
'Move to': '移到',
|
|
17
|
+
Delete: '刪除',
|
|
18
|
+
'Delete folder': '刪除資料夾',
|
|
19
|
+
'Delete document': '刪除文件',
|
|
20
|
+
'Document title': '文件標題',
|
|
21
|
+
'Delete "{title}"? This removes docs/{id}/ from disk.':
|
|
22
|
+
'要刪除「{title}」嗎?這會從磁碟移除 docs/{id}/。',
|
|
23
|
+
emoji: '表情符號',
|
|
24
|
+
color: '顏色',
|
|
25
|
+
Newest: '最新',
|
|
26
|
+
Oldest: '最舊',
|
|
27
|
+
'A–Z': 'A–Z',
|
|
28
|
+
'Z–A': 'Z–A',
|
|
29
|
+
'Sort: {label}': '排序:{label}',
|
|
30
|
+
'Filter documents': '篩選文件',
|
|
31
|
+
'{size} landscape': '{size} 橫向',
|
|
32
|
+
'Nothing matches “{query}”': '找不到符合「{query}」的項目',
|
|
33
|
+
'Try another word from the title.': '試試標題裡的其他字詞。',
|
|
34
|
+
'Nothing here yet': '這裡還沒有東西',
|
|
35
|
+
'Ask your agent to write a document, and it appears here.':
|
|
36
|
+
'請你的 agent 寫一份文件,它就會出現在這裡。',
|
|
37
|
+
'Drag a document onto this folder, or use Move to on its card.':
|
|
38
|
+
'把文件拖到這個資料夾,或使用卡片上的「移到」。',
|
|
39
|
+
'No themes yet': '還沒有主題',
|
|
40
|
+
'Ask your agent to create a theme from a document you like.':
|
|
41
|
+
'請你的 agent 從你喜歡的文件建立一個主題。',
|
|
42
|
+
'Theme “{id}” not found.': '找不到主題「{id}」。',
|
|
43
|
+
'Back to themes': '返回主題',
|
|
44
|
+
'Used by': '使用中的文件',
|
|
45
|
+
Upload: '上傳',
|
|
46
|
+
Project: '專案',
|
|
47
|
+
'This document': '這份文件',
|
|
48
|
+
'Drop files here to upload': '將檔案拖放到這裡即可上傳',
|
|
49
|
+
'No assets yet': '還沒有素材',
|
|
50
|
+
'Drop images here or choose Upload.': '將圖片拖放到這裡,或選擇「上傳」。',
|
|
51
|
+
'"{name}" already exists in {scope}. Replace it?': '{scope} 已有「{name}」,要取代嗎?',
|
|
52
|
+
'New file name': '新的檔案名稱',
|
|
53
|
+
'Delete "{name}"? This removes the file from disk.': '要刪除「{name}」嗎?這會從磁碟移除該檔案。',
|
|
54
|
+
' · unused': ' · 未使用',
|
|
55
|
+
'Copy the import line for {name}': '複製 {name} 的 import 語法',
|
|
56
|
+
'Copy import line': '複製 import 語法',
|
|
57
|
+
'Copy import': '複製 import',
|
|
58
|
+
Copied: '已複製',
|
|
59
|
+
'No assets yet. Add images from the Assets page.': '還沒有素材。請從「素材」頁面加入圖片。',
|
|
60
|
+
pages: '頁面',
|
|
61
|
+
outline: '大綱',
|
|
62
|
+
assets: '素材',
|
|
63
|
+
'Page {page}': '第 {page} 頁',
|
|
64
|
+
'No headings yet.': '還沒有標題。',
|
|
65
|
+
'Toggle theme': '切換主題',
|
|
66
|
+
Theme: '主題',
|
|
67
|
+
Light: '淺色',
|
|
68
|
+
Dark: '深色',
|
|
69
|
+
System: '系統',
|
|
70
|
+
Language: '語言',
|
|
71
|
+
'Search documents, sections and actions': '搜尋文件、章節與動作',
|
|
72
|
+
Close: '關閉',
|
|
73
|
+
'Command menu': '指令面板',
|
|
74
|
+
Results: '結果',
|
|
75
|
+
'Nothing matches “{query}”.': '找不到符合「{query}」的項目。',
|
|
76
|
+
Navigate: '移動',
|
|
77
|
+
Open: '開啟',
|
|
78
|
+
'Go to': '前往',
|
|
79
|
+
'All documents': '所有文件',
|
|
80
|
+
Appearance: '外觀',
|
|
81
|
+
'Light theme': '淺色主題',
|
|
82
|
+
'Dark theme': '深色主題',
|
|
83
|
+
'System theme': '系統主題',
|
|
84
|
+
};
|
|
@@ -0,0 +1,64 @@
|
|
|
1
|
+
export const DOC: Record<string, string> = {
|
|
2
|
+
'Back to workspace': '返回工作區',
|
|
3
|
+
'Back to documents': '返回文件列表',
|
|
4
|
+
'Print & share': '列印與分享',
|
|
5
|
+
Edit: '編輯',
|
|
6
|
+
Images: '圖片',
|
|
7
|
+
Word: 'Word',
|
|
8
|
+
'True page size, print-ready': '實際頁面尺寸,可直接列印',
|
|
9
|
+
'One self-contained file': '單一獨立檔案',
|
|
10
|
+
'Editable; Word lays out the pages': '可編輯;由 Word 自行排版頁面',
|
|
11
|
+
'Pixels at 2×, for slides and chat': '2× 解析度點陣圖,適合簡報與聊天',
|
|
12
|
+
'Vector, text stays text': '向量圖,文字仍是文字',
|
|
13
|
+
'This document': '這份文件',
|
|
14
|
+
'Go to page {page}': '前往第 {page} 頁',
|
|
15
|
+
Sections: '章節',
|
|
16
|
+
'p. {page}': '第 {page} 頁',
|
|
17
|
+
Actions: '動作',
|
|
18
|
+
'Download as {format}': '下載為 {format}',
|
|
19
|
+
'Continuous layout': '連續版面',
|
|
20
|
+
'Two-up layout': '雙頁版面',
|
|
21
|
+
'Grid layout': '格狀版面',
|
|
22
|
+
Fullscreen: '全螢幕',
|
|
23
|
+
'Leave edit mode': '離開編輯模式',
|
|
24
|
+
'Edit on the page': '在頁面上編輯',
|
|
25
|
+
'Close the design panel': '關閉設計面板',
|
|
26
|
+
'Open the design panel': '開啟設計面板',
|
|
27
|
+
'Could not load “{id}”.': '無法載入「{id}」。',
|
|
28
|
+
'Search sections, pages, actions and documents': '搜尋章節、頁面、動作與文件',
|
|
29
|
+
'Page layout': '頁面版面',
|
|
30
|
+
Continuous: '連續',
|
|
31
|
+
'Two-up': '雙頁',
|
|
32
|
+
Grid: '格狀',
|
|
33
|
+
'Exit fullscreen (F)': '離開全螢幕 (F)',
|
|
34
|
+
'Fullscreen (F)': '全螢幕 (F)',
|
|
35
|
+
Mode: '模式',
|
|
36
|
+
Preview: '預覽',
|
|
37
|
+
Design: '設計',
|
|
38
|
+
'Design tokens (D)': '設計變數 (D)',
|
|
39
|
+
Download: '下載',
|
|
40
|
+
All: '全部',
|
|
41
|
+
'This page': '這一頁',
|
|
42
|
+
Range: '範圍',
|
|
43
|
+
'No such pages — this document has {total}': '沒有這些頁面,這份文件共 {total} 頁',
|
|
44
|
+
'Type pages, like 1-3, 6': '輸入頁碼,例如 1-3, 6',
|
|
45
|
+
'All 1 page': '全部 1 頁',
|
|
46
|
+
'All {count} pages': '全部 {count} 頁',
|
|
47
|
+
'Page {pages} · 1 page': '第 {pages} 頁 · 1 頁',
|
|
48
|
+
'Pages {pages} · {count} pages': '第 {pages} 頁 · 共 {count} 頁',
|
|
49
|
+
Pages: '頁面',
|
|
50
|
+
'Pages to download': '要下載的頁面',
|
|
51
|
+
'Page range': '頁面範圍',
|
|
52
|
+
'Page number, {total} pages': '頁碼,共 {total} 頁',
|
|
53
|
+
'Go to page': '前往頁面',
|
|
54
|
+
'Zoom out': '縮小',
|
|
55
|
+
'Zoom in': '放大',
|
|
56
|
+
'Zoom level, percent': '縮放比例(百分比)',
|
|
57
|
+
'Type a zoom level': '輸入縮放比例',
|
|
58
|
+
'Zoom options': '縮放選項',
|
|
59
|
+
'Fit width': '符合寬度',
|
|
60
|
+
'Fit page': '符合頁面',
|
|
61
|
+
'Actual size (100%)': '實際大小 (100%)',
|
|
62
|
+
'Link copied': '已複製連結',
|
|
63
|
+
'Copy link': '複製連結',
|
|
64
|
+
};
|
|
@@ -0,0 +1,99 @@
|
|
|
1
|
+
export const PANELS: Record<string, string> = {
|
|
2
|
+
Design: '設計',
|
|
3
|
+
'This document has no design const yet — saving writes one':
|
|
4
|
+
'這份文件還沒有 design 常數,儲存時會寫入一個',
|
|
5
|
+
Draft: '草稿',
|
|
6
|
+
'Unsaved changes': '未儲存的變更',
|
|
7
|
+
'Shuffle preset': '隨機套用預設組合',
|
|
8
|
+
'Reset to defaults': '重設為預設值',
|
|
9
|
+
'Close design panel (D)': '關閉設計面板 (D)',
|
|
10
|
+
Palette: '色彩',
|
|
11
|
+
Fonts: '字型',
|
|
12
|
+
'Type scale': '字級',
|
|
13
|
+
Page: '頁面',
|
|
14
|
+
Sheet: '紙張',
|
|
15
|
+
Text: '文字',
|
|
16
|
+
Muted: '次要文字',
|
|
17
|
+
Accent: '強調色',
|
|
18
|
+
Rule: '線條',
|
|
19
|
+
Heading: '標題',
|
|
20
|
+
Body: '內文',
|
|
21
|
+
Mono: '等寬',
|
|
22
|
+
Title: '大標題',
|
|
23
|
+
Caption: '圖說',
|
|
24
|
+
'System sans': '系統無襯線體',
|
|
25
|
+
'Georgia serif': 'Georgia 襯線體',
|
|
26
|
+
'Times serif': 'Times 襯線體',
|
|
27
|
+
'Body under 12px prints below 9pt — hard to read on paper.':
|
|
28
|
+
'內文小於 12px 時印出來不到 9pt,在紙上不易閱讀。',
|
|
29
|
+
Margin: '邊界',
|
|
30
|
+
Leading: '行高',
|
|
31
|
+
Radius: '圓角',
|
|
32
|
+
'Failed to save': '儲存失敗',
|
|
33
|
+
'{label} swatch': '{label}色票',
|
|
34
|
+
'Custom (from source)': '自訂(來自原始碼)',
|
|
35
|
+
Undo: '復原',
|
|
36
|
+
Redo: '重做',
|
|
37
|
+
Saved: '已儲存',
|
|
38
|
+
'{count} unsaved change': '{count} 項未儲存的變更',
|
|
39
|
+
'{count} unsaved changes': '{count} 項未儲存的變更',
|
|
40
|
+
Discard: '捨棄',
|
|
41
|
+
Save: '儲存',
|
|
42
|
+
Saving: '儲存中',
|
|
43
|
+
'Not everything was saved': '有部分變更未能儲存',
|
|
44
|
+
'Find in document': '在文件中尋找',
|
|
45
|
+
Find: '尋找',
|
|
46
|
+
'Previous match': '上一個符合項目',
|
|
47
|
+
'Next match': '下一個符合項目',
|
|
48
|
+
'Close search': '關閉搜尋',
|
|
49
|
+
'Text formatting': '文字格式',
|
|
50
|
+
'Link address': '連結網址',
|
|
51
|
+
'https://… or #section': 'https://… 或 #章節',
|
|
52
|
+
'Only web, mail, phone, or in-document addresses': '只接受網址、電子郵件、電話或文件內的位置',
|
|
53
|
+
'Apply link': '套用連結',
|
|
54
|
+
Apply: '套用',
|
|
55
|
+
'Remove link': '移除連結',
|
|
56
|
+
Bold: '粗體',
|
|
57
|
+
Italic: '斜體',
|
|
58
|
+
Code: '程式碼',
|
|
59
|
+
'Already bold — this element’s own style sets it': '已經是粗體:這個元素本身的樣式就設定了粗體',
|
|
60
|
+
Link: '連結',
|
|
61
|
+
'Clear formatting': '清除格式',
|
|
62
|
+
'Select words to format': '請先選取要套用格式的文字',
|
|
63
|
+
'This text is passed in as a string — formatting needs text written in the document':
|
|
64
|
+
'這段文字是以字串傳入的,只有直接寫在文件中的文字才能套用格式',
|
|
65
|
+
'The text on the page does not line up with its source, so it cannot be edited here.':
|
|
66
|
+
'頁面上的文字與原始碼對不上,因此無法在這裡編輯。',
|
|
67
|
+
'Discarded unsaved edits': '已捨棄未儲存的編輯',
|
|
68
|
+
'Save failed': '儲存失敗',
|
|
69
|
+
'Saved to source': '已儲存至原始碼',
|
|
70
|
+
'{failed} of {total} not saved — {reason}': '{total} 項中有 {failed} 項未儲存:{reason}',
|
|
71
|
+
refused: '遭到拒絕',
|
|
72
|
+
'The document reloaded with new text here — {count} unsaved edit was lost':
|
|
73
|
+
'文件已重新載入,這裡的文字已變更,{count} 項未儲存的編輯已遺失',
|
|
74
|
+
'The document reloaded with new text here — {count} unsaved edits were lost':
|
|
75
|
+
'文件已重新載入,這裡的文字已變更,{count} 項未儲存的編輯已遺失',
|
|
76
|
+
'Type inside one run of text — the markup between runs stays as written.':
|
|
77
|
+
'請在同一段文字內輸入,段落之間的標記會維持原樣。',
|
|
78
|
+
'source text does not match this element': '原始碼中的文字與這個元素不符',
|
|
79
|
+
'could not read source': '無法讀取原始碼',
|
|
80
|
+
'This text cannot be edited here.': '這段文字無法在這裡編輯。',
|
|
81
|
+
'Marked in source — run /apply-comments': '已在原始碼中標記,請執行 /apply-comments',
|
|
82
|
+
'Could not add comment': '無法新增註解',
|
|
83
|
+
'Enter to keep · Shift+Enter for a new line · Esc to revert':
|
|
84
|
+
'Enter 保留 · Shift+Enter 換行 · Esc 還原',
|
|
85
|
+
'Double-click or Enter to edit text · Esc to deselect':
|
|
86
|
+
'按兩下或按 Enter 編輯文字 · Esc 取消選取',
|
|
87
|
+
'Click to select · double-click to edit · Esc to leave': '按一下選取 · 按兩下編輯 · Esc 離開',
|
|
88
|
+
Element: '元素',
|
|
89
|
+
Close: '關閉',
|
|
90
|
+
'Editing on the page. Enter keeps the change, Shift+Enter starts a new line, Esc reverts it.':
|
|
91
|
+
'正在頁面上編輯。按 Enter 保留變更,Shift+Enter 換行,Esc 還原。',
|
|
92
|
+
'Double-click the text on the page, or press Enter, to edit it where it is printed.':
|
|
93
|
+
'在頁面上按兩下文字或按 Enter,即可直接在印出的位置編輯。',
|
|
94
|
+
'Inline markup stays as written.': '行內標記會維持原樣。',
|
|
95
|
+
'Not editable here.': '無法在這裡編輯。',
|
|
96
|
+
'Comment for the agent': '給 agent 的註解',
|
|
97
|
+
'make this bold, shorten to one line…': '改成粗體、縮短成一行…',
|
|
98
|
+
'Mark comment': '標記註解',
|
|
99
|
+
};
|
|
@@ -0,0 +1,24 @@
|
|
|
1
|
+
import { describe, expect, it } from 'vitest';
|
|
2
|
+
import { DICTIONARIES } from './i18n';
|
|
3
|
+
|
|
4
|
+
const placeholders = (text: string) => [...text.matchAll(/\{(\w+)\}/g)].map((m) => m[1]).sort();
|
|
5
|
+
|
|
6
|
+
const translated = Object.entries(DICTIONARIES).filter(([locale]) => locale !== 'en');
|
|
7
|
+
const reference = Object.keys(DICTIONARIES['zh-TW']).sort();
|
|
8
|
+
|
|
9
|
+
describe.each(translated)('%s dictionary', (_locale, dictionary) => {
|
|
10
|
+
it('translates exactly the strings the others do', () => {
|
|
11
|
+
expect(Object.keys(dictionary).sort()).toEqual(reference);
|
|
12
|
+
});
|
|
13
|
+
|
|
14
|
+
it('keeps every placeholder of the English key, and no others', () => {
|
|
15
|
+
const broken = Object.entries(dictionary).filter(
|
|
16
|
+
([en, text]) => placeholders(en).join() !== placeholders(text).join(),
|
|
17
|
+
);
|
|
18
|
+
expect(broken).toEqual([]);
|
|
19
|
+
});
|
|
20
|
+
|
|
21
|
+
it('has no empty translations', () => {
|
|
22
|
+
expect(Object.entries(dictionary).filter(([, text]) => text.trim() === '')).toEqual([]);
|
|
23
|
+
});
|
|
24
|
+
});
|
|
@@ -0,0 +1,109 @@
|
|
|
1
|
+
import {
|
|
2
|
+
createContext,
|
|
3
|
+
type ReactNode,
|
|
4
|
+
useCallback,
|
|
5
|
+
useContext,
|
|
6
|
+
useEffect,
|
|
7
|
+
useMemo,
|
|
8
|
+
useRef,
|
|
9
|
+
useState,
|
|
10
|
+
} from 'react';
|
|
11
|
+
import { JA } from './i18n-ja';
|
|
12
|
+
import { KO } from './i18n-ko';
|
|
13
|
+
import { ZH_CN } from './i18n-zh-cn';
|
|
14
|
+
import { ZH_TW } from './i18n-zh-tw';
|
|
15
|
+
|
|
16
|
+
/**
|
|
17
|
+
* The viewer chrome in English, Chinese, Japanese or Korean. The English text is the
|
|
18
|
+
* key, so a string with no translation yet still reads — in English — instead
|
|
19
|
+
* of showing a key. Only the chrome is translated: what prints on the page is
|
|
20
|
+
* the document's, and `meta.labels` already decides what a figure is called.
|
|
21
|
+
*/
|
|
22
|
+
export const LOCALES = [
|
|
23
|
+
{ value: 'en', label: 'English' },
|
|
24
|
+
{ value: 'zh-TW', label: '繁體中文' },
|
|
25
|
+
{ value: 'zh-CN', label: '简体中文' },
|
|
26
|
+
{ value: 'ja', label: '日本語' },
|
|
27
|
+
{ value: 'ko', label: '한국어' },
|
|
28
|
+
] as const;
|
|
29
|
+
export type Locale = (typeof LOCALES)[number]['value'];
|
|
30
|
+
|
|
31
|
+
const STORAGE = 'open-doc:locale';
|
|
32
|
+
export const DICTIONARIES: Record<Locale, Record<string, string>> = {
|
|
33
|
+
en: {},
|
|
34
|
+
'zh-TW': ZH_TW,
|
|
35
|
+
'zh-CN': ZH_CN,
|
|
36
|
+
ja: JA,
|
|
37
|
+
ko: KO,
|
|
38
|
+
};
|
|
39
|
+
|
|
40
|
+
const isLocale = (value: string | null): value is Locale =>
|
|
41
|
+
LOCALES.some((entry) => entry.value === value);
|
|
42
|
+
|
|
43
|
+
/** The reader's browser language, mapped onto a locale we have; Chinese splits by script. */
|
|
44
|
+
function browserLocale(language: string): Locale {
|
|
45
|
+
if (/^zh-(TW|HK|MO)\b|^zh-Hant/i.test(language)) return 'zh-TW';
|
|
46
|
+
if (/^zh/i.test(language)) return 'zh-CN';
|
|
47
|
+
if (/^ja/i.test(language)) return 'ja';
|
|
48
|
+
if (/^ko/i.test(language)) return 'ko';
|
|
49
|
+
return 'en';
|
|
50
|
+
}
|
|
51
|
+
|
|
52
|
+
function initialLocale(): Locale {
|
|
53
|
+
try {
|
|
54
|
+
const stored = localStorage.getItem(STORAGE);
|
|
55
|
+
if (isLocale(stored)) return stored;
|
|
56
|
+
} catch {}
|
|
57
|
+
return typeof navigator === 'undefined' ? 'en' : browserLocale(navigator.language);
|
|
58
|
+
}
|
|
59
|
+
|
|
60
|
+
export type Translate = (text: string, vars?: Record<string, string | number>) => string;
|
|
61
|
+
|
|
62
|
+
function translate(locale: Locale, text: string, vars?: Record<string, string | number>): string {
|
|
63
|
+
const template = DICTIONARIES[locale][text] ?? text;
|
|
64
|
+
if (!vars) return template;
|
|
65
|
+
return template.replace(/\{(\w+)\}/g, (whole, name: string) =>
|
|
66
|
+
name in vars ? String(vars[name]) : whole,
|
|
67
|
+
);
|
|
68
|
+
}
|
|
69
|
+
|
|
70
|
+
type LocaleState = { locale: Locale; setLocale: (locale: Locale) => void; t: Translate };
|
|
71
|
+
|
|
72
|
+
const LocaleContext = createContext<LocaleState>({
|
|
73
|
+
locale: 'en',
|
|
74
|
+
setLocale: () => {},
|
|
75
|
+
t: (text, vars) => translate('en', text, vars),
|
|
76
|
+
});
|
|
77
|
+
|
|
78
|
+
export function LocaleProvider({ children }: { children: ReactNode }) {
|
|
79
|
+
const [locale, setLocaleState] = useState<Locale>(initialLocale);
|
|
80
|
+
|
|
81
|
+
useEffect(() => {
|
|
82
|
+
document.documentElement.lang = locale;
|
|
83
|
+
}, [locale]);
|
|
84
|
+
|
|
85
|
+
const setLocale = useCallback((next: Locale) => {
|
|
86
|
+
setLocaleState(next);
|
|
87
|
+
try {
|
|
88
|
+
localStorage.setItem(STORAGE, next);
|
|
89
|
+
} catch {}
|
|
90
|
+
}, []);
|
|
91
|
+
|
|
92
|
+
// `t` keeps one identity for the app's lifetime and reads the locale when
|
|
93
|
+
// called. Components still re-render on a switch — the context value changes —
|
|
94
|
+
// but an effect that lists `t` does not re-run, so switching language never
|
|
95
|
+
// tears down an edit in progress or refetches what the inspector holds.
|
|
96
|
+
const localeRef = useRef(locale);
|
|
97
|
+
localeRef.current = locale;
|
|
98
|
+
const t = useCallback<Translate>((text, vars) => translate(localeRef.current, text, vars), []);
|
|
99
|
+
const value = useMemo(() => ({ locale, setLocale, t }), [locale, setLocale, t]);
|
|
100
|
+
return <LocaleContext.Provider value={value}>{children}</LocaleContext.Provider>;
|
|
101
|
+
}
|
|
102
|
+
|
|
103
|
+
export function useLocale(): LocaleState {
|
|
104
|
+
return useContext(LocaleContext);
|
|
105
|
+
}
|
|
106
|
+
|
|
107
|
+
export function useT(): Translate {
|
|
108
|
+
return useContext(LocaleContext).t;
|
|
109
|
+
}
|