Project

General

Profile

Actions

Bug #101334

open

Custom packages translations not working

Added by Eric Chavaillaz 10 months ago. Updated 4 months ago.

Status:
Needs Feedback
Priority:
Should have
Assignee:
-
Category:
Localization
Target version:
Start date:
2023-07-12
Due date:
% Done:

0%

Estimated time:
TYPO3 Version:
11
PHP Version:
8.0
Tags:
xlf
Complexity:
Is Regression:
Sprint Focus:

Description

Hi,

I got some problems with custom packages translations in TYPO3 11. I use "typo3/cms-composer-installers v4.0.0-RC1" and my custom extensions are stored in a packages folder at the same level of vendor one. All works fine except the translations for my custom extensions.

All the translations files are located in "my_ext/Resources/Private/Language/filename.xlf". And they are all used via the official viewHelper or the API methods. It is not possible for me to reproduce this in local with DDEV (in local, the server structure is different).

In fact instead of resolve "/var/www/html/vendor/..." TYPO3 search language files in "/var/www/deployment/x.x.x/vendor/..." . It is not possible for the method GeneralUtility::getFileAbsFileName() to resolve it (because this is outside the project or the public path).

Maybe it can help, I have seen a comment in "LocalizationFactory->getParsedData()": // @todo: this (providing an absolute file system path) likely does not work properly anyway in all cases and should rather be deprecated at line 85.

Could it be linked?

As a workaround I have override the method "GeneralUtility::getFileAbsFileName()" to allow composer path (the "getComposerRootPath" part):

public static function getFileAbsFileName($filename)
{
    $fileName = (string)$filename;
    if ($fileName === '') {
        return '';
    }
    $checkForBackPath = fn (string $fileName): string => $fileName !== '' && static::validPathStr($fileName) ? $fileName : '';

    // Extension "EXT:" path resolving.
    if (PathUtility::isExtensionPath($fileName)) {
        try {
            $fileName = ExtensionManagementUtility::resolvePackagePath($fileName);
        } catch (PackageException) {
            $fileName = '';
        }
        return $checkForBackPath($fileName);
    }

    // Absolute path, but set to blank if not inside allowed directories.
    if (PathUtility::isAbsolutePath($fileName)) {
        if (str_starts_with($fileName, Environment::getProjectPath()) ||
            str_starts_with($fileName, Environment::getPublicPath()) ||
            str_starts_with($filename, Environment::getComposerRootPath())) {
            return $checkForBackPath($fileName);
        }
        return '';
    }

    // Relative path. Prepend with the public web folder.
    $fileName = Environment::getPublicPath() . '/' . $fileName;
    return $checkForBackPath($fileName);
}

Note that the translations from the core are working as expected.


Files

tree.png (64.6 KB) tree.png Eric Chavaillaz, 2023-07-12 11:46
Actions

Also available in: Atom PDF