Tom
Tom

Reputation: 119

TypoScript condition based on language - TYPO3 version 9

I'm currently upgrading a site from version 7 to version 9.

I have a small TypoScript object that shows different content depending on the page language selected:

lib.myTSO = TEXT
lib.myTSO.value (
    <p>Hello World</p>
)
[globalVar = GP:L =1]
    lib.myTSO = TEXT
    lib.myTSO.value (
        <p>Hello World in a different language</p>
    )
[global]

This worked, in version 7 & 8 but no longer appears to be working in version 9. I assume its the way in which I'm calling the language variable?

Thanks again,

Upvotes: 1

Views: 3573

Answers (2)

Dan
Dan

Reputation: 61

if you want to use the language uid, this also works:

[siteLanguage("languageId") == 1]
 // 
[global]

Upvotes: 6

tripbe
tripbe

Reputation: 86

Matching against your locale set in site configuration should work:

[siteLanguage("locale") == "en_US.UTF-8"]
   lib.myTSO = TEXT
   lib.myTSO.value (
        <p>Hello World in a different language</p>
    )
[global]

Reference: https://docs.typo3.org/typo3cms/CoreApiReference/ApiOverview/SiteHandling/UseSiteInConditions.html

In Constants only this seems to work as of TYPO3 9.5.1

[siteLanguage = locale = en_US.UTF-8]
constantFoo = Bar
[global]

Upvotes: 6

Related Questions