I have a website with two languages e.g de and en. De is my default language with no path prefix. En, the second language, has /en/ as prefix in the url. Now when I switch to the en language, the menu item links have /en/ in the url, which is fine. But when I click on a menu item, which is not explicit translated in the backend, then I get a 404 error. I cannot say this behavier is wrong, because there isn't a page with this slug path before I create one. But what should I do? Create a translation for each page, which is not helpful, if there are already hundreds of pages. Is there no fallback (not content fallback, page fallback)?
site config
rootPageId: 2
base: 'http://some-domain.de/'
baseVariants: { }
languages:
-
title: 'Meine tolle Webseite'
enabled: true
languageId: '0'
base: /
typo3Language: de
locale: de_DE.UTF-8
iso-639-1: de
navigationTitle: ''
hreflang: ''
direction: ''
flag: de
-
title: 'Andere Sprache'
enabled: true
languageId: '1'
base: /en/
typo3Language: en
locale: en_US.UTF-8
iso-639-1: en
navigationTitle: ''
hreflang: ''
direction: ''
fallbackType: fallback
fallbacks: '0'
flag: en
errorHandling: { }
routes: { }
routeEnhancers:
PageTypeSuffix:
type: PageType
default: .html
map:
.html: 0
There is a open bug related to content fallback:
https://forge.typo3.org/issues/86762
Maybe try upgrade to 9.5.3 (Dont know if this is fixed there).
As a workaround: Do you want to remove not translated pages in the english menu?
Then you can set for all pages "Hide page if no translation for current language exists". This checkbox is available for every page under the tab "language".
To do this for all your existing pages:
UPDATE pages SET l18n_cfg = 2
To automaticly set this flag for new created pages:
Create a overrides pages.php in your extension.
typo3conf/ext/[YOUR_EXTENSION]/Configuration/TCA/Overrides/pages.php
And add the default value for l18n_cfg
$GLOBALS['TCA']['pages']['columns']['l18n_cfg']['config']['default'] = 2;
Another workaround instead of creating translations for every page is to create static routes.
For example:
route: de/english-slug-of-page
type: uri
source: https://yoursite/english-slug-of-page.
Not very handy solution though. And it has the disadvantage that routing to the English pages will change the selected language (in the example from German to English).
The is still no fix for this issue in TYPO3 9.5.4.
This here should be a comment to the answer from Steffen Mächtel but i dont have the enough reputation -.-.
If you want archive that all pages are hidden(inside menus) when there is no translation, you can set a global setting under Module Settings -> Configure Installation-Wide Options -> [FE][hidePagesIfNotTranslatedByDefault] (< TYPO3 9 you will finde the same setting in the install tool). This way is a bit simpler :)