0
votes

I'm using Typo3 9.5 and got some hardcoded variables within my fluid templates. I'm trying to make this variables depending on what language the page is viewed. Default value works fine. But making use of TypoScript like

[globalVar = GP:L = 1]
   #whatever
[end]

for instance already throws an Error within the console either way and therefore does not override an variable. I think I've done this before in previous Typo3 versions. How do I achieve language depending variables and render it within my FLUID template?

1
What do you mean with variables? Can you show us the related Fluid part? Maybe it would help to provide a bit more context. Like current TypoScript involved and Fluid involved. If it's hard coded and language specific, I would suggest a translation file and f:translate ViewHelper. - Daniel
I'm talking about simple TEXT variables, for instance the placeholder of an input field, I want the value to be 'search' for English and 'recherche' for French etc. - Bradley
Then see Claus Due answer, the translation is the way to go, do not use Variables but translations. This doesn't sound like Variables. - Daniel

1 Answers

2
votes

You shouldn't be assigning your variables this way. The right way to handle this is to create XLF files that can be referenced with f:translate to translate a given key into any language as long as there's an XLF file for it.

This method is used and supported throughout TYPO3, not just in Fluid. Nearly all labelling options support LLL:... references where you can point to specific files.

You are encouraged to create an extension that can contain such files and then reference them with LLL:EXT... paths and/or use extensionName on f:translate in your Fluid templates if the extension is other than the one rendering your Fluid templates.