Daniel Siepmann - Coding is Art

Blog Post

Build TYPO3 Language Menu without the need of optionSplit

Published: , Updated:

Tested with TYPO3: 9 LTS, 8 LTS

Topics: typo3, typoscript


TYPO3 CMS allows you to build a language menu to enable the frontend user to switch the current language. This menu is generated via TypoScript using optionSplit. Just start a query and take a look at the snippets. This way has one big drawback. In a multi domain setup you have to change the config

We have overcame this issue with one language menu working for all setup on all domains without the need to adjust anything. Read here how to achieve this.

Figure i7: Visible and source code result of the language menu without option split

The idea

The basic idea is to use the HMENU like all other solutions, but instead of using the optionSplit we are using data to inject the values from a language file.

The TypoScript

tmp.language = HMENU
tmp.language {
    wrap = <ul>|</ul>

    special = language
    special {
        value = 0, 1, 2, 3

    1 = TMENU
    1 {
        NO = 1
        NO {
            allWrap = <li>|</li>

            ATagTitle {
                data = LLL:EXT:example/Resources/Private/Language/Frontend.xlf:languageMenu.title.{field: _PAGES_OVERLAY_LANGUAGE}
                data {
                    insertData = 1

            stdWrap {
                cObject = COA
                cObject {
                    1 = TEXT
                    1 {
                        data < tmp.language.1.NO.ATagTitle.data

        ACT < .NO
        ACT {
            allWrap = <li class="active">|</li>

        USERDEF1 = 1
        USERDEF1 {
            doNotShowLink = 1

On Line 5 to 8 we define the menu as you normally would. With one exception, we add all sys_language_uid’s, not only the one we want on the current site. Via NO all existing languages that are not currently active are rendered. With ACT the current active language is rendered and via USERDEF1 we define to not show links to languages which are not available for the current site, depending on your configuration.

By Using USERDEF1 we don’t have to adjust the set of languages for each page.

Inside of data, the field: _PAGES_OVERLAY_LANGUAGE contains the uid of the current sys_language to render.

Using the data we can render the content of a language file. This file can be different for each language. This way we can adjust the labels for each language depending on the language.

The language file

The language file for above example might look like the following.

<?xml version="1.0"?>
<xliff version="1.2" xmlns="urn:oasis:names:tc:xliff:document:1.2">
    <file original="en" datatype="plaintext">
            <trans-unit id="languageMenu.title.">
            <trans-unit id="languageMenu.title.1">
            <trans-unit id="languageMenu.title.2">
            <trans-unit id="languageMenu.title.3">

The result

The output will look like the following:

Figure i7: Visible and source code result of the language menu without option split


This solution was “invented” by Justus Moroni and myself during one project, as we thought that option split and adjusting the settings for each site is not the best way. Also we were just to lazy, you know programmer?, to adjust the configuration for each multisite.

Further reading

And further resources to TYPO3 documentation which are used in this example: