fix(pages): populate defaults before translation overlay
Some checks failed
Build and Release / Create Release (push) Successful in 0s
Build and Release / Integration Tests (PostgreSQL) (push) Successful in 2m48s
Build and Release / Unit Tests (push) Successful in 8m44s
Build and Release / Lint (push) Successful in 9m14s
Build and Release / Build Binaries (arm64, darwin, macos) (push) Failing after 0s
Build and Release / Build Binaries (amd64, darwin, macos) (push) Successful in 3m49s
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 9h4m56s
Build and Release / Build Binary (linux/arm64) (push) Failing after 17m26s
Some checks failed
Build and Release / Create Release (push) Successful in 0s
Build and Release / Integration Tests (PostgreSQL) (push) Successful in 2m48s
Build and Release / Unit Tests (push) Successful in 8m44s
Build and Release / Lint (push) Successful in 9m14s
Build and Release / Build Binaries (arm64, darwin, macos) (push) Failing after 0s
Build and Release / Build Binaries (amd64, darwin, macos) (push) Successful in 3m49s
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 9h4m56s
Build and Release / Build Binary (linux/arm64) (push) Failing after 17m26s
Add ensureTemplateDefaults function that fills navigation labels and section headlines with template-specific defaults before applying translation overlay. Ensures these fields are present in base config JSON so translations can override them via deep-merge. Fixes issue where translated labels wouldn't apply because base config had empty strings instead of default values. Prevents templates from falling back to hardcoded English text.
This commit is contained in:
@@ -1174,6 +1174,11 @@ func detectPageLanguage(ctx *context.Context, config *pages_module.LandingConfig
|
||||
// applyLanguageOverlay loads the translation for the detected language and merges it onto config.
|
||||
// Sets template data for the language switcher and returns the (possibly merged) config.
|
||||
func applyLanguageOverlay(ctx *context.Context, repo *repo_model.Repository, config *pages_module.LandingConfig) *pages_module.LandingConfig {
|
||||
// Ensure navigation labels and section headlines are populated with
|
||||
// template-specific defaults so they are present in the base config
|
||||
// for deep-merge (and so templates never fall back to hardcoded English).
|
||||
ensureTemplateDefaults(config)
|
||||
|
||||
if len(config.I18n.Languages) == 0 {
|
||||
return config
|
||||
}
|
||||
@@ -1215,6 +1220,44 @@ func applyLanguageOverlay(ctx *context.Context, repo *repo_model.Repository, con
|
||||
return merged
|
||||
}
|
||||
|
||||
// ensureTemplateDefaults fills in empty navigation labels and section headlines
|
||||
// with template-specific defaults so they are always present for serialization
|
||||
// and deep-merge. This ensures the base config JSON contains these keys, making
|
||||
// them available for the translation overlay to override.
|
||||
func ensureTemplateDefaults(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
|
||||
}
|
||||
// Section headlines — fill empty headlines with sensible defaults
|
||||
// so they appear in the base JSON and can be overridden by translations.
|
||||
if config.Blog.Enabled && config.Blog.Headline == "" {
|
||||
config.Blog.Headline = "Latest Posts"
|
||||
}
|
||||
if config.Gallery.Enabled && config.Gallery.Headline == "" {
|
||||
config.Gallery.Headline = "Gallery"
|
||||
}
|
||||
if config.Comparison.Enabled && config.Comparison.Headline == "" {
|
||||
config.Comparison.Headline = "How We Compare"
|
||||
}
|
||||
}
|
||||
|
||||
// ApproveExperiment handles the email approval link for an A/B test experiment
|
||||
func ApproveExperiment(ctx *context.Context) {
|
||||
handleExperimentAction(ctx, true)
|
||||
|
||||
Reference in New Issue
Block a user