Language fields

See also the Frontend Localization Guide.

All fields mentioned below get added to the database automatically. It is not recommended to define them in the ext_tables.sql. Doing so with incompatible SQL settings can lead to problems later on.

Language fields in detail

sys_language_uid

This field gets defined in ctrl->languageField. If this field is defined a record in this table can be translated into another language.

A typical sys_language_uid field
l10n_parent

This field gets defined in ctrl->transOrigPointerField.

If this value is found being set together with languageField then FormEngine will show the default translation value under the fields in the main form.

Header field showing values from two other languages

Header field showing values from two other languages

l10n_source

This field gets defined in ctrl->translationSource.

This field contains the uid of the record the translation was created from. For example if your default language is English and you already translated a record into German you can base the Suisse-German translation on the German record. In this case l10n_parent would contain the uid of the English record while l10n_source contains the uid of the German record.

l10n_diffsource

This field gets defined in ctrl->transOrigPointerField.

This information is used later on to compare the current values of the default record with those stored in this field. If they differ, there will be a display in the form of the difference visually:

Header field showing values from two other languages

Header field showing values from two other languages

Example: enable table for localization and translation:

EXT:my_extension/Configuration/TCA/tx_myextension_domain_model_something.php
<?php

return [
    'ctrl' => [
        'transOrigPointerField' => 'l18n_parent',
        'transOrigDiffSourceField' => 'l18n_diffsource',
        'languageField' => 'sys_language_uid',
        'translationSource' => 'l10n_source',
        // ...
    ],
    'columns' => [
        'sys_language_uid' => [
            'exclude' => true,
            'label' => 'LLL:EXT:core/Resources/Private/Language/locallang_general.xlf:LGL.language',
            'config' => [
                'type' => 'language',
            ],
        ],
        'l18n_parent' => [
            'displayCond' => 'FIELD:sys_language_uid:>:0',
            'label' => 'LLL:EXT:core/Resources/Private/Language/locallang_general.xlf:LGL.l18n_parent',
            'config' => [
                'type' => 'select',
                'renderType' => 'selectSingle',
                'items' => [
                    [
                        '',
                        0,
                    ],
                ],
                'foreign_table' => 'tx_myextension_domain_model_something',
                'foreign_table_where' =>
                    'AND {#tx_myextension_domain_model_something}.{#pid}=###CURRENT_PID###'
                    . ' AND {#tx_myextension_domain_model_something}.{#sys_language_uid} IN (-1,0)',
                'default' => 0,
            ],
        ],
        'l10n_source' => [
            'config' => [
                'type' => 'passthrough',
            ],
        ],
        'l18n_diffsource' => [
            'config' => [
                'type' => 'passthrough',
                'default' => '',
            ],
        ],
        // ...
    ],
];
Copied!