belsignum / languagemodes
Change languages modes - 'free, fallback, strict' individually for pages
Installs: 0
Dependents: 0
Suggesters: 0
Security: 0
Stars: 0
Watchers: 1
Forks: 0
Open Issues: 0
Type:typo3-cms-extension
Requires
- typo3/cms-core: ^12.4
This package is not auto-updated.
Last update: 2025-04-02 21:11:37 UTC
README
This TYPO3 extension allows you to dynamically override the fallbackType
for SiteLanguage
per page and language at runtime.
🧩 Features
- Define language fallback behavior (
free
,fallback
,strict
) per language version of each page - Fully compatible with TYPO3 v12
- Uses
SiteFinder
andSiteConfiguration
XCLASS for clean and early injection - Modifies both
SiteLanguage
andLanguageAspect
at runtime - Configuration is cached safely and applies consistently across the TYPO3 request lifecycle
- No core patch required since v12
🔧 How it works
- A
select
field is added to thepages
table (tx_languagemodes_mode
) - This field is only visible in translated pages (i.e.,
sys_language_uid > 0
) - When a page is resolved, the SiteFinder XCLASS loads the language-specific configuration from the DB and replaces the SiteLanguage for the current request
- Additionally, the
LanguageAspect
is updated to ensure proper behavior in content fetching and overlays
🛠 Installation
Install via Composer:
composer require belsignum/languagemodes
⚙️ Configuration
No special configuration needed. Once the extension is installed:
- Open the page module
- Switch to a language version of a page (not the default language)
- You will see a select field labeled
Language fallback mode
with the options:- Free
- Fallback
- Strict
If no value is selected, the global fallback behavior from the site config applies.
🧠 Why we use SiteFinder
/ SiteConfiguration
– and not Middleware, Events or Hooks
TYPO3 offers multiple ways to influence site and language resolution. After extensive evaluation, this extension intentionally avoids Middleware or Event-based approaches for the following reasons:
❌ Why not Middleware?
- Middlewares like
typo3/cms-frontend/site
resolve the site and language context before any custom fallback logic can take effect. - Injecting a modified
SiteLanguage
orLanguageAspect
into$GLOBALS['TYPO3_REQUEST']
after site resolution has no influence on the request lifecycle. - Custom middlewares cannot safely override fallbackType without risk of unstable or version-dependent behavior.
❌ Why not Events?
- Events such as
BootCompletedEvent
orSiteConfigurationBeforeWriteEvent
are either:- Too early (before routing and site resolution),
- Too late (after the fallback logic has already been applied),
- or only trigger on configuration write operations, not at runtime.
- As of TYPO3 v12, there is no
ModifyResolvedSiteLanguageEvent
or similar that would allow request-based manipulation of fallback behavior.
❌ Why not Hooks?
- While legacy hooks like
configArrayPostProc
are still technically available in TYPO3 v12, they no longer have meaningful influence on language resolution. - These hooks operate after
TSFE
initialization and only affect TypoScript-based values likeconfig.sys_language_mode
. - Since TYPO3 v9+, language fallback is controlled via
SiteLanguage
andContext
, not TypoScript. - Hook-based solutions are not reliable in modern TYPO3 setups and are not suitable for manipulating
SiteLanguage
orLanguageAspect
.
➡️ Therefore, we avoid using legacy hooks and rely on early runtime overrides instead.
✅ Why SiteFinder
and SiteConfiguration
XCLASSing is used
SiteFinder
andSiteConfiguration
are part of the early site and language resolution process.- By XCLASSing both, the extension can:
- Load the language-specific configuration from the database
- Dynamically set the
fallbackType
per language and page - Safely inject a new
SiteLanguage
and correspondingLanguageAspect
into the runtime context
- This approach is:
- Core-compliant
- Fully runtime-safe
- Patch-free
- Compatible with TYPO3 v12+
🧑💻 Credits
Developed by Belsignum with ❤️ for TYPO3 integrators.
📝 License
Licensed under the MIT License