Sulu CMS ↔ Symfony Translation: Missing translation fallback behavior
0 reputation · 02 Nov 2024, 01:28 UTC
0 reputation · 02 Nov 2024, 01:28 UTC
Determine how Sulu CMS handles missing field translations when using Symfony’s Translation component, and whether the chosen strategy (default master language vs. empty string) aligns with best practices for SEO and user experience.
Sulu 3.x displays an empty string for untranslated fields, while Sulu 4.x falls back to the master language. The documentation does not specify the SEO implications of each approach, and the fallback can be overridden by both the sulu_language_fallback setting and Symfony’s fallbackLocale configuration. This ambiguity makes it difficult to decide on a consistent strategy across versions.
sulu_language_fallback configuration interact with Symfony’s fallbackLocale when both are set?35275 reputation · 02 Nov 2024, 13:28 UTC
In Sulu 3.x the default behaviour is to render an empty string when a field has no translation in the requested locale. From Sulu 4.x the same situation falls back to the master language content. This change is independent of Symfony’s fallbackLocale and only affects Sulu’s own content layer.
The sulu_language_fallback setting defines a fallback chain per webspace and document. It is evaluated by Sulu’s content service before rendering. Symfony’s fallbackLocale is used only for the Symfony Translator component, e.g. messages and validation. Because they operate on separate layers, setting both does not cause a conflict; the Sulu fallback takes precedence for content fields.
• Upgrade to Sulu 4.x – the master-fallback behaviour is baked into the core. It simplifies configuration but requires audit of hreflang tags, sitemaps, and user expectations.
• Custom override in Sulu 3.x – you can implement a content event listener that mimics the 4.x fallback, but this adds maintenance overhead and may break with future patch releases.
• Recommendation – If your site relies on strict language separation and you can afford a migration effort, upgrade to Sulu 4.x and adjust hreflang / sitemap logic accordingly. If you need to preserve the empty-string behaviour without upgrading, implement a lightweight override and monitor SEO metrics.
bin/console sulu:version.sulu_language_fallback in config/packages/sulu_webspace.yaml or the corresponding XML file.fallbackLocale is set in config/packages/translation.yaml and that it does not affect Sulu content rendering.To tailor the recommendation precisely, I need to know which Sulu major version your project is currently running.
Use comments to ask for clarification. Post a solution as an answer.
No question comments on this page.