Search code examples
localizationtypo3fallback

TYPO3 sys_language_mode = content_fallback not working as expected


Here is a little follow-up question to this question of mine: Language switching in Typo3 v6.

This is my current setup:

config {
  tx_realurl_enable = 1
  simulateStaticDocuments = 0
  sys_language_uid = 1
  language = de
  locale_all = de_DE
  htmlTag_langKey = de
  linkVars := addToList(L)
  uniqueLinkVars = 1
  sys_language_mode = content_fallback
  sys_language_overlay = 1
}

[globalVar = GP:L = 1]
config.sys_language_uid = 1
config.language = de
config.locale_all = de_DE
config.htmlTag_langKey = de
[global]

[globalVar = GP:L = 2]
config.sys_language_uid = 2
config.language = en
config.locale_all = en_EN
config.htmlTag_langKey = en
[global]

In the backend, German has the ID 1 and English the ID 2. Up to now, everything worked fine. But now there is a site where some German content has no direct translated element in the English content. In other words: I need an element only to appear on the German version.

Up to now, the German content sat in the "default" column and the English content was added in the "english" column. So I thought all I have to do is add a german translation to the site and add the element there. But it is not working as expected:

This is the content I added. The left column (marked green) is the default content. The middle column (pink) is the German content. The right column (blue) is the English content.

But in the frontend, on the English site the blue (English) content is show and on the German site, the green (default) content is shown, not the pink (German) content, as I would have expected and desired.

Where did I go wrong?

I already confirmed that L=1 by messing around with the htmlTag_langKey. It definitely is set by the first conditional block. So why is sys_language_uid = not displaying the German content. Is any additional configuration needed?


Solution

  • You are adding a german translation to a german text. This can't go well.

    If your main language is german, it should stay the default language. You can rename the label via TSCONFIG in the Backend for editor's convenience.

    mod.SHARED{
        defaultLanguageFlag = de.gif
        defaultLanguageLabel = Deutsch
    }
    

    The default language has the ID 0, so you can call index.php without a language parameter. So you just have to add the foreign languages on page 0, default is already there

    I think you will run into problems if you try to force another localisation to be the default language, so you might want to go back to 2 languages quickly.

    By the way, I find the most logical setup for TYPO3 language fallback to be:

    In TS:

    config.sys_language_overlay =1
    // don't set sys_language_mode
    

    In TSCONFIG:

    mod.web_layout.defLangBinding = 1
    

    which will bind each article with it's translations