3.2.6 Language files
In this example, we will translate the following Flux form element:
(Please notice, that this is a Configuration section for a Page template. Content- and Plugin templates require an additional
flux:form.content
tag in flux:grid.column
)
<f:section name="Configuration">
<flux:form id="defaultpage" >
<flux:form.sheet name="settings.basics">
<flux:form.field.checkbox name="settings.includenavi" />
<flux:grid>
<flux:grid.row>
<flux:grid.column colPos="0" name="content"/>
</flux:grid.row>
</flux:grid>
</flux:form.sheet>
</flux:form>
</f:section>
So we need to add labels and/or description for
- the form itself "defaultpage"
- the sheet called "settings.basics"
- the checkbox called "settings.includenavi"
- the grid.colum called "content"
To achieve that, we place this code in the locallang.xlf
in the body
tag for each element:
<trans-unit id="ID.and.path.of.the.element">
<source>Label or description to be shown</source>
</trans-unit>
So basically it always is flux.formID.type.name-of-the-element
In our example, we add the following to the default xlf-file (locallang.xlf
):
<trans-unit id="flux.defaultpage">
<source>Default Pagelayout</source>
</trans-unit>
<trans-unit id="flux.defaultpage.sheets.settings.basics">
<source>Basic Configuration</source>
</trans-unit>
<trans-unit id="flux.defaultpage.fields.settings.includenavi">
<source>Include navigation</source>
</trans-unit>
<trans-unit id="flux.defaultpage.columns.content">
<source>Content-Area</source>
</trans-unit>
As you can find in typo3conf/ext/flux/Classes/Form/AbstractFormComponent.php
--> public function getLabel()
these types
are available:
- sheets (flux.sheets.id)
- sections
- grids
- columns
- objects
- areas
- containers
- fields
The whole file is now looking like this:
<?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="**YOUREXT**">
<header/>
<body>
<trans-unit id="flux.defaultpage">
<source>Default Pagelayout</source>
</trans-unit>
<trans-unit id="flux.defaultpage.sheets.settings.basics">
<source>Basic Configuration</source>
</trans-unit>
<trans-unit id="flux.defaultpage.fields.settings.includenavi">
<source>Include navigation</source>
</trans-unit>
<trans-unit id="flux.defaultpage.columns.content">
<source>Content-Area</source>
</trans-unit>
</body>
</file>
</xliff>
Working with other (additional) languages
To add translations for further languages we need to create the locallang.xlf
for each languages and name it this way:
iso.locallang.xlf
(for example de.locallang.xlf
). This file also contains this structure:
<?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="**YOUREXT**">
<header/>
<body>
</body>
</file>
</xliff>
To tell TYPO3 which language this is for, it is not enough to name the file. We need to extend the <file>
tag within the
iso.locallang.xlf
with the target language like this:
<file source-language="en" datatype="plaintext" original="messages"
date="2012-10-17T17:55:17Z" product-name="ext-name" target-language="de">
As you can see we added the language target "de" by adding target-language="de"
The next thing to do is to add the translation like we did in the default language-file - with one difference: instead of the
<source>my translation</source>
we use
<target>my translation</target>
The German file looks like this now (de.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="**YOUREXT**" target-language="de">
<header/>
<body>
<trans-unit id="flux.defaultpage">
<target>Standard-Seitenlayout</target>
</trans-unit>
<trans-unit id="flux.defaultpage.sheets.settings.basics">
<target>Basis Konfiguration</target>
</trans-unit>
<trans-unit id="flux.defaultpage.fields.settings.includenavi">
<target>Navigation einbinden</target>
</trans-unit>
<trans-unit id="flux.defaultpage.columns.content">
<target>Inhaltsbereich</target>
</trans-unit>
</body>
</file>
</xliff>