Reputation: 765
I am struggling with Typo3 / Typoscript. I want to localize a website to two languages in total (German as default, and English). Using the following typoscript I could localize my standard text records:
lib.main = CONTENT
lib.main {
table = tt_content
select {
pidInList = this
languageField = sys_language_uid
orderBy = sorting
}
renderObj.stdWrap.dataWrap = <section id="tt_content_{field:uid}"><article>|<hr class="clearer"/></article></section>
}
However, no images / media records and their captions are overwritten/localized. I already have these settings in my Typoscript:
config.sys_language_overlay = 1
config.sys_language_softExclude = tt_content:image
config.sys_language_softMergeIfNotBlank = tt_content:image
config.sys_language_mode = strict
The images (and files) and captions are still default German; no translation / localization. Even if I altered the localized record with different files, only the default was visible. Is there another point where I can force localization? Another snippet using the image is a caption wrap (which another one created):
plugin.tx_presets_pi1 {
rendering {
file.import.data = file:current:uid_local
caption {
wrap = <p class="center image-caption">|</p>
}
}
}
Could someone suggest a solution? I have the feeling that it is a FAL problem (and a reported bug...?!) Thanks for your generous help :)
Upvotes: 0
Views: 1151
Reputation: 130
Localize file or image references: A simpler example for the above solution:
lib.image < styles.content.get
lib.image {
renderObj = FILES
renderObj {
references {
table = tt_content
uid.data = field:uid
fieldName = image
}
renderObj = IMAGE
renderObj {
file.import.data = file:current:publicUrl
altText.data = file:current:alternative
titleText.data = file:current:title
}
}
}
[globalVar = GP:L > 0]
# Reference to localized image (including localized title and alternative)
lib.image.renderObj.references {
uid.data =
l18n_parent.data = field:uid
}
[global]
Upvotes: 3
Reputation: 130
I had a similar problem: A (parallax) background image with a textbox inside. The content of the textbox is rendered from the images title, description, alternative text and link.
The trick is: Use l18n_parent instead of uid for relating to the image reference relation if language is > 0 [globalVar = GP:L > 0]. So you get the localization of the images. This can easily be adapted for sliders as well.
# Image with title, alternative text, description and link, replace 101 with your colPos
lib.bgImageWithTextbox < styles.content.get
lib.bgImageWithTextbox {
select.where = colPos = 101
stdWrap.required = 1
renderObj = FILES
renderObj {
references {
table = tt_content
uid.data = field:uid
fieldName = image
}
renderObj = COA
renderObj {
# Render container with image as background
10 = IMG_RESOURCE
10 {
file.import.data = file:current:publicUrl
file.treatIdAsReference = 1
stdWrap.wrap >
stdWrap.dataWrap (
<div class="g-section-padding-medium js-parallax" data-image-src="/|" data-speed="0.75">
<div class="c-box-background-image">
<h3>{file:current:title}</h3>
<p>{file:current:description}</p>
)
}
# Render textbox with typolink (internal, external, target = _blank etc.)
20 = TEXT
20 {
data = file:current:alternative
typolink.parameter.data = file:current:link
typolink.wrap = |
}
# Close image container
30 = TEXT
30.value (
</div>
</div>
)
}
}
}
[globalVar = GP:L > 0]
# Translation of image texts
lib.bgImageWithTextbox.renderObj.references {
uid.data =
l18n_parent.data = field:uid
}
[global]
Upvotes: 0