Issue Bug Closed

#87056Default language not respecting.

Ricky Mathew 12/03/18, 07:41 updated 07/25/19, 14:11

Description

I have a site configuration as follows for a multilanguage site:

rootPageId: 211
base: 'https://example.com/'
baseVariants: {  }
languages:
  -
    title: Default
    enabled: false
    languageId: '0'
    base: /en/
    typo3Language: default
    locale: en_US.UTF-8
    iso-639-1: en
    navigationTitle: English
    hreflang: en-US
    direction: ''
    flag: global
  -
    title: 'Swiss German'
    enabled: true
    languageId: '6'
    base: /
    typo3Language: de
    locale: de_CH
    iso-639-1: de
    navigationTitle: Deutch
    hreflang: de-CH
    direction: ''
    fallbackType: strict
    flag: ch
  -
    title: 'Swiss French'
    enabled: true
    languageId: '10'
    base: /fr_CH/
    typo3Language: fr
    locale: fr_CH.UTF-8
    iso-639-1: fr
    navigationTitle: Francais
    hreflang: fr-CH
    direction: ''
    fallbackType: strict
    flag: ch
errorHandling: {  }
routes: {  }

I use Swiss German as default language which is the second language in my page structue with base ‘/’(.i.e inbuilt default language is not using in fronend).
As a result, on clicking page preview of pagetree from backend it generates url like ‘https://example.com/en/examplepage’ which is not i wanted.

I want the pagetree to generate page preview for swiss german language (like ‘https://example.com/beispiel’) by default.

So i have the following work around in ‘TYPO3\CMS\Core\Site\Entity\Site’ class on picking default language:

    /**
     * @inheritdoc
     */
    public function getDefaultLanguage(): SiteLanguage
    {
        + foreach ($this->languages as $language) {
        +   if($language->getBase()->getPath()=='/'){
        +       return $language;
        +    }
        +}
        return reset($this->languages);
    }

I

If you guys have no objection i can push it to the core.What are your thoughts?

Reviews 0

No change resolves or names this issue in its commit message, and no comment links one.