简体   繁体   中英

Typo3 Record localization

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 :)

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]

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]

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM