Search code examples
typo3typoscripttypo3-9.x

How to setup TYPO3 9.5.x with a multiple-trees concept for languages


For a new website I have to setup a multiple languages TYPO3 9.5. I have done this for previous versions, but don't get it to work with version 9.5. Have been searching for a couple of days now, without any result. All solutions are for older TYPO3's or one-tree concept.

The website has a structure like this:

  • Homepage (redirect to NL)
    • NL (homepage with Dutch content)
      • Algemeen
      • Contact
      • ...
    • DE (homepage with German content)
      • Allgemeine info
      • Kontakt
      • ...

The URL's:
- https://domain.tld/nl/
- https://domain.tld/nl/algemeen/
- https://domain.tld/nl/contact/
- https://domain.tld/de/
- https://domain.tld/de/allgemeine-info/
- https://domain.tld/de/kontakt/

The Homepage and DE part are the pages with all the TypoScript settings.
I don't want to translate the pages. When you go to /nl/ everything is in Dutch and you are in the Dutch page tree when you go to /de/ everything is in German and you are in the German page tree.

The same sort of site structure is used for other websites which have to be migrated from TYPO3 8.7 to 9.5 in the near future.

I've setup a new website and configured the website via Site Management -> Sites.
The Root Page ID is set for the "Homepage".
In the Languages tab I have the default language Dutch (NL) with base /nl/.
And German (DE) with base /de/.
No Error Handling and Static Routes are set at the moment.

I have added an extension from another website with FLUID templates based on fluidpages and flux.

I have tried setting the language via TypoScript (Setup) on /nl/ and /de/. But it is ignored. I guess that is because of TYPO3 9.5.
NL:

config {
  language = nl
  locale_all = nl_NL.utf8
  sys_language_uid = 0
}

DE:

config {
  language = de
  locale_all = de_DE.utf8
  sys_language_uid = 1
}

The standard slug of https://domain.tld/de/allgemeine-info/ is https://domain.tld/de/de/allgemeine-info/ in this setup. When I set the slug manually I can get what I want.. kind of, but then you have to set the slug for every page. And I can also call https://domain.tld/de/nl/algemeen/ and https://domain.tld/nl/de/allgemeine-info/ which is not okay.

Is there a way to set the language via TypoScript only and not via Site Management, so I can create a multiple tree website?

I hope someone can help me in the right direction.

Thanks!


Solution

  • You could realize this scenario by creating two separate sites, one for each language:

    In your example you would tick the checkbox "Use as Root Page" in the page properties of the root pages of the two languages:

    • NL (homepage with Dutch content)
    • DE (homepage with German content)

    Then you create two site configurations.

    For Dutch:

    rootPageId: <ID of NL page>
    base: 'https://www.domain.tld/nl/'
    baseVariants: {  }
    languages:
      -
        title: Dutch
        enabled: true
        languageId: '0'
        base: /
        typo3Language: nl
        locale: nl_NL.utf8
        iso-639-1: nl
        navigationTitle: Dutch
        hreflang: nl-NL
        direction: ltr
        flag: nl
    errorHandling: {  }
    routes: {  }
    

    And for German:

    rootPageId: <ID of DE page>
    base: 'https://www.domain.tld/en/'
    baseVariants: {  }
    languages:
      -
        title: English
        enabled: true
        languageId: '0'
        base: /
        typo3Language: default
        locale: en_US.utf8
        iso-639-1: en
        navigationTitle: English
        hreflang: en-US
        direction: ltr
        flag: us
    errorHandling: {  }
    routes: {  }
    
    

    With this setup you do not need website language records because both trees would use the default language 0.

    You might need to add a third site for the root domain that redirects the user to the /nl pagetree. The setup would be the same as for the dutch version except the page ID and the base setting would be different.