fix: HTML sitemap headings follow each locale until an editor sets one

Settings > Sitemaps no longer prefills a content type's heading with its
label in the administrator's language, so a save that did not touch the
heading stores none and each locale's HTML sitemap keeps the label
translated into it. The field's comment says so.
This commit is contained in:
Jakub Zych
2026-11-04 23:08:38 +01:00
parent b37b2265ed
commit da32044d5b
5 changed files with 137 additions and 5 deletions

View File

@@ -80,6 +80,7 @@ func typeSettingsDocument(types []pact.MenuItemType) ([]byte, error) {
}},
yaml.MapItem{Key: base + "title", Value: yaml.MapSlice{
{Key: "label", Value: "golem15.sitemap::lang.settings.type_title"},
{Key: "comment", Value: "golem15.sitemap::lang.settings.type_title_comment"},
{Key: "type", Value: "mltext"},
{Key: "span", Value: "full"},
{Key: "tab", Value: TabTypes},
@@ -118,17 +119,18 @@ func (p *Plugin) typeSettingsTab(types []pact.MenuItemType) *pact.AdminFormExten
if err != nil {
return nil, err
}
def := p.defaultLocale(ctx, in.DB)
tr := p.translator()
out := map[string]any{}
for _, typ := range types {
cfg := classes.EffectiveType(typ, rows)
base := classes.TypeFieldBase(typ.Key)
out[base+"include"] = cfg.Include
out[base+"slug"] = cfg.Slug
// Only stored headings (L2 WR-05): a type without one loads
// empty, so a save that did not touch it stores none and each
// locale's HTML sitemap keeps the label translated into it.
titles := cfg.Titles
if len(titles) == 0 {
titles = map[string]string{def: controllers.Phrase(ctx, tr, typ.Label, nil)}
if titles == nil {
titles = map[string]string{}
}
out[base+"title"] = titles
}