[Typo3] Using [language] condition

Jason Lefkowitz jlefkowitz at oceana.org
Fri May 27 15:37:35 CEST 2005


Hey everyone...

quick question about using the [language = ] condition to do content-switching based on the user's language preferences, in a one-tree multi-language site.

I've got the multi-language support set up, and the switching between languages seems to be working fine.  However, I've got some images in the template that should switch as well when the expressed language changes (since they have text on them).

My thinking was, instead of create a whole new template for each language, just use the [language] condition in the CONSTANTS field of the template to set the source file of the image so it's the appropriate one for that language -- like this:

[language = es]

imageFile = fileadmin/images/espanol.jpg

[else]

imageFile = fileadmin/images/english.jpg

[end]

... and then refer to {$imageFile} in the SETUP, rather than hard-code the path to the image in there.

Interestingly, it seems to do the substituting-for-{$imageFile} bit fine -- but it always puts in the value of the [else] branch of the condition, even if I have selected Spanish in the language menu.  All the page text switches to Spanish, so I know Typo has 'gotten the message' that I want to switch to spanish.  So why doesn't [language = es] resolve as true?

The only way I've found so far to make it work is to test against [globalVar] rather than [language].    In other words, since I defined Spanish in my Typoscript like this...

[globalVar = GP:L =2]
page.config.sys_language_uid = 2
page.config.language = es
page.config.locale_all = es
[GLOBAL]   

... I *can* make the condition branch properly by rewriting it like this:


[globalVar = GP:L =2]

imageFile = fileadmin/images/espanol.jpg

[else]

imageFile = fileadmin/images/english.jpg

[end]

This works, but it's not as easy to follow as [language = es] -- I'd prefer that route so that future people maintaining this code have as easy a job as possible figuring out my TypoScript.  

Any ideas where I might be going off the rails?

- Jason Lefkowitz (jlefkowitz)

-----------------------
The mailing list archive is found here:
http://typo3.org/documentation/mailing-lists/english-main-list-archive/
				



More information about the TYPO3-english mailing list