Files
aego/editor/shell/meta.go
sanspie 2fcbaa6c12 Stage 11g1: the editor in Russian (D348)
engine/i18n with catalogs, plural forms and module catalogs; tools/i18n extract and check; the editor UI, menus, panels and notices in Russian with the author's terms; overflow test and tooltip wrapping; the English log.
2026-10-25 15:31:22 +03:00

61 lines
1.4 KiB
Go

package shell
import (
"slices"
"strconv"
"strings"
"aego/editor/core/command"
"aego/editor/core/context"
"aego/engine/i18n"
)
const CommandRepairMeta = "assets.repair_meta"
func (a *App) registerMeta() error {
pl := a.opt.Pipeline
if pl == nil {
return nil
}
return a.ctx.Commands.Register(command.Desc{
ID: CommandRepairMeta, Name: "Repair Meta Files…", Category: "Assets", Order: 300,
Enabled: func() bool {
l, _ := pl.MetaIssues()
return len(l) > 0 && !pl.Shared()
},
Run: a.repairMeta,
})
}
func (a *App) repairMeta() error {
pl := a.opt.Pipeline
list, _ := pl.MetaIssues()
issues := slices.Clone(list)
var b strings.Builder
for i, is := range issues {
if i == 8 {
b.WriteString("and " + strconv.Itoa(len(issues)-i) + " more")
break
}
b.WriteString(is.Action() + "\n")
}
a.ctx.Ask(context.Question{
Title: i18n.Tr("editor.shell.repair_meta_files", "Repair meta files"),
Message: b.String(),
Buttons: []string{i18n.Tr("editor.shell.repair", "Repair"), i18n.Tr("editor.shell.cancel", "Cancel")},
Then: func(choice int) {
if choice != 0 {
return
}
n, err := pl.Repair(issues)
a.ctx.AssetRev++
if err != nil {
a.ctx.Notify(context.LevelError, err.Error())
return
}
a.ctx.Notify(context.LevelInfo, i18n.Note("editor.shell.repaired_n_meta_issue_s", "Repaired {n} meta issue(s)", i18n.Str("n", strconv.Itoa(n))))
},
})
return nil
}