🎨 Title localization when creating a document https://github.com/siyuan-note/siyuan/issues/10719

This commit is contained in:
Daniel 2024-03-24 22:15:19 +08:00
parent f5043a8c46
commit 2a8809bc7e
No known key found for this signature in database
GPG key ID: 86211BA83DF03017
25 changed files with 72 additions and 61 deletions

View file

@ -1738,7 +1738,7 @@ func getAvNames(avIDs string) (ret string) {
continue
}
if "" == nodeAvName {
nodeAvName = "Untitled"
nodeAvName = Conf.language(105)
}
tpl := strings.ReplaceAll(attrAvNameTpl, "${avID}", nodeAvID)

View file

@ -101,7 +101,7 @@ func GetDocInfo(blockID string) (ret *BlockInfo) {
}
if "" == avName {
avName = "Untitled"
avName = Conf.language(105)
}
attrView := &AttrView{ID: avID, Name: avName}

View file

@ -76,7 +76,7 @@ func ExportAv2CSV(avID, blockID string) (zipPath string, err error) {
name := util.FilterFileName(attrView.Name)
if "" == name {
name = "Untitled"
name = Conf.language(105)
}
table, err := renderAttributeViewTable(attrView, view, "")
@ -1375,7 +1375,7 @@ func BatchExportMarkdown(boxID, folderPath string) (zipPath string) {
baseFolderName = path.Base(block.HPath)
}
if "" == baseFolderName {
baseFolderName = "Untitled"
baseFolderName = Conf.language(105)
}
docFiles := box.ListFiles(folderPath)

View file

@ -1568,7 +1568,7 @@ func RenameDoc(boxID, p, title string) (err error) {
return
}
if "" == title {
title = "Untitled"
title = Conf.language(105)
}
title = strings.ReplaceAll(title, "/", "")
@ -1604,6 +1604,10 @@ func createDoc(boxID, p, title, dom string) (tree *parse.Tree, err error) {
return
}
title = strings.ReplaceAll(title, "/", "")
title = strings.TrimSpace(title)
if "" == title {
title = Conf.Language(105)
}
baseName := strings.TrimSpace(path.Base(p))
if "" == strings.TrimSuffix(baseName, ".sy") {

View file

@ -687,7 +687,7 @@ func indexHistoryDir(name string, luteEngine *lute.Lute) {
title := tree.Root.IALAttr("title")
if "" == title {
title = "Untitled"
title = Conf.language(105)
}
content := tree.Root.Content()
p := strings.TrimPrefix(doc, util.HistoryDir)

View file

@ -40,6 +40,9 @@ func CreateBox(name string) (id string, err error) {
err = errors.New(Conf.Language(106))
return
}
if "" == name {
name = Conf.language(105)
}
WaitForWritingFiles()
@ -67,6 +70,16 @@ func RenameBox(boxID, name string) (err error) {
return errors.New(Conf.Language(0))
}
if 512 < utf8.RuneCountInString(name) {
// 限制笔记本名和文档名最大长度为 `512`
err = errors.New(Conf.Language(106))
return
}
if "" == name {
name = Conf.language(105)
}
boxConf := box.GetConf()
boxConf.Name = name
box.Name = name