Search code examples
typo3typoscripttemplavoila

typo3 templavoila check current language


Hi i have 4 languages in my typo. Here is my main configuration for them:

#LANGS
config.linkVars=L
config.defaultGetVars.L = 0
config.sys_language_overlay = hideNonTranslated
[globalVar = GP:L = 3]
config.sys_language_uid = 3
config.language = en
config.locale_all = en_EN
config.htmlTag_langKey = en
plugin.tx_indexedsearch._DEFAULT_PI_VARS.lang = 3
[globalVar = GP:L = 2]
config.sys_language_uid = 2
config.language = ro
config.locale_all = ro_RO
config.htmlTag_langKey = ro
plugin.tx_indexedsearch._DEFAULT_PI_VARS.lang = 2
[globalVar = GP:L = 1]
config.sys_language_uid = 1
config.language = de
config.locale_all = de_DE
config.htmlTag_langKey = de
plugin.tx_indexedsearch._DEFAULT_PI_VARS.lang = 1
[global]

All works fine. Im using templavoila and realurl.

In one of templates/modules/flexible content i have typoscript displays field only when its not empty:

10 = TEXT
10.field = field_test
10.wrap = info: |
10.if.isTrue.field = field_test

Now i'd like to display this field in diferent versions:

like:

10.wrap = informationen | 

for DE language etc.

How may i check here what current language is?


Solution

  • Using translation labels in TypoScript

    You can use a translation label in TypoScript. For example:

    {LLL:typo3conf/customlabels.xlf:label.id}
    {LLL:EXT:mytemplateext/Resources/Private/Language/locallang.xlf:label.id}
    

    You may want to look at:

    http://docs.typo3.org/typo3cms/FrontendLocalizationGuide/BasicSetupOfALocalizedWebsite/Llxml%28locallang-xml%29InPluginsAndTyposcript/Index.html

    llXML files are XML files containing labels that the system can fetch in a localized version if a language pack is installed. If you want to retrieve values from llXML files in TypoScript you can do it like this:

    page.20 = TEXT page.20.stdWrap.data =
    LLL:EXT:indexed_search/pi/locallang.xml:submit_button_label
    

    And see also:

    http://docs.typo3.org/typo3cms/CoreApiReference/Internationalization/Introduction/Index.html http://docs.typo3.org/typo3cms/InsideTypo3Reference/CoreArchitecture/Localization/Locallang-xml%28llxml%29Files/Index.html

    TypoScript variables

    You can extend your language configuration with your own settings. For example:

    #LANGS
    config.linkVars=L
    config.defaultGetVars.L = 0
    config.sys_language_overlay = hideNonTranslated
    myLanguageLabels {
        info = info
    }
    [globalVar = GP:L = 3]
    config.sys_language_uid = 3
    config.language = en
    config.locale_all = en_EN
    config.htmlTag_langKey = en
    myLanguageLabels {
        info = info 2
    }
    plugin.tx_indexedsearch._DEFAULT_PI_VARS.lang = 3
    [globalVar = GP:L = 2]
    config.sys_language_uid = 2
    config.language = ro
    config.locale_all = ro_RO
    config.htmlTag_langKey = ro
    myLanguageLabels {
        info = info 3
    }
    plugin.tx_indexedsearch._DEFAULT_PI_VARS.lang = 2
    [globalVar = GP:L = 1]
    config.sys_language_uid = 1
    config.language = de
    config.locale_all = de_DE
    config.htmlTag_langKey = de
    plugin.tx_indexedsearch._DEFAULT_PI_VARS.lang = 1
    myLanguageLabels {
        info = info 3
    }
    [global]
    

    And then just point out to the variable you want to use:

    10.wrap = {$myLanguageLabels.info}: |