[TYPO3-english] Language dependent typoscript CONSTANTS

bernd wilke t3ng at bernd-wilke.net
Thu Feb 14 11:22:28 CET 2013


Am 14.02.2013 11:02, schrieb J. Peter M. Schuler:
> Dear all,
> in short: Is there any simple way to have ts.constants with translation
> possible?
>
> I know that with ts.SETUP I have the opportunity for following code,
> which does the l10n 'automatically' (instead of relying on L-var
> conditions directly):
> ======== snip ==========
> xyz.text = <my default text goes here, e.g. mylabel-default>
> xyz.text.lang.en =  <my special English version here, e.g. mylabel-en>

!!! default = english
...lang.en is not defined!

> xyz.text.lang.nl =  <my special Dutch version here, e.g. mylabe-nl>
> ======== snip ==========
>
> However I work with many different subsites relying on the same
> template, who all use different labels in different languages (e.g. for
> pagetitles). However not all labels are filled. My current approach is
> to define three constants per label (mylabel-default, mylabel-en,
> mylabe-nl) and refer to them in the setup code. This leads to a problem
> in case e.g. the Dutch version isn't filled: instead of falling back to
> default language it just shows the empty constant.
> The only way I see to fix this fallback-issue is to have a LIT-condition
> on every non-default language that overwrites the content with the
> default language. This would lead to 3 lines of code per label per
> non-default-language, which adds up quite fast.
>
> So it seems it would be best to skip constants for this part and use
> ts.SETUP? Or is there some way to use constants in an l10n way I didn't
> stumble upon yet?

following comes to mind:
why not mix both parts?

you may define 3 constants for each labels

and put it into one setup-object:

temp.label1 = TEXT
temp.label1 {
	value = {$constant.label1-default}
	lang.de = {$constant.label1-de}
	lang.nl = {$constant.label1-nl}
}

also if your default-language is not english: default contains your 
english translation and your default-language must have its own 
lang.<id> entry!

and furthermore use this object:

page.10.20.30.mark.LABEL1 < temp.label1


bernd
-- 
http://www.pi-phi.de/cheatsheet.html


More information about the TYPO3-english mailing list