A.Tietz
A.Tietz

Reputation: 77

Typo3 9.x: Multi-Language - Content Fallback not working?

I have a problem with Typo3 9.4 (and I have to admit that this is the first Typo3 9 page with multiple languages that I try to set up):

I want to have a content fallback to the default language if there is no content in the selected language. This is my TypoScript:

config {
        linkVars = L
        sys_language_uid = 0
        language = en
        locale_all = en_US.UTF-8
        sys_language_overlay = 1
        htmlTag_setParams = lang="en" dir="ltr" class="no-js en-selected"
}
[globalVar = GP:L = 1]
config {
        sys_language_uid = 1
        sys_language_mode = content_fallback;0
        language = de
        locale_all = de_DE.UTF-8
        htmlTag_setParams = lang="de" dir="ltr" class="no-js de-selected"
}
[global]
[globalVar = GP:L = 2]
config {
        sys_language_uid = 2
        sys_language_mode = content_fallback;0
        language = es
        locale_all = es_ES.UTF-8
        htmlTag_setParams = lang="es" dir="ltr" class="no-js es-selected"
}
[global]

The languages are also defiend in the Site Management. Here's the resulting config.yaml:

rootPageId: 1
base: /
baseVariants: {  }
languages:
  -
    languageId: '0'
    title: English
    navigationTitle: English
    base: /
    locale: en_US.UTF-8
    iso-639-1: en
    hreflang: en-US
    direction: ''
    typo3Language: default
    flag: global
    enabled: true
  -
    languageId: '1'
    title: Deutsch
    navigationTitle: Deutsch
    base: /de/
    locale: de_DE.UTF-8
    iso-639-1: de
    hreflang: de-DE
    direction: ''
    typo3Language: de
    flag: de
    fallbackType: fallback
    fallbacks: '0'
    enabled: true
  -
    languageId: '2'
    title: Spanisch
    navigationTitle: Spanisch
    base: /es/
    locale: es-ES.UTF-8
    iso-639-1: es
    hreflang: es-ES
    direction: ''
    typo3Language: default
    flag: es
    fallbackType: fallback
    fallbacks: '0'
    enabled: true
errorHandling: {  }
routes: {  }

My Homepage has content in english, german and spanisch are empty. But when I change to german I have no (english) content on the page. Interesting are two points: The menu is in german, so the alternate language is recognized, but in the html source code the html-tag looks like this:

<html lang="en" dir="ltr" class="no-js en-selected"> 

But this was defined as default. I think, the condition doesn't have any effect. Any Idea what's wrong in my thinking or coding?

Upvotes: 1

Views: 2480

Answers (2)

Wolfgang Kleinbach
Wolfgang Kleinbach

Reputation: 11

I'm just upgrading my website from 8.7.x to 9.5.x. As far as I understand, you don't need your TypoScript part at all. All settings for language fallback are done within the site configuration. There are still two bugs in TYPO3 9.5.x (I only tried these versions) connected to the language fallback:

  • Fallback for content elements does not work: When you change to a Spanish/German page (refering to your language settings), for which already a localized page without localized (Spanish/German) content elements exists, you will not get an output of the English content elements as expected. You have to apply a bug fix. See the related issue here and the bugfix here.
  • With your site setup you also will be affected by the other bug, which occurs when there's no localized page already for German/Spanish. When you have selected German/Spanish as language and you click on a link which leads to a page without a localized page element in German/Spanish you will get an 404 error and not the content of English page as expected. As far as I know, there's no bugfix for this problem which works. This bugfix didn't work for me. Hopefully there will be a bugfix for this problem soon. As long as there's no bugfix one solution is to create localized pages for every page and language. The other option is to create static routes for all affected pages, for example, route: de/english-slug-of-page, type: uri, source: https://yoursite/english-slug-of-page. The disadvantage of the second solution is that it will change the selected language to English too. Both options are not very handy, when your site has quite a lot of untranslated pages. Related question to this bug see here.

Upvotes: 1

Bharat Parmar
Bharat Parmar

Reputation: 1880

Linkvar L is no longer supported in typo3 9.5 so you need to change your condition from

[globalVar = GP:L = 2]

to

#condition on localE in site management language tab
[siteLanguage = locale = de_DE.UTF-8]

site management yaml files looks ok

Upvotes: 0

Related Questions