diff --git a/README.md b/README.md
index 981ca43..3c233a7 100644
--- a/README.md
+++ b/README.md
@@ -65,8 +65,11 @@ complete the following tasks:
* Meta information about the plugin itself, such as plugin description and readme
* `description` and `readme` fields in plugin.json, and the corresponding README*.md file
* Text used in the plugin, such as button text and tooltips
- * src/i18n/*.json language configuration files
+ * public/i18n/*.json language configuration files
* Use `this.i18.key` to get the text in the code
+* YAML Support
+ * This template specifically supports I18n based on YAML syntax, see `public/i18n/zh_CN.yaml`
+ * During compilation, the defined YAML files will be automatically translated into JSON files and placed in the dist or dev directory.
It is recommended that the plugin supports at least English and Simplified Chinese, so that more people can use it more
conveniently.
@@ -246,43 +249,12 @@ Related APIs can be found at: `/api/file/*` (e.g., `/api/file/getFile`).
### 2. Daily Note Attribute Specifications
-When creating a diary in SiYuan, a custom-dailynote-yyyymmdd attribute will be automatically added to the document to distinguish it from regular documents.
+When creating a daily note in SiYuan, a custom-dailynote-yyyymmdd attribute will be automatically added to the document to distinguish it from regular documents.
> For more details, please refer to [Github Issue #9807](https://github.com/siyuan-note/siyuan/issues/9807).
Developers should pay attention to the following when developing the functionality to manually create Daily Notes:
-- If `/api/filetree/createDailyNote` is called to create a diary, the attribute will be automatically added to the document, and developers do not need to handle it separately.
-- If a document is created manually by developer's code (e.g., using the `createDocWithMd` API to create a diary), please manually add this attribute to the document.
+* If `/api/filetree/createDailyNote` is called to create a daily note, the attribute will be automatically added to the document, and developers do not need to handle it separately
+* If a document is created manually by developer's code (e.g., using the `createDocWithMd` API to create a daily note), please manually add this attribute to the document
-Here is a reference code:
-
-```ts
-/*
- * Copyright (c) 2023 by frostime. All Rights Reserved.
- * @Author : frostime
- * @Url : https://github.com/frostime/siyuan-dailynote-today/blob/v1.3.0/src/func/dailynote/dn-attr.ts
- */
-
-export function formatDate(date?: Date, sep=''): string {
- date = date === undefined ? new Date() : date;
- let year = date.getFullYear();
- let month = date.getMonth() + 1;
- let day = date.getDate();
- return `${year}${sep}${month < 10 ? '0' + month : month}${sep}${day < 10 ? '0' + day : day}`;
-}
-
-/**
- * Set custom attribute: `custom-dailynote-yyyyMMdd`: yyyyMMdd
- * https://github.com/siyuan-note/siyuan/issues/9807
- * @param doc_id Id of daily note
- */
-export function setCustomDNAttr(doc_id: string, date?: Date) {
- let td = formatDate(date);
- let attr = `custom-dailynote-${td}`;
- // 构建 attr: td
- let attrs: { [key: string]: string } = {};
- attrs[attr] = td;
- serverApi.setBlockAttrs(doc_id, attrs);
-}
-```
diff --git a/README_zh_CN.md b/README_zh_CN.md
index b2d3ad3..1510f9b 100644
--- a/README_zh_CN.md
+++ b/README_zh_CN.md
@@ -62,9 +62,12 @@
* 插件自身的元信息,比如插件描述和自述文件
* plugin.json 中的 `description` 和 `readme` 字段,以及对应的 README*.md 文件
* 插件中使用的文本,比如按钮文字和提示信息
- * src/i18n/*.json 语言配置文件
+ * public/i18n/*.json 语言配置文件
* 代码中使用 `this.i18.key` 获取文本
* 最后在 plugin.json 中的 `i18n` 字段中声明该插件支持的语言
+* yaml 支持
+ * 本模板特别支持基于 Yaml 语法的 I18n,见 `public/i18n/zh_CN.yaml`
+ * 编译时,会自动把定义的 yaml 文件翻译成 json 文件放到 dist 或 dev 目录下
建议插件至少支持英文和简体中文,这样可以方便更多人使用。
@@ -234,47 +237,15 @@ PR 社区集市仓库。
插件或者外部扩展如果有直接读取或者写入 data 下文件的需求,请通过调用内核 API 来实现,**不要自行调用 `fs` 或者其他 electron、nodejs API**,否则可能会导致数据同步时分块丢失,造成云端数据损坏。
-相关 API 见: `/api/file/*`(例如 `/api/file/getFile` 等)。
+相关 API 见 `/api/file/*`(例如 `/api/file/getFile` 等)。
### 2. Daily Note 属性规范
-思源在创建日记的时候会自动为文档添加 custom-dailynote-yyyymmdd 属性, 以方便将日记文档同普通文档区分。
+思源在创建日记的时候会自动为文档添加 custom-dailynote-yyyymmdd 属性,以方便将日记文档同普通文档区分。
> 详情请见 [Github Issue #9807](https://github.com/siyuan-note/siyuan/issues/9807)。
开发者在开发手动创建 Daily Note 的功能时请注意:
-- 如果调用了 `/api/filetree/createDailyNote` 创建日记,那么文档会自动添加这个属性,无需开发者特别处理。
-- 如果是开发者代码手动创建文档(例如使用 `createDocWithMd` API 创建日记),请手动为文档添加该属性。
-
-参考代码:
-
-```ts
-/*
- * Copyright (c) 2023 by frostime. All Rights Reserved.
- * @Author : frostime
- * @Url : https://github.com/frostime/siyuan-dailynote-today/blob/v1.3.0/src/func/dailynote/dn-attr.ts
- */
-
-export function formatDate(date?: Date, sep=''): string {
- date = date === undefined ? new Date() : date;
- let year = date.getFullYear();
- let month = date.getMonth() + 1;
- let day = date.getDate();
- return `${year}${sep}${month < 10 ? '0' + month : month}${sep}${day < 10 ? '0' + day : day}`;
-}
-
-/**
- * Set custom attribute: `custom-dailynote-yyyyMMdd`: yyyyMMdd
- * https://github.com/siyuan-note/siyuan/issues/9807
- * @param doc_id Id of daily note
- */
-export function setCustomDNAttr(doc_id: string, date?: Date) {
- let td = formatDate(date);
- let attr = `custom-dailynote-${td}`;
- // 构建 attr: td
- let attrs: { [key: string]: string } = {};
- attrs[attr] = td;
- serverApi.setBlockAttrs(doc_id, attrs);
-}
-```
+* 如果调用了 `/api/filetree/createDailyNote` 创建日记,那么文档会自动添加这个属性,无需开发者特别处理
+* 如果是开发者代码手动创建文档(例如使用 `createDocWithMd` API 创建日记),请手动为文档添加该属性
diff --git a/package.json b/package.json
index 3b29e49..df94e90 100644
--- a/package.json
+++ b/package.json
@@ -11,24 +11,25 @@
"make-link": "node --no-warnings ./scripts/make_dev_link.js",
"dev": "vite build --watch",
"build": "vite build",
- "install": "vite build && node --no-warnings ./scripts/make_install.js"
+ "make-install": "vite build && node --no-warnings ./scripts/make_install.js"
},
"devDependencies": {
- "@sveltejs/vite-plugin-svelte": "^2.4.1",
+ "@sveltejs/vite-plugin-svelte": "^3.0.0",
"@tsconfig/svelte": "^4.0.1",
"@types/node": "^20.3.0",
"eslint": "^8.42.0",
"fast-glob": "^3.2.12",
"glob": "^7.2.3",
+ "js-yaml": "^4.1.0",
"minimist": "^1.2.8",
"rollup-plugin-livereload": "^2.0.5",
"sass": "^1.63.3",
- "siyuan": "0.9.4",
- "svelte": "^3.59.1",
+ "siyuan": "0.9.7",
+ "svelte": "^4.2.0",
"ts-node": "^10.9.1",
"typescript": "^5.1.3",
- "vite": "^4.5.2",
- "vite-plugin-static-copy": "^0.15.0",
+ "vite": "^5.0.0",
+ "vite-plugin-static-copy": "^1.0.2",
"vite-plugin-zip-pack": "^1.0.5"
}
}
diff --git a/public/i18n/zh_CN.json b/public/i18n/zh_CN.json
deleted file mode 100644
index 9b6231e..0000000
--- a/public/i18n/zh_CN.json
+++ /dev/null
@@ -1,21 +0,0 @@
-{
- "addTopBarIcon": "使用插件添加一个顶栏按钮",
- "cancel": "取消",
- "save": "保存",
- "byeMenu": "再见,菜单!",
- "helloPlugin": "你好,插件!",
- "byePlugin": "再见,插件!",
- "showDialog": "弹出一个对话框",
- "removedData": "数据已删除",
- "confirmRemove": "确认删除 ${name} 中的数据?",
- "insertEmoji": "插入表情",
- "removeSpace": "移除空格",
- "getTab": "在日志中打印出已打开的所有自定义页签",
- "name": "思源",
- "hello": {
- "makesure": "使用这个模板之前,请阅读官方教程, 确保自己已经理解了插件的基本开发流程。"
- },
- "hintTitle":"关于",
- "hintDesc":"🔗 plugin-sample-vite-svelte
💻 @frostime
💻 @88250
💻 @zxkmm"
-
-}
\ No newline at end of file
diff --git a/public/i18n/zh_CN.yaml b/public/i18n/zh_CN.yaml
new file mode 100644
index 0000000..16099a3
--- /dev/null
+++ b/public/i18n/zh_CN.yaml
@@ -0,0 +1,21 @@
+---
+addTopBarIcon: 使用插件添加一个顶栏按钮
+cancel: 取消
+save: 保存
+byeMenu: 再见,菜单!
+helloPlugin: 你好,插件!
+byePlugin: 再见,插件!
+showDialog: 弹出一个对话框
+removedData: 数据已删除
+confirmRemove: 确认删除 ${name} 中的数据?
+insertEmoji: 插入表情
+removeSpace: 移除空格
+getTab: 在日志中打印出已打开的所有自定义页签
+name: 思源
+hello:
+ makesure: 使用这个模板之前,请阅读官方教程,
+ 确保自己已经理解了插件的基本开发流程。
+hintTitle: 关于
+hintDesc: "\U0001F517
+ plugin-sample-vite-svelte
\U0001F4BB @frostime
\U0001F4BB @88250
\U0001F4BB
+ @zxkmm"
diff --git a/src/setting-example.svelte b/src/setting-example.svelte
index 3ae156a..5f8958b 100644
--- a/src/setting-example.svelte
+++ b/src/setting-example.svelte
@@ -63,6 +63,7 @@