mirror of
https://github.com/siyuan-note/siyuan.git
synced 2025-05-04 03:31:31 +08:00
🎨 Improve petal loading https://github.com/siyuan-note/bazaar/pull/1546
This commit is contained in:
parent
d0ad863651
commit
10c3d10145
@ -134,7 +134,7 @@ func loadCode(petal *Petal) {
|
|||||||
langJSONs, readErr := os.ReadDir(i18nDir)
|
langJSONs, readErr := os.ReadDir(i18nDir)
|
||||||
if nil != readErr {
|
if nil != readErr {
|
||||||
logging.LogErrorf("read plugin [%s] i18n failed: %s", petal.Name, readErr)
|
logging.LogErrorf("read plugin [%s] i18n failed: %s", petal.Name, readErr)
|
||||||
} else {
|
} else if 0 < len(langJSONs) {
|
||||||
preferredLang := Conf.Lang + ".json"
|
preferredLang := Conf.Lang + ".json"
|
||||||
foundPreferredLang := false
|
foundPreferredLang := false
|
||||||
foundEnUS := false
|
foundEnUS := false
|
||||||
@ -166,7 +166,8 @@ func loadCode(petal *Petal) {
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
data, err = filelock.ReadFile(filepath.Join(i18nDir, preferredLang))
|
if langFilePath := filepath.Join(i18nDir, preferredLang); gulu.File.IsExist(langFilePath) {
|
||||||
|
data, err = filelock.ReadFile(langFilePath)
|
||||||
if err != nil {
|
if err != nil {
|
||||||
logging.LogErrorf("read plugin [%s] i18n failed: %s", petal.Name, err)
|
logging.LogErrorf("read plugin [%s] i18n failed: %s", petal.Name, err)
|
||||||
} else {
|
} else {
|
||||||
@ -178,6 +179,7 @@ func loadCode(petal *Petal) {
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
}
|
||||||
|
|
||||||
var petalsStoreLock = sync.Mutex{}
|
var petalsStoreLock = sync.Mutex{}
|
||||||
|
|
||||||
|
Loading…
Reference in New Issue
Block a user