Language fields 

New in version 13.0

Changed in version 13.3

This field type displays all languages available in the current site context. Outside of the site context it displays all languages available in the installation.

A special language All languages is automatically added.

The according database field is generated automatically.

Introduction 

The main purpose of the TCA language configuration is to simplify the TCA language configuration. It therefore supersedes the special=languages option of TCA columns with type=select.

Formerly foreign_table relations to the table sys_language had also been used. This became deprecated with the introduction of site configurations with TYPO3 v9.

This field type decouples the actually available site languages from the sys_language table.

This TCA type automatically displays all available languages for the current context (the corresponding site configuration) and also automatically adds the special -1 language (meaning all languages) for all record types, except pages.

In records on root level (pid=0) or on a page, outside of a site context, all languages from all site configurations are displayed in the new field.

Changed in version 14.2

Fields of type language are now hidden by default if only one language is available.

language fields are hidden by default if only one language is available. If they should be displayed, set showIfEmpty.

Reasons why only one language is available include:

Example: Simple language field 

The conferences have a language field. TYPO3 creates the column sys_language_uid of type language from the languageField in the ctrl section, and the palette shows it:

The language of a conference

The language of a conference

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

return [
  'ctrl' => [
    'title' => 'my_extension.db:conference',
    'label' => 'title',
    'descriptionColumn' => 'internal_notes',
    'default_sortby' => 'conference_date DESC',
    'tstamp' => 'tstamp',
    'crdate' => 'crdate',
    'delete' => 'deleted',
    'editlock' => 'editlock',
    'enablecolumns' => [
      'disabled' => 'hidden',
      'starttime' => 'starttime',
      'endtime' => 'endtime',
      'fe_group' => 'fe_group',
    ],
    'languageField' => 'sys_language_uid',
    'transOrigPointerField' => 'l10n_parent',
    'transOrigDiffSourceField' => 'l10n_diffsource',
    'translationSource' => 'l10n_source',
    'versioningWS' => true,
    'origUid' => 't3_origuid',
    'iconfile' => 'EXT:my_extension/Resources/Public/Icons/Conference.svg',
    'security' => [
      'ignorePageTypeRestriction' => true,
    ],
  ],
  'columns' => [
    'title' => [
      'label' => 'my_extension.db:conference.title',
      'config' => [
        'type' => 'input',
        'required' => true,
        'max' => 255,
        'eval' => 'trim',
      ],
    ],
    'conference_date' => [
      'label' => 'my_extension.db:conference.conference_date',
      'config' => [
        'type' => 'datetime',
        'format' => 'date',
        'required' => true,
      ],
    ],
    'internal_notes' => [
      'label' => 'my_extension.db:conference.internal_notes',
      'config' => [
        'type' => 'text',
        'rows' => 3,
      ],
    ],
  ],
  // The fields of the other tabs are added in Configuration/TCA/Overrides/
  'types' => [
    '0' => [
      'showitem' => '
        title, conference_date,
        --div--;my_extension.db:tab.program,
        --div--;my_extension.db:tab.details,
        --div--;core.form.tabs:categories,
        --div--;core.form.tabs:access,
          hidden, --palette--;;access, fe_group, editlock,
        --div--;core.form.tabs:language,
          --palette--;;language,
        --div--;my_extension.db:tab.comments,
        --div--;core.form.tabs:notes,
          internal_notes,
      ',
    ],
  ],
  'palettes' => [
    'access' => [
      'label' => 'core.form.palettes:access',
      // The labels of the fields tell the editors what the dates are for
      'showitem' => '
        starttime;my_extension.db:conference.starttime,
        endtime;my_extension.db:conference.endtime,
      ',
    ],
    'language' => [
      'showitem' => 'sys_language_uid, l10n_parent',
    ],
  ],
];
Copied!

Example: Language of the subtitles 

A field of type language can also hold other information about a language. The recording of a talk has subtitles in one language of the site:

The field "Subtitles of the recording" with the language "Deutsch [1]" selected

The language of the subtitles of a talk

EXT:my_extension/Configuration/TCA/Overrides/242-tx_myextension_talk-subtitles.php
<?php

use TYPO3\CMS\Core\Utility\ExtensionManagementUtility;

defined('TYPO3') or die();

ExtensionManagementUtility::addTCAcolumns('tx_myextension_talk', [
  'subtitles' => [
    'label' => 'my_extension.db:talk.subtitles',
    // The recording is the same in all translations of the talk
    'l10n_mode' => 'exclude',
    'config' => [
      // A language field besides the language of the record. The item [All]
      // means that the recording has subtitles in every language of the site
      'type' => 'language',
    ],
  ],
]);
ExtensionManagementUtility::addToAllTCAtypes(
  'tx_myextension_talk',
  'subtitles',
  'talk,keynote',
  'after:recording_allowed',
);
Copied!

TYPO3 treats such a field differently from the language of the record:

  • The field lists all languages of the site. On a translated page, the language of the record lists only the default language and the languages of the page translations.
  • TYPO3 does not check whether the editor has access to the selected language.
  • The field also offers the item [All] with the value -1. For the subtitles, this item means that the recording has subtitles in every language of the site.

Language field properties 

Since the TCA type language is mostly based on the type=select internally, most of the associated TCA and TSconfig options can still be applied. This includes for example the selectIcons field wizard, as well as the keepItems and removeItems page TSconfig options.