Project

General

Profile

Actions

Bug #100030

closed

Translation handling: Fallback chain is broken if backend user is logged in.

Added by Marc Willmann over 1 year ago. Updated 5 months ago.

Status:
Closed
Priority:
Must have
Assignee:
Category:
-
Target version:
-
Start date:
2023-02-24
Due date:
% Done:

100%

Estimated time:
TYPO3 Version:
12
PHP Version:
8.2
Tags:
Complexity:
Is Regression:
Sprint Focus:

Description

According to https://docs.typo3.org/m/typo3/reference-coreapi/main/en-us/ApiOverview/Localization/XliffFormat.html TYPO3 supports a fallbackchain for locallang.xlf files with region-specific prefix.

As I understand correctly the feature SHOULD work this way:

If I have a locale of e.g. de-DE.UTF-8 TYPO3 will use the language labels in de_DE.locallang.xlf. If this file does not exist the label from de.locallang.xlf will be used. And last but not least the original label from locallang.xlf comes into effect.

This behaviour is broken in 12.2.0

If a BE user is logged in and uses the Backend (!) with german translation, the file 'de_DE.locallang.xlf' is ignored when rendering the frontend! (thanks for the acceptance test in our project which has detected this error ;)

If no BE user is logged in, the file de.locallang.xlf is ignored.

So, as a temporary workaround I have a symlink de.locallang.xlf which points to de_DE.locallang.xlf to tackle both use cases.

I expect this bug is related to vendor/typo3/cms-extbase/Classes/Utility/LocalizationUtility.php

/**
     * Resolves the currently active language key.
     */
    protected static function getLanguageKey(): string
    {
        if (($GLOBALS['TYPO3_REQUEST'] ?? null) instanceof ServerRequestInterface
            && ApplicationType::fromRequest($GLOBALS['TYPO3_REQUEST'])->isFrontend()
        ) {
            // Frontend application
            $siteLanguage = self::getCurrentSiteLanguage();

            // Get values from site language
            if ($siteLanguage !== null) {
                return $siteLanguage->getTypo3Language();
            }
        } elseif (!empty($GLOBALS['BE_USER']->user['lang'])) {
            return $GLOBALS['BE_USER']->user['lang'];
        }
        return 'default';
    }

Files

Translation.png (40.4 KB) Translation.png Marc Willmann, 2023-02-27 09:37

Related issues 2 (0 open2 closed)

Related to TYPO3 Core - Bug #100176: Translations not available in v12.2 when using language key with country in site configClosed2023-03-15

Actions
Related to TYPO3 Core - Bug #100255: Language of backend user influence FE translationsClosed2023-03-22

Actions
Actions

Also available in: Atom PDF