fix(cabana): send the default content locale first in enabledLocales

- enabledContentLocales moves TranslationWriter.DefaultLocale to index 0
  and keeps the other enabled codes in the writer's order
- every ML control opens on enabledLocales[0], so the form now shows the
  host-column values (content, excerpt, title, slug) instead of an empty
  non-default locale
- a DefaultLocale error is logged and keeps the writer's order
- README and forms docs: default locale first
This commit is contained in:
2026-10-09 20:58:12 +02:00
parent 06d75cb654
commit bd8626e5fc
4 changed files with 41 additions and 3 deletions

View File

@@ -980,6 +980,17 @@ func (s *service) enabledContentLocales(ctx context.Context) []string {
slog.Error("cabana: enabled locales", "error", err)
return nil
}
// The SPA opens every ML control on the first code, and the default
// locale's values live in the host columns, so the default goes first
// and the other codes keep the writer's order.
def, err := writer.DefaultLocale(ctx, db)
if err != nil {
slog.Error("cabana: default locale", "error", err)
return codes
}
if i := slices.Index(codes, def); def != "" && i > 0 {
codes = append([]string{def}, slices.Delete(slices.Clone(codes), i, i+1)...)
}
return codes
}