2
0

feat(pages): add navigation label translation support
All checks were successful
Build and Release / Create Release (push) Successful in 0s
Build and Release / Integration Tests (PostgreSQL) (push) Successful in 4m4s
Build and Release / Unit Tests (push) Successful in 4m38s
Build and Release / Lint (push) Successful in 6m26s
Build and Release / Build Binaries (amd64, darwin, macos) (push) Successful in 3m52s
Build and Release / Build Binaries (amd64, linux, linux-latest) (push) Successful in 4m52s
Build and Release / Build Binaries (amd64, windows, windows-latest) (push) Successful in 9h5m22s
Build and Release / Build Binaries (arm64, darwin, macos) (push) Successful in 3m38s
Build and Release / Build Binary (linux/arm64) (push) Successful in 7m46s

Add translation support for navigation section labels (Value Props, Features, Pricing, Blog, Gallery, Compare, etc.). Adds TemplateDefaultLabels function that returns template-specific creative names (e.g., "Systems Analysis" for value props in Architecture Deep Dive). Auto-applies defaults when enabling pages or changing templates. Includes UI fields in languages settings and translation JSON serialization. Enables full localization of section headings.
This commit is contained in:
2026-03-17 23:34:29 -04:00
parent 17028589c8
commit 965ef8966f
5 changed files with 186 additions and 9 deletions

View File

@@ -87,6 +87,31 @@ func savePagesLandingConfig(ctx *context.Context, config *pages_module.LandingCo
return repo_model.UpdatePagesConfig(ctx, dbConfig)
}
// applyTemplateDefaultLabels populates Navigation label fields with
// template-specific defaults. Existing non-empty labels are preserved.
func applyTemplateDefaultLabels(config *pages_module.LandingConfig) {
defaults := pages_module.TemplateDefaultLabels(config.Template)
nav := &config.Navigation
if nav.LabelValueProps == "" {
nav.LabelValueProps = defaults.LabelValueProps
}
if nav.LabelFeatures == "" {
nav.LabelFeatures = defaults.LabelFeatures
}
if nav.LabelPricing == "" {
nav.LabelPricing = defaults.LabelPricing
}
if nav.LabelBlog == "" {
nav.LabelBlog = defaults.LabelBlog
}
if nav.LabelGallery == "" {
nav.LabelGallery = defaults.LabelGallery
}
if nav.LabelCompare == "" {
nav.LabelCompare = defaults.LabelCompare
}
}
// setCommonPagesData sets common data for all pages settings pages
func setCommonPagesData(ctx *context.Context) {
config := getPagesLandingConfig(ctx)
@@ -141,6 +166,7 @@ func PagesPost(ctx *context.Context) {
config := getPagesLandingConfig(ctx)
config.Enabled = true
config.Template = template
applyTemplateDefaultLabels(config)
if err := savePagesLandingConfig(ctx, config); err != nil {
ctx.ServerError("EnablePages", err)
return
@@ -161,6 +187,7 @@ func PagesPost(ctx *context.Context) {
}
config := getPagesLandingConfig(ctx)
config.Template = template
applyTemplateDefaultLabels(config)
if err := savePagesLandingConfig(ctx, config); err != nil {
ctx.ServerError("UpdateTemplate", err)
return
@@ -766,6 +793,17 @@ type TranslationView struct {
// SEO
SEOTitle string
SEODescription string
// Navigation labels
NavLabelValueProps string
NavLabelFeatures string
NavLabelPricing string
NavLabelBlog string
NavLabelGallery string
NavLabelCompare string
NavLabelDocs string
NavLabelReleases string
NavLabelAPI string
NavLabelIssues string
}
// overlayString extracts a string from a map
@@ -938,6 +976,20 @@ func parseTranslationView(t *pages_model.Translation, config *pages_module.Landi
view.SEODescription = overlayString(seo, "description")
}
// Navigation labels
if nav, ok := overlay["navigation"].(map[string]any); ok {
view.NavLabelValueProps = overlayString(nav, "label_value_props")
view.NavLabelFeatures = overlayString(nav, "label_features")
view.NavLabelPricing = overlayString(nav, "label_pricing")
view.NavLabelBlog = overlayString(nav, "label_blog")
view.NavLabelGallery = overlayString(nav, "label_gallery")
view.NavLabelCompare = overlayString(nav, "label_compare")
view.NavLabelDocs = overlayString(nav, "label_docs")
view.NavLabelReleases = overlayString(nav, "label_releases")
view.NavLabelAPI = overlayString(nav, "label_api")
view.NavLabelIssues = overlayString(nav, "label_issues")
}
return view
}
@@ -1159,6 +1211,21 @@ func buildTranslationJSON(ctx *context.Context) string {
overlay["seo"] = seo
}
// Navigation labels
nav := map[string]any{}
for _, key := range []string{
"label_value_props", "label_features", "label_pricing",
"label_blog", "label_gallery", "label_compare",
"label_docs", "label_releases", "label_api", "label_issues",
} {
if v := ctx.FormString("trans_nav_" + key); v != "" {
nav[key] = v
}
}
if len(nav) > 0 {
overlay["navigation"] = nav
}
if len(overlay) == 0 {
return ""
}