TypoScript condition based on language - TYPO3 ver

2019-08-27 23:21发布

问题:

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,

回答1:

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]


标签: typo3-9.x