diff --git a/Classes/Controller/LocalizationModuleController.php b/Classes/Controller/LocalizationModuleController.php index e260c22..180cfba 100644 --- a/Classes/Controller/LocalizationModuleController.php +++ b/Classes/Controller/LocalizationModuleController.php @@ -126,6 +126,7 @@ public function initialize(ServerRequestInterface $request): void // @extensionScannerIgnoreLine $this->id = (int)($request->getQueryParams()['id'] ?? $request->getParsedBody()['id'] ?? 0); $this->srcPID = (int)($request->getQueryParams()['srcPID'] ?? $request->getParsedBody()['srcPID'] ?? 0); + $this->previewLanguage = (int)($request->getQueryParams()['export_xml_forcepreviewlanguage'] ?? $request->getParsedBody()['export_xml_forcepreviewlanguage'] ?? 0); $this->menuConfig(); } @@ -469,6 +470,7 @@ protected function excelExportImportAction(L10nConfiguration $l10nConfiguration) $importExcel = GeneralUtility::_POST('import_excel'); $exportExcel = GeneralUtility::_POST('export_excel'); $checkExports = GeneralUtility::_POST('check_exports') ?? false; + $export_xml_forcepreviewlanguage_only = GeneralUtility::_POST('export_xml_forcepreviewlanguage_only'); if ($importAsDefaultLanguage) { $this->l10nBaseService->setImportAsDefaultLanguage(true); @@ -510,7 +512,7 @@ protected function excelExportImportAction(L10nConfiguration $l10nConfiguration) if ($export_xml_forcepreviewlanguage > 0) { $viewClass->setForcedSourceLanguage($export_xml_forcepreviewlanguage); } - if (GeneralUtility::_POST('export_xml_forcepreviewlanguage_only')) { + if ($export_xml_forcepreviewlanguage_only) { $viewClass->setOnlyForcedSourceLanguage(); } if ($this->MOD_SETTINGS['onlyChangedContent'] ?? false) { @@ -581,6 +583,9 @@ protected function excelExportImportAction(L10nConfiguration $l10nConfiguration) 'existingExportsOverview' => $existingExportsOverview, 'isImport' => $isImport, 'importSuccess' => $importSuccess, + 'check_exports' => $checkExports, + 'import_asdefaultlanguage' => $importAsDefaultLanguage, + 'export_xml_forcepreviewlanguage_only' => $export_xml_forcepreviewlanguage_only, 'previewLanguageMenu' => $this->makePreviewLanguageMenu(), 'flashMessageHtml' => $flashMessageHtml, 'internalFlashMessage' => $internalFlashMessage, diff --git a/Classes/View/AbstractExportView.php b/Classes/View/AbstractExportView.php index 859f9e2..e3bd21b 100644 --- a/Classes/View/AbstractExportView.php +++ b/Classes/View/AbstractExportView.php @@ -199,22 +199,23 @@ public function setFilename(): void $fileType = 'catxml'; } - $sourceLanguageId = $this->l10ncfgObj->getForcedSourceLanguage() ?: 0; - $sourceLanguageConfiguration = $this->site->getAvailableLanguages($this->getBackendUser())[$sourceLanguageId] ?? null; + $sourceLanguageId = $this->forcedSourceLanguage ?: 0; + try { + $sourceLanguageConfiguration = $this->site->getLanguageById($sourceLanguageId); + } catch(\InvalidArgumentException $e) { + $sourceLanguageConfiguration = null; + } if ($sourceLanguageConfiguration instanceof SiteLanguage) { - if ($this->typo3Version->getMajorVersion() < 12) { - $sourceLang = $sourceLanguageConfiguration->getLocale() ?: $sourceLanguageConfiguration->getTwoLetterIsoCode(); - } else { - $sourceLang = $sourceLanguageConfiguration->getLocale()->getName() ?: $sourceLanguageConfiguration->getLocale()->getLanguageCode(); - } + $sourceLang = $sourceLanguageConfiguration->getHreflang(); + } + try { + $targetLanguageConfiguration = $this->site->getLanguageById($this->targetLanguage); + } catch(\InvalidArgumentException $e) { + $targetLanguageConfiguration = null; } $targetLanguageConfiguration = $this->site->getAvailableLanguages($this->getBackendUser())[$this->targetLanguage] ?? null; if ($targetLanguageConfiguration instanceof SiteLanguage) { - if ($this->typo3Version->getMajorVersion() < 12) { - $targetLang = $targetLanguageConfiguration->getLocale() ?: $targetLanguageConfiguration->getTwoLetterIsoCode(); - } else { - $targetLang = $targetLanguageConfiguration->getLocale()->getName() ?: $targetLanguageConfiguration->getLocale()->getLanguageCode(); - } + $targetLang = $targetLanguageConfiguration->getHreflang(); } if ($sourceLang !== '' && $targetLang !== '') { $fileNamePrefix = (trim($this->l10ncfgObj->getFileNamePrefix())) ? $this->l10ncfgObj->getFileNamePrefix() . '_' . $fileType : $fileType; diff --git a/Classes/View/CatXmlView.php b/Classes/View/CatXmlView.php index 8891ae8..9717a12 100644 --- a/Classes/View/CatXmlView.php +++ b/Classes/View/CatXmlView.php @@ -71,7 +71,27 @@ public function render(): string if (empty($page['items'])) { continue; } + // Build a source URL that reflects the requested source language (forcedSourceLanguage) + // instead of always using the default language $url = $page['header']['url'] ?? ''; + if (!empty($this->forcedSourceLanguage)) { + // For TYPO3 v12+, enforce language via special _language parameter with SiteLanguage, + // not by appending L (which can be ignored by routing) + try { + if ($this->typo3Version->getMajorVersion() >= 12) { + $siteLanguage = $this->site->getLanguageById((int)$this->forcedSourceLanguage); + if ($siteLanguage instanceof SiteLanguage) { + // Pass SiteLanguage via reserved _language parameter so router can build the language-specific URL + $url = (string)$this->site->getRouter()->generateUri((int)$pId, ['_language' => $siteLanguage]); + } + } else { + // Fallback for older TYPO3 versions: use L parameter + $url = (string)$this->site->getRouter()->generateUri((int)$pId, ['L' => (int)$this->forcedSourceLanguage]); + } + } catch (\Throwable $e) { + // Keep $url from header as fallback if generation fails for any reason + } + } $output[] = "\t" . '' . "\n"; foreach ($page['items'] as $table => $elements) { foreach ($elements as $elementUid => $data) { diff --git a/Resources/Private/Partials/LocalizationModule/Modules/ExportExcel.html b/Resources/Private/Partials/LocalizationModule/Modules/ExportExcel.html index bf9b0d1..44aa0bc 100644 --- a/Resources/Private/Partials/LocalizationModule/Modules/ExportExcel.html +++ b/Resources/Private/Partials/LocalizationModule/Modules/ExportExcel.html @@ -9,7 +9,7 @@
@@ -17,7 +17,7 @@
@@ -42,7 +42,7 @@ - +