🎨 Add i18n settings in marketplace package https://github.com/siyuan-note/siyuan/issues/8177
This commit is contained in:
parent
089a8322c7
commit
f5f5a1d428
6 changed files with 34 additions and 0 deletions
|
@ -73,6 +73,7 @@ func Icons() (icons []*Icon) {
|
|||
icon.IconURL = util.BazaarOSSServer + "/package/" + repoURL + "/icon.png"
|
||||
icon.Funding = parseFunding(repo["package"].(map[string]interface{}))
|
||||
icon.PreferredFunding = getPreferredFunding(icon.Funding)
|
||||
icon.PreferredDesc = getPreferredDesc(icon.Description)
|
||||
icon.Updated = repo["updated"].(string)
|
||||
icon.Stars = int(repo["stars"].(float64))
|
||||
icon.OpenIssues = int(repo["openIssues"].(float64))
|
||||
|
@ -137,6 +138,7 @@ func InstalledIcons() (ret []*Icon) {
|
|||
icon.IconURL = "/appearance/icons/" + dirName + "/icon.png"
|
||||
icon.Funding = parseFunding(iconConf)
|
||||
icon.PreferredFunding = getPreferredFunding(icon.Funding)
|
||||
icon.PreferredDesc = getPreferredDesc(icon.Description)
|
||||
info, statErr := os.Stat(filepath.Join(installPath, "README.md"))
|
||||
if nil != statErr {
|
||||
logging.LogWarnf("stat install theme README.md failed: %s", statErr)
|
||||
|
|
|
@ -64,6 +64,7 @@ type Package struct {
|
|||
Description *Description `json:"description"`
|
||||
Readme *Readme `json:"readme"`
|
||||
Funding *Funding `json:"funding"`
|
||||
I18N []string `json:"i18n"`
|
||||
|
||||
PreferredFunding string `json:"preferredFunding"`
|
||||
PreferredDesc string `json:"preferredDesc"`
|
||||
|
@ -112,6 +113,29 @@ func parseFunding(pkg map[string]interface{}) (ret *Funding) {
|
|||
return
|
||||
}
|
||||
|
||||
func getPreferredDesc(desc *Description) string {
|
||||
if nil == desc {
|
||||
return ""
|
||||
}
|
||||
|
||||
ret := desc.Default
|
||||
switch util.Lang {
|
||||
case "zh_CN":
|
||||
if "" != desc.ZhCN {
|
||||
ret = desc.ZhCN
|
||||
}
|
||||
case "en_US":
|
||||
if "" != desc.EnUS {
|
||||
ret = desc.EnUS
|
||||
}
|
||||
default:
|
||||
if "" != desc.EnUS {
|
||||
ret = desc.EnUS
|
||||
}
|
||||
}
|
||||
return ret
|
||||
}
|
||||
|
||||
func getPreferredFunding(funding *Funding) string {
|
||||
if nil == funding {
|
||||
return ""
|
||||
|
|
|
@ -75,6 +75,7 @@ func Plugins() (plugins []*Plugin) {
|
|||
plugin.IconURL = util.BazaarOSSServer + "/package/" + repoURL + "/icon.png"
|
||||
plugin.Funding = parseFunding(repo["package"].(map[string]interface{}))
|
||||
plugin.PreferredFunding = getPreferredFunding(plugin.Funding)
|
||||
plugin.PreferredDesc = getPreferredDesc(plugin.Description)
|
||||
plugin.Updated = repo["updated"].(string)
|
||||
plugin.Stars = int(repo["stars"].(float64))
|
||||
plugin.OpenIssues = int(repo["openIssues"].(float64))
|
||||
|
@ -142,6 +143,7 @@ func InstalledPlugins() (ret []*Plugin) {
|
|||
plugin.IconURL = "/plugins/" + dirName + "/icon.png"
|
||||
plugin.Funding = parseFunding(pluginConf)
|
||||
plugin.PreferredFunding = getPreferredFunding(plugin.Funding)
|
||||
plugin.PreferredDesc = getPreferredDesc(plugin.Description)
|
||||
info, statErr := os.Stat(filepath.Join(installPath, "README.md"))
|
||||
if nil != statErr {
|
||||
logging.LogWarnf("stat install theme README.md failed: %s", statErr)
|
||||
|
|
|
@ -75,6 +75,7 @@ func Templates() (templates []*Template) {
|
|||
template.IconURL = util.BazaarOSSServer + "/package/" + repoURL + "/icon.png"
|
||||
template.Funding = parseFunding(repo["package"].(map[string]interface{}))
|
||||
template.PreferredFunding = getPreferredFunding(template.Funding)
|
||||
template.PreferredDesc = getPreferredDesc(template.Description)
|
||||
template.Updated = repo["updated"].(string)
|
||||
template.Stars = int(repo["stars"].(float64))
|
||||
template.OpenIssues = int(repo["openIssues"].(float64))
|
||||
|
@ -144,6 +145,7 @@ func InstalledTemplates() (ret []*Template) {
|
|||
template.IconURL = "/templates/" + dirName + "/icon.png"
|
||||
template.Funding = parseFunding(templateConf)
|
||||
template.PreferredFunding = getPreferredFunding(template.Funding)
|
||||
template.PreferredDesc = getPreferredDesc(template.Description)
|
||||
info, statErr := os.Stat(filepath.Join(installPath, "README.md"))
|
||||
if nil != statErr {
|
||||
logging.LogWarnf("stat install theme README.md failed: %s", statErr)
|
||||
|
|
|
@ -76,6 +76,7 @@ func Themes() (ret []*Theme) {
|
|||
theme.IconURL = util.BazaarOSSServer + "/package/" + repoURL + "/icon.png"
|
||||
theme.Funding = parseFunding(repo["package"].(map[string]interface{}))
|
||||
theme.PreferredFunding = getPreferredFunding(theme.Funding)
|
||||
theme.PreferredDesc = getPreferredDesc(theme.Description)
|
||||
theme.Updated = repo["updated"].(string)
|
||||
theme.Stars = int(repo["stars"].(float64))
|
||||
theme.OpenIssues = int(repo["openIssues"].(float64))
|
||||
|
@ -148,6 +149,7 @@ func InstalledThemes() (ret []*Theme) {
|
|||
theme.IconURL = "/appearance/themes/" + dirName + "/icon.png"
|
||||
theme.Funding = parseFunding(themeConf)
|
||||
theme.PreferredFunding = getPreferredFunding(theme.Funding)
|
||||
theme.PreferredDesc = getPreferredDesc(theme.Description)
|
||||
info, statErr := os.Stat(filepath.Join(installPath, "README.md"))
|
||||
if nil != statErr {
|
||||
logging.LogWarnf("stat install theme README.md failed: %s", statErr)
|
||||
|
|
|
@ -75,6 +75,7 @@ func Widgets() (widgets []*Widget) {
|
|||
widget.IconURL = util.BazaarOSSServer + "/package/" + repoURL + "/icon.png"
|
||||
widget.Funding = parseFunding(repo["package"].(map[string]interface{}))
|
||||
widget.PreferredFunding = getPreferredFunding(widget.Funding)
|
||||
widget.PreferredDesc = getPreferredDesc(widget.Description)
|
||||
widget.Updated = repo["updated"].(string)
|
||||
widget.Stars = int(repo["stars"].(float64))
|
||||
widget.OpenIssues = int(repo["openIssues"].(float64))
|
||||
|
@ -142,6 +143,7 @@ func InstalledWidgets() (ret []*Widget) {
|
|||
widget.IconURL = "/widgets/" + dirName + "/icon.png"
|
||||
widget.Funding = parseFunding(widgetConf)
|
||||
widget.PreferredFunding = getPreferredFunding(widget.Funding)
|
||||
widget.PreferredDesc = getPreferredDesc(widget.Description)
|
||||
info, statErr := os.Stat(filepath.Join(installPath, "README.md"))
|
||||
if nil != statErr {
|
||||
logging.LogWarnf("stat install theme README.md failed: %s", statErr)
|
||||
|
|
Loading…
Add table
Reference in a new issue