user2310852
user2310852

Reputation: 1674

Fluid TYPO3 Translate Text in Page Template

I work with TYPO3 6.2.12 and the latest FluidTYPO3-Extensions. I also have a Multilanguage-Website (german/english).

At my Page-Template Subpage.html I need a headline in english (mydomain.de/en/page.html) and also in german (mydomain.de/de/seite.html). But I don't know why?!

<h3 class="section-heading">Manufacturers</h3>

and for the german users ...

<h3 class="section-heading">Hersteller</h3>

I've made it with the file locallang.xlf and de.locallang.xlf (s. below and thanks to jost answer 1). But how's the syntax for my template?

My tries doesn't work .. cleared caches?!

<h3 class="section-heading"><f:translate key="LLL:typo3conf/ext/redeagle/Resources/Private/Language/locallang.xlf:navigation.sub.headline" /></h3>

or

 <h3><f:translate key="navigation.sub.headline"/></h3>

Need a bit of help to show the Text from locallang.xlfat my template. Thanks.

Upvotes: 1

Views: 3438

Answers (2)

Jost
Jost

Reputation: 5850

The xliff format is described here.

You need to have one file for the default labels, e.g. locallang.xlf. Then you add another file for each translation, with the language code prepended to the file name of the file with the default labels. In the example it could be de.locallang.xlf. This file has to be in the same folder the locallang.xlf is located.

This file is a copy of the file with the default labels, but with some additions:

  1. The <file> tag gets an additional attribute target-language with the language code of the translation as value.
  2. Each <source>-tag gets a <target> tag as sibling, containing the translation of the label.

Make sure you clear the caches (in the install tool) after changing translations, so you can see the changes.

A translation program for XLIFF is virtaal, works quite well for me.

In your example, you should have these two files:

locallang.xlf:

<?xml version="1.0" encoding="utf-8" standalone="yes" ?>
<xliff version="1.0">
    <file source-language="en" datatype="plaintext" original="messages"
          date="2012-10-17T17:55:17Z" product-name="myproject">
        <header/>
        <body>
            <trans-unit id="flux.sidebar.navigation.sub.headline">
                <source>Manufacturer</source>
            </trans-unit>
        </body>
    </file>
</xliff>

de.locallang.xlf:

<?xml version="1.0" encoding="utf-8" standalone="yes" ?>
<xliff version="1.0">
    <file source-language="en"  target-language="de" datatype="plaintext" original="messages"
          date="2012-10-17T17:55:17Z" product-name="myproject">
        <header/>
        <body>
            <trans-unit id="flux.sidebar.navigation.sub.headline">
                <source>Manufacturer</source>
                <target>Hersteller</target>
            </trans-unit>
        </body>
    </file>
</xliff>

Upvotes: 1

user2310852
user2310852

Reputation: 1674

Got it.

My default Language is "german", the second language is "english"

locallang.xlf

<?xml version="1.0" encoding="utf-8" standalone="yes"?>
<xliff version="1.0">
    <file source-language="de" datatype="plaintext" original="messages" product-name="project1" date="2015-05-05T12:31:24+02:00">
        <header/>
        <body>

            <trans-unit id="flux.subsidebar.navigation.sub.headline" xml:space="preserve">
                <source>Hersteller</source>
            </trans-unit>

        </body>
    </file>
</xliff>

en.locallang.xlf

<?xml version="1.0" encoding="utf-8" standalone="yes"?>
<xliff version="1.0">
    <file source-language="de" target-language="en" datatype="plaintext" original="messages" product-name="project1" date="2015-05-05T12:31:24+02:00">
        <header/>
        <body>

            <trans-unit id="flux.subsidebar.navigation.sub.headline" xml:space="preserve">
                <source>Hersteller</source>
                <target>Manufacturer</target>
            </trans-unit>

        </body>
    </file>
</xliff>

And at my fluid-template

<h3><f:translate key="flux.subsidebar.navigation.sub.headline"/></h3>

Perfect! Thanks to Jost. I only had time for one night sleep over it...

Upvotes: 0

Related Questions