Skip to content

An open-source, privacy-first, self-hosted knowledge workspace where humans and AI agents work together 开源、隐私优先、自托管的知识工作空间,让人与智能体在此协作

:art: Improve petal loading https://github.com/siyuan-note/bazaar/pull/1546

Daniel10c3d10145c5
diff --git a/kernel/model/plugin.go b/kernel/model/plugin.go
index 8f2806c049..2af31d7bd8 100644
--- a/kernel/model/plugin.go
+++ b/kernel/model/plugin.go
@@ -134,7 +134,7 @@ func loadCode(petal *Petal) {
langJSONs, readErr := os.ReadDir(i18nDir)
if nil != readErr {
logging.LogErrorf("read plugin [%s] i18n failed: %s", petal.Name, readErr)
- } else {
+ } else if 0 < len(langJSONs) {
preferredLang := Conf.Lang + ".json"
foundPreferredLang := false
foundEnUS := false
@@ -166,13 +166,15 @@ func loadCode(petal *Petal) {
}
}
- data, err = filelock.ReadFile(filepath.Join(i18nDir, preferredLang))
- if err != nil {
- logging.LogErrorf("read plugin [%s] i18n failed: %s", petal.Name, err)
- } else {
- petal.I18n = map[string]interface{}{}
- if err = gulu.JSON.UnmarshalJSON(data, &petal.I18n); err != nil {
- logging.LogErrorf("unmarshal plugin [%s] i18n failed: %s", petal.Name, err)
+ if langFilePath := filepath.Join(i18nDir, preferredLang); gulu.File.IsExist(langFilePath) {
+ data, err = filelock.ReadFile(langFilePath)
+ if err != nil {
+ logging.LogErrorf("read plugin [%s] i18n failed: %s", petal.Name, err)
+ } else {
+ petal.I18n = map[string]interface{}{}
+ if err = gulu.JSON.UnmarshalJSON(data, &petal.I18n); err != nil {
+ logging.LogErrorf("unmarshal plugin [%s] i18n failed: %s", petal.Name, err)
+ }
}
}
}