Skip to content

Commit

Permalink
[BUGFIX] Use editors language in admin panel instead of site language
Browse files Browse the repository at this point in the history
The translations need to use the language of the current backend user
and not the one of the current language of the site in the frontend.

Resolves: #96004
Releases: master, 11.5, 10.4
Change-Id: Id409e759de4f0324835cc932f87719147b6e1b0f
Reviewed-on: https://review.typo3.org/c/Packages/TYPO3.CMS/+/72362
Tested-by: core-ci <typo3@b13.com>
Tested-by: Georg Ringer <georg.ringer@gmail.com>
Reviewed-by: Georg Ringer <georg.ringer@gmail.com>
  • Loading branch information
georgringer committed Dec 1, 2021
1 parent 04640cd commit 473410a
Show file tree
Hide file tree
Showing 30 changed files with 111 additions and 69 deletions.
7 changes: 7 additions & 0 deletions typo3/sysext/adminpanel/Classes/Controller/MainController.php
Expand Up @@ -32,6 +32,7 @@
use TYPO3\CMS\Adminpanel\Utility\ResourceUtility;
use TYPO3\CMS\Adminpanel\Utility\StateUtility;
use TYPO3\CMS\Backend\Routing\UriBuilder;
use TYPO3\CMS\Core\Authentication\BackendUserAuthentication;
use TYPO3\CMS\Core\Cache\CacheManager;
use TYPO3\CMS\Core\SingletonInterface;
use TYPO3\CMS\Core\Utility\GeneralUtility;
Expand Down Expand Up @@ -127,6 +128,7 @@ public function render(ServerRequestInterface $request): string
'toggleActiveUrl' => $this->generateBackendUrl('ajax_adminPanel_toggle'),
'resources' => $resources,
'adminPanelActive' => StateUtility::isOpen(),
'languageKey' => $this->getBackendUser()->user['lang'],
]
);
if (StateUtility::isOpen()) {
Expand Down Expand Up @@ -244,4 +246,9 @@ protected function storeDataPerModule(ServerRequestInterface $request, array $mo
}
return $data;
}

protected function getBackendUser(): BackendUserAuthentication
{
return $GLOBALS['BE_USER'];
}
}
Expand Up @@ -17,6 +17,7 @@

namespace TYPO3\CMS\Adminpanel\ModuleApi;

use TYPO3\CMS\Core\Authentication\BackendUserAuthentication;
use TYPO3\CMS\Core\Localization\LanguageService;

/**
Expand All @@ -35,4 +36,9 @@ protected function getLanguageService(): LanguageService
{
return $GLOBALS['LANG'];
}

protected function getBackendUser(): BackendUserAuthentication
{
return $GLOBALS['BE_USER'];
}
}
1 change: 1 addition & 0 deletions typo3/sysext/adminpanel/Classes/Modules/CacheModule.php
Expand Up @@ -68,6 +68,7 @@ public function getPageSettings(): string
'cacheCmd' => $pageId,
]
),
'languageKey' => $this->getBackendUser()->user['lang'],
]
);

Expand Down
1 change: 1 addition & 0 deletions typo3/sysext/adminpanel/Classes/Modules/Debug/Events.php
Expand Up @@ -72,6 +72,7 @@ public function getContent(ModuleData $data): string
$dumper->setTheme('light');

$view->assign('events', $dumper->dump($events, true));
$view->assign('languageKey', $this->getBackendUser()->user['lang']);

return $view->render();
}
Expand Down
2 changes: 2 additions & 0 deletions typo3/sysext/adminpanel/Classes/Modules/Debug/Log.php
Expand Up @@ -114,6 +114,7 @@ public function getSettings(): string
$templateNameAndPath = 'EXT:adminpanel/Resources/Private/Templates/Modules/Debug/LogSettings.html';
$view->setTemplatePathAndFilename(GeneralUtility::getFileAbsFileName($templateNameAndPath));
$view->setPartialRootPaths(['EXT:adminpanel/Resources/Private/Partials']);
$view->assign('languageKey', $this->getBackendUser()->user['lang']);

$maxLevel = LogLevel::normalizeLevel(LogLevel::DEBUG);
$levels = [];
Expand Down Expand Up @@ -171,6 +172,7 @@ public function getContent(ModuleData $data): string
$data['groupByComponent'] = $groupByComponent;
$data['groupByLevel'] = $groupByLevel;
$view->assignMultiple($data->getArrayCopy());
$view->assign('languageKey', $this->getBackendUser()->user['lang']);

return $view->render();
}
Expand Down
Expand Up @@ -105,6 +105,7 @@ public function getContent(ModuleData $data): string
);
$this->getLanguageService()->includeLLFile('EXT:adminpanel/Resources/Private/Language/locallang_debug.xlf');
$view->assignMultiple($data->getArrayCopy());
$view->assign('languageKey', $this->getBackendUser()->user['lang']);
return $view->render();
}

Expand Down
Expand Up @@ -87,6 +87,7 @@ public function getContent(ModuleData $data): string
);
$this->getLanguageService()->includeLLFile('EXT:adminpanel/Resources/Private/Language/locallang_debug.xlf');
$view->assignMultiple($data->getArrayCopy());
$view->assign('languageKey', $this->getBackendUser()->user['lang']);
return $view->render();
}

Expand Down
Expand Up @@ -84,6 +84,7 @@ public function getContent(ModuleData $data): string
$view->setPartialRootPaths(['EXT:adminpanel/Resources/Private/Partials']);

$view->assignMultiple($data->getArrayCopy());
$view->assign('languageKey', $this->getBackendUser()->user['lang']);

return $view->render();
}
Expand Down
Expand Up @@ -79,6 +79,7 @@ public function getContent(ModuleData $data): string
$view->setPartialRootPaths(['EXT:adminpanel/Resources/Private/Partials']);

$view->assignMultiple($data->getArrayCopy());
$view->assign('languageKey', $this->getBackendUser()->user['lang']);

return $view->render();
}
Expand Down
Expand Up @@ -76,6 +76,7 @@ public function getContent(ModuleData $data): string
$view->setPartialRootPaths(['EXT:adminpanel/Resources/Private/Partials']);

$view->assignMultiple($data->getArrayCopy());
$view->assign('languageKey', $this->getBackendUser()->user['lang']);

return $view->render();
}
Expand Down
Expand Up @@ -73,6 +73,7 @@ public function getContent(ModuleData $data): string
$view->setPartialRootPaths(['EXT:adminpanel/Resources/Private/Partials']);

$view->assignMultiple($data->getArrayCopy());
$view->assign('languageKey', $this->getBackendUser()->user['lang']);

return $view->render();
}
Expand Down
1 change: 1 addition & 0 deletions typo3/sysext/adminpanel/Classes/Modules/PreviewModule.php
Expand Up @@ -132,6 +132,7 @@ public function getPageSettings(): string
'availableGroups' => $frontendGroupsRepository->getAvailableFrontendUserGroups(),
'selected' => (int)$this->config['simulateUserGroup'],
],
'languageKey' => $this->getBackendUser()->user['lang'],
]
);
return $view->render();
Expand Down
Expand Up @@ -103,6 +103,7 @@ public function getContent(ModuleData $data): string
'trackContentRendering' => (int)$this->getConfigurationOption('LR'),
'forceTemplateParsing' => (int)$this->getConfigurationOption('forceTemplateParsing'),
'typoScriptLog' => $this->renderTypoScriptLog(),
'languageKey' => $this->getBackendUser()->user['lang'],
]
);

Expand All @@ -128,7 +129,8 @@ public function getSettings(): string
'content' => (int)$this->getConfigurationOption('displayContent'),
],
'trackContentRendering' => (int)$this->getConfigurationOption('LR'),
'forceTemplateParsing' => (int)$this->getConfigurationOption('forceTemplateParsing')
'forceTemplateParsing' => (int)$this->getConfigurationOption('forceTemplateParsing'),
'languageKey' => $this->getBackendUser()->user['lang'],
]
);

Expand Down
Expand Up @@ -7,15 +7,15 @@ <h2 class="typo3-adminPanel-headline">{label}</h2>
<table class="typo3-adminPanel-table typo3-adminPanel-table-debug">
<thead>
<tr>
<th scope="col" class="typo3-adminPanel-table-cell-key"><f:translate key="LLL:EXT:adminpanel/Resources/Private/Language/locallang_info.xlf:key"/></th>
<th scope="col"><f:translate key="LLL:EXT:adminpanel/Resources/Private/Language/locallang_info.xlf:value"/></th>
<th scope="col" class="typo3-adminPanel-table-cell-key"><f:translate key="LLL:EXT:adminpanel/Resources/Private/Language/locallang_info.xlf:key" languageKey="{languageKey}"/></th>
<th scope="col"><f:translate key="LLL:EXT:adminpanel/Resources/Private/Language/locallang_info.xlf:value" languageKey="{languageKey}"/></th>
</tr>
</thead>
<tbody>
<f:for each="{data}" as="val" key="key">
<tr>
<th scope="row" class="typo3-adminPanel-table-cell-key">
<f:translate key="{key}" default="{key}" extensionName="adminpanel"/>
<f:translate key="{key}" default="{key}" extensionName="adminpanel" languageKey="{languageKey}"/>
</th>
<td>
<f:variable name="typeClass" value="string" />
Expand All @@ -24,10 +24,10 @@ <h2 class="typo3-adminPanel-headline">{label}</h2>
<f:if condition="{adm:isArray(value: val)}"><f:variable name="typeClass" value="array" /></f:if>
<f:switch expression="{typeClass}">
<f:case value="string">
<pre class="typo3-adminPanel-dump typo3-adminPanel-dump-{typeClass}"><f:if condition="{val}"><f:translate key="{val}" default="{val}" extensionName="adminpanel"/></f:if></pre>
<pre class="typo3-adminPanel-dump typo3-adminPanel-dump-{typeClass}"><f:if condition="{val}"><f:translate key="{val}" default="{val}" extensionName="adminpanel" languageKey="{languageKey}"/></f:if></pre>
</f:case>
<f:case value="array">
<f:render partial="Data/TableKeyValue" arguments="{data: val}" />
<f:render partial="Data/TableKeyValue" arguments="{data: val, languageKey: languageKey}" />
</f:case>
<f:defaultCase>
<pre class="typo3-adminPanel-dump typo3-adminPanel-dump-{typeClass}">{val}</pre>
Expand Down
Expand Up @@ -5,7 +5,7 @@
<input type="hidden" name="TSFE_ADMIN_PANEL[{name}]" value="0"/>
<input type="checkbox" id="{name}" name="TSFE_ADMIN_PANEL[{name}]" value="1" class="typo3-adminPanel-form-checkbox-input"{f:if(condition: value, then:' checked="checked"')} />
<label for="{name}" class="typo3-adminPanel-form-checkbox-label">
<f:translate key="{label}" default="{label}" extensionName="adminpanel"/>
<f:translate key="{label}" default="{label}" extensionName="adminpanel" languageKey="{languageKey}"/>
</label>
</div>
</div>
Expand Down
Expand Up @@ -3,7 +3,7 @@
<div class="typo3-adminPanel-form-group">
<div class="typo3-adminPanel-form-datetime">
<label for="{name}" class="typo3-adminPanel-form-datetime-label">
<f:translate key="{label}" default="{label}" extensionName="adminpanel"/>
<f:translate key="{label}" default="{label}" extensionName="adminpanel" languageKey="{languageKey}"/>
</label>
<div class="typo3-adminPanel-form-datetime-input-group">
<input type="date" id="{name}-date-hr" class="typo3-adminPanel-form-datetime-input" data-target="{name}"/>
Expand Down
Expand Up @@ -3,7 +3,7 @@
<div class="typo3-adminPanel-form-group">
<div class="typo3-adminPanel-form-select">
<label for="{name}" class="typo3-adminPanel-form-select-label">
<f:translate key="{label}" default="{label}" extensionName="adminpanel"/>
<f:translate key="{label}" default="{label}" extensionName="adminpanel" languageKey="{languageKey}"/>
</label>
<select name="TSFE_ADMIN_PANEL[{name}]" id="{name}" class="typo3-adminPanel-form-select-input">
<option value="0"></option>
Expand Down
Expand Up @@ -34,15 +34,15 @@
<f:for each="{module.subModules}" as="sub">
<f:if condition="{sub.settings}">
<div class="typo3-adminPanel-content-settings-group">
<h4 class="typo3-adminPanel-headline">{sub.label} <f:translate key="LLL:EXT:adminpanel/Resources/Private/Language/locallang.xlf:settings.label"/></h4>
<h4 class="typo3-adminPanel-headline">{sub.label} <f:translate key="LLL:EXT:adminpanel/Resources/Private/Language/locallang.xlf:settings.label" languageKey="{languageKey}"/></h4>
<f:format.raw>
{sub.settings}
</f:format.raw>
</div>
</f:if>
</f:for>
<div class="typo3-adminPanel-form-group">
<f:form.button class="typo3-adminPanel-btn typo3-adminPanel-btn-primary" data="{typo3-role: 'typo3-adminPanel-saveButton'}"><f:translate key="LLL:EXT:adminpanel/Resources/Private/Language/locallang.xlf:settings.updateButtonLabel"/></f:form.button>
<f:form.button class="typo3-adminPanel-btn typo3-adminPanel-btn-primary" data="{typo3-role: 'typo3-adminPanel-saveButton'}"><f:translate key="LLL:EXT:adminpanel/Resources/Private/Language/locallang.xlf:settings.updateButtonLabel" languageKey="{languageKey}"/></f:form.button>
</div>
</div>
</f:if>
Expand Down
14 changes: 7 additions & 7 deletions typo3/sysext/adminpanel/Resources/Private/Templates/Main.html
Expand Up @@ -6,26 +6,26 @@
<f:variable name="icon"><core:icon identifier="{module.iconIdentifier}" alternativeMarkupIdentifier="inline"/></f:variable>
<f:variable name="label">{module.label}</f:variable>
<f:variable name="information">{module.shortInfo}</f:variable>
<f:render partial="Modules/Item" arguments="{module: module, uid: uid, icon: icon, label: label, information: information, data: data}" debug="false"/>
<f:render partial="Modules/Item" arguments="{module: module, uid: uid, icon: icon, label: label, information: information, data: data, languageKey: languageKey}" debug="false"/>
</f:for>

<f:if condition="{hookObjectModuleContent}">
<f:variable name="uid">hook</f:variable>
<f:variable name="icon"><core:icon identifier="actions-window-open" alternativeMarkupIdentifier="inline"/></f:variable>
<f:variable name="label"><f:translate key="LLL:EXT:adminpanel/Resources/Private/Language/locallang.xlf:deprecatedModuleLabel"/></f:variable>
<f:variable name="label"><f:translate key="LLL:EXT:adminpanel/Resources/Private/Language/locallang.xlf:deprecatedModuleLabel" languageKey="{languageKey}"/></f:variable>
<f:variable name="mainContent">{hookObjectModuleContent}</f:variable>
<f:render partial="Modules/Item" arguments="{uid: uid, icon: icon, label: label, mainContent: mainContent, data: data}}" debug="false"/>
<f:render partial="Modules/Item" arguments="{uid: uid, icon: icon, label: label, mainContent: mainContent, data: data, languageKey: languageKey}}" debug="false"/>
</f:if>

</f:section>
<f:section name="Settings">

<f:variable name="uid">settings</f:variable>
<f:variable name="icon"><core:icon identifier="actions-system-extension-configure" alternativeMarkupIdentifier="inline"/></f:variable>
<f:variable name="label"><f:translate key="LLL:EXT:adminpanel/Resources/Private/Language/locallang.xlf:settings.label"/></f:variable>
<f:variable name="label"><f:translate key="LLL:EXT:adminpanel/Resources/Private/Language/locallang.xlf:settings.label" languageKey="{languageKey}"/></f:variable>
<f:variable name="information">{module.shortInfo}</f:variable>
<f:variable name="mainContent">
<h1 class="typo3-adminPanel-headline"><f:translate key="LLL:EXT:adminpanel/Resources/Private/Language/locallang.xlf:settings.label"/></h1>
<h1 class="typo3-adminPanel-headline"><f:translate key="LLL:EXT:adminpanel/Resources/Private/Language/locallang.xlf:settings.label" languageKey="{languageKey}"/></h1>
<div class="typo3-adminPanel-card-group">
<f:for each="{settingsModules}" as="module">
<f:if condition="{module.pageSettings}">
Expand All @@ -43,10 +43,10 @@ <h2 class="typo3-adminPanel-card-header-headline">
</div>
<div class="typo3-adminPanel-form-group">
<button data-typo3-role="typo3-adminPanel-saveButton" class="typo3-adminPanel-btn typo3-adminPanel-btn-primary">
<f:translate key="LLL:EXT:adminpanel/Resources/Private/Language/locallang.xlf:settings.updateButtonLabel"/>
<f:translate key="LLL:EXT:adminpanel/Resources/Private/Language/locallang.xlf:settings.updateButtonLabel" languageKey="{languageKey}"/>
</button>
</div>
</f:variable>
<f:render partial="Modules/Item" arguments="{uid: uid, icon: icon, label: label, information: information, mainContent: mainContent, data: data}" debug="false"/>
<f:render partial="Modules/Item" arguments="{uid: uid, icon: icon, label: label, information: information, mainContent: mainContent, data: data, languageKey: languageKey}" debug="false"/>
</f:section>
</html>

0 comments on commit 473410a

Please sign in to comment.