Skip to content

Commit

Permalink
🎨 i18n
Browse files Browse the repository at this point in the history
  • Loading branch information
frostime committed Jul 7, 2024
1 parent 2784926 commit 2d82de3
Show file tree
Hide file tree
Showing 10 changed files with 347 additions and 130 deletions.
114 changes: 97 additions & 17 deletions public/i18n/en_US.yaml
Original file line number Diff line number Diff line change
@@ -1,18 +1,98 @@
---
addTopBarIcon: Add a top bar icon by plugin
cancel: Cancel
save: Save
byeMenu: Bye, Menu!
helloPlugin: Hello, Plugin!
byePlugin: Bye, Plugin!
showDialog: Show dialog
removedData: Data deleted
confirmRemove: Confirm to delete the data in ${name}?
insertEmoji: Insert Emoji
removeSpace: Remove Space
getTab: Print out all opened custom tabs in the debugger
name: SiYuan
hello:
makesure: Before using this template, please read the <a href="https://github.com/siyuan-note/plugin-sample">offical sample</a>, make sure that you've known about the pipeline for plugin developing.
hintTitle: About
hintDesc: "<a href='https://github.com/siyuan-note/plugin-sample-vite-svelte'>plugin-sample-vite-svelte</a><br>@frostime<br>@88250<br>@zxkmm"
msg:
ruleFailed: 'Failed to correctly parse the configuration rule: {0}'
ruleInvalid: 'The format of the group rule input is incorrect: {0}'
itemHasInGroup: The item is already in the target group
itemNotFoundInGroup: The item was not found in the source group
groupNameEmpty: The name of the bookmark group cannot be empty!
itemErr:
closed: 'The notebook "{0}" is already closed'
deleted: 'Content block not found, it may have been deleted! Old block content: {0}'
setting:
replaceDefault:
title: Replace Built-in Bookmarks
description: If enabled, the default bookmarks will be blocked, and bookmark shortcut keys (default is Alt+3) will be bound;<br/>Takes effect after restart
viewMode:
title: Display Mode
description: Select the style of the bookmark bar display
hideClosed:
title: Hide Closed Items
description: When enabled, hide items from closed notebooks
hideDeleted:
title: Hide Invalid Items
description: When enabled, hide items that have been deleted
grouplist:
title: Bookmark Groups
description: Set up bookmark groups
viewMode:
bookmark: Bookmark Style
card: Card Style
bookmark:
new: Create New Bookmark Group
delete:
title: Delete the bookmark group {0}[{1}]?
desc: ⚠️ Cannot be recovered after deletion! Are you sure you want to delete?
cache: Cache Current Bookmarks
logo:
name: Bookmark
setting: Settings
add: Add Bookmark Group
refresh: Refresh
expand: Expand Ctrl+↓
collapse: Collapse Ctrl+↑
min: Minimize Ctrl+W
group:
msgexist: 'Cannot add: Block with ID [{0}] already exists in the bookmark group'
msg404: 'Cannot add: Block with ID [{0}] not found'
refresh: Refresh
copyref: Copy as Reference List
copylink: Copy as Link List
msgcopy: Copy Successful
docflow: Document Flow
rename: Rename Bookmark Group
edit: Edit Rule Value
delete: Delete Bookmark Group
move: Move
top: Move to Top
up: Move Up
down: Move Down
bottom: Move to Bottom
fromclipboard: Insert Block from Clipboard
msgparse: Unable to parse block from [{0}]
currentdoc: Add Current Document Block
msgdelconfirm:
- Delete bookmark item {0}?
- ⚠️ Cannot be recovered after deletion! Are you sure you want to delete?
item:
copyref: Copy as Reference
copylink: Copy as Link
msgcopy: Copy Successful
style: Style
transfer: Move to Other Group
move: Move
top: Move to Top
bottom: Move to Bottom
del: Delete Bookmark
newgroup:
name:
- Bookmark Group Name
- Please enter the name of the new bookmark group
type:
- Bookmark Group Type
- Select Bookmark Group Type
rtype:
- Rule Type
- Select Dynamic Rule Type
rinput: Rule Value
desc:
sql: Please enter the SQL query below
backlinks: Please enter the block ID of the backlink
attr: Please enter the attribute to search for; You can fill in [attribute name], or [attribute name][= or like][attribute value]
bookmarktype:
normal: 'Normal Bookmark'
dynamic: 'Dynamic Bookmark'
composed: 'Composite Bookmark'
ruletype:
sql: SQL
backlinks: Backlinks
attr: Block Attributes
117 changes: 97 additions & 20 deletions public/i18n/zh_CN.yaml
Original file line number Diff line number Diff line change
@@ -1,21 +1,98 @@
---
addTopBarIcon: 使用插件添加一个顶栏按钮
cancel: 取消
save: 保存
byeMenu: 再见,菜单!
helloPlugin: 你好,插件!
byePlugin: 再见,插件!
showDialog: 弹出一个对话框
removedData: 数据已删除
confirmRemove: 确认删除 ${name} 中的数据?
insertEmoji: 插入表情
removeSpace: 移除空格
getTab: 在日志中打印出已打开的所有自定义页签
name: 思源
hello:
makesure: 使用这个模板之前,请阅读<a href="https://github.com/siyuan-note/plugin-sample">官方教程</a>,
确保自己已经理解了插件的基本开发流程。
hintTitle: 关于
hintDesc: "<a href='https://github.com/siyuan-note/plugin-sample-vite-svelte'>\U0001F517
plugin-sample-vite-svelte</a><br>\U0001F4BB @frostime<br>\U0001F4BB @88250<br>\U0001F4BB
@zxkmm"
msg:
ruleFailed: '未能正确解析配置规则: {0}'
ruleInvalid: '分组规则输入格式有误: {0}'
itemHasInGroup: 该项已经在目标分组中
itemNotFoundInGroup: 源分组中没有找到该项
groupNameEmpty: 书签组的名称不能为空!
itemErr:
closed: '笔记本「{0}」已经关闭'
deleted: '无法找到内容块,可能已经被删除!旧块内容:{0}'
setting:
replaceDefault:
title: 替换内置书签
description: 如果启用,则屏蔽默认书签,并且绑定书签快捷键(默认为 Alt+3);<br/>重启后生效
viewMode:
title: 展示模式
description: 选择书签栏展示的样式
hideClosed:
title: 隐藏关闭项目
description: 开启后,隐藏那些来自被关闭的笔记本中的项目
hideDeleted:
title: 隐藏无效项目
description: 开启后,隐藏那些被删除的项目
grouplist:
title: 书签组
description: 设置书签组
viewMode:
bookmark: 书签样式
card: 卡片样式
bookmark:
new: 新建书签组
delete:
title: 是否删除书签组{0}[{1}]?
desc: ⚠️ 删除后无法恢复!确定删除吗?
cache: 缓存当前书签
logo:
name: 书签
setting: 设置
add: 添加书签组
refresh: 刷新
expand: 展开 Ctrl+↓
collapse: 折叠 Ctrl+↑
min: 最小化 Ctrl+W
group:
msgexist: '无法添加: 书签组中已存在 ID 为 [{0}] 的块'
msg404: '无法添加: 未找到 ID 为 [{0}] 的块'
refresh: 刷新
copyref: 复制为引用列表
copylink: 复制为链接列表
msgcopy: 复制成功
docflow: 文档流
rename: 重命名书签组
edit: 更改规则值
delete: 删除书签组
move: 移动
top: 置顶
up: 上移
down: 下移
bottom: 置底
fromclipboard: 从剪贴板中插入块
msgparse: 无法从[{0}]中解析到块
currentdoc: 添加当前文档块
msgdelconfirm:
- 是否删除书签项目{0}?
- ⚠️ 删除后无法恢复!确定删除吗?
item:
copyref: 复制为引用
copylink: 复制为链接
msgcopy: 复制为引用
style: 样式
transfer: 移动到其他分组
move: 移动
top: 置顶
bottom: 置底
del: 删除书签
newgroup:
name:
- 书签组名称
- 请输入新建书签组名称
type:
- 书签组类型
- 选择书签组类型
rtype:
- 规则类型
- 选择动态规则类型
rinput: 规则取值
desc:
sql: 请在下方输入 SQL 查询
backlinks: 请输入反链的块 ID
attr: 请输入要查找的属性; 可以填写 [属性名], 或者 [属性名][= 或 like][属性值]
bookmarktype:
normal: '普通书签'
dynamic: '动态书签'
composed: '复合书签'
ruletype:
sql: SQL
backlinks: 反向链接
attr: 块属性
34 changes: 20 additions & 14 deletions src/components/bookmark.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -10,6 +10,8 @@ import { BookmarkContext } from "./context";
import Setting from './setting';
import NewGroup from "./new-group";

import { i18n, renderI18n } from "@/utils/i18n";

interface Props {
plugin: Plugin;
model: BookmarkDataModel;
Expand All @@ -35,7 +37,7 @@ const createNewGroup = (confirmCb: (data: any) => void) => {
}
}), container);
confirmDialog({
title: "新建书签组",
title: i18n.bookmark.new,
content: container,
width: '600px',
confirm: () => {
Expand All @@ -46,6 +48,8 @@ const createNewGroup = (confirmCb: (data: any) => void) => {

const BookmarkComponent: Component<Props> = (props) => {

const I18N = i18n.bookmark;

const [fnRotate, setFnRotate] = createSignal("");

type TAction = "" | "AllExpand" | "AllCollapse";
Expand All @@ -61,7 +65,7 @@ const BookmarkComponent: Component<Props> = (props) => {
container.classList.add("fn__flex-1", "fn__flex");
render(() => Setting(), container);
simpleDialog({
title: "书签设置",
title: "Setting",
ele: container,
width: '600px',
height: '700px',
Expand All @@ -76,7 +80,7 @@ const BookmarkComponent: Component<Props> = (props) => {
console.log(result);
let { group, rule } = result;
if (group.name === "") {
showMessage("书签组的名称不能为空!", 3000, 'error');
showMessage(i18n.msg.groupNameEmpty, 3000, 'error');
return;
}
props.model.newGroup(group.name, group.type, rule);
Expand All @@ -94,8 +98,10 @@ const BookmarkComponent: Component<Props> = (props) => {

const groupDelete = (detail: IBookmarkGroup) => {
confirm(
`是否删除书签组${detail.name}[${detail.id}]?`,
"⚠️ 删除后无法恢复!确定删除吗?",
// `是否删除书签组${detail.name}[${detail.id}]?`,
renderI18n(i18n.bookmark.delete.title, detail.name, detail.id),
i18n.bookmark.delete.desc,
// "⚠️ 删除后无法恢复!确定删除吗?",
() => {
props.model.delGroup(detail.id)
}
Expand Down Expand Up @@ -125,14 +131,14 @@ const BookmarkComponent: Component<Props> = (props) => {
const bookmarkContextMenu = (e: MouseEvent) => {
const menu = new Menu();
menu.addItem({
label: "缓存当前书签",
label: i18n.bookmark.cache,
icon: "iconDownload",
click: () => {
const time = new Date();
const timeStr = `${time.getFullYear()}-${time.getMonth() + 1}-${time.getDate()} ${time.getHours()}_${time.getMinutes()}_${time.getSeconds()}`;
const name = `Cache/bookmarks-${timeStr}.json`;
props.model.save(name);
showMessage(`缓存成功: ${name}`);
showMessage(`${name}`);
},
});
menu.open({
Expand All @@ -151,13 +157,13 @@ const BookmarkComponent: Component<Props> = (props) => {
<svg class="block__logoicon">
<use href="#iconBookmark"></use>
</svg>
书签
{I18N.logo.name}
</div>
<span class="fn__flex-1"></span>
<span
data-type="setting"
class="block__icon ariaLabel"
aria-label="设置"
aria-label={I18N.logo.setting}
onClick={openSetting}
>
<svg class="">
Expand All @@ -168,7 +174,7 @@ const BookmarkComponent: Component<Props> = (props) => {
<span
data-type="add"
class="block__icon ariaLabel"
aria-label="添加书签组"
aria-label={I18N.logo.add}
onClick={groupAdd}
>
<svg class="">
Expand All @@ -179,7 +185,7 @@ const BookmarkComponent: Component<Props> = (props) => {
<span
data-type="refresh"
class="block__icon ariaLabel"
aria-label="刷新"
aria-label={I18N.logo.refresh}
onClick={bookmarkRefresh}
>
<svg class={fnRotate()}>
Expand All @@ -190,7 +196,7 @@ const BookmarkComponent: Component<Props> = (props) => {
<span
data-type="expand"
class="block__icon ariaLabel"
aria-label="展开 Ctrl+↓"
aria-label={I18N.logo.expand}
onClick={() => {
setDoAction('AllExpand');
}}
Expand All @@ -203,7 +209,7 @@ const BookmarkComponent: Component<Props> = (props) => {
<span
data-type="collapse"
class="block__icon ariaLabel"
aria-label="折叠 Ctrl+↑"
aria-label={I18N.logo.collapse}
onClick={() => {
setDoAction('AllCollapse');
}}
Expand All @@ -216,7 +222,7 @@ const BookmarkComponent: Component<Props> = (props) => {
<span
data-type="min"
class="block__icon ariaLabel"
aria-label="最小化 Ctrl+W"
aria-label={I18N.logo.min}
>
<svg>
<use href="#iconMin"></use>
Expand Down
Loading

0 comments on commit 2d82de3

Please sign in to comment.