Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
7 changes: 6 additions & 1 deletion Classes/Controller/LocalizationModuleController.php
Original file line number Diff line number Diff line change
Expand Up @@ -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();
}

Expand Down Expand Up @@ -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);
Expand Down Expand Up @@ -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) {
Expand Down Expand Up @@ -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,
Expand Down
25 changes: 13 additions & 12 deletions Classes/View/AbstractExportView.php
Original file line number Diff line number Diff line change
Expand Up @@ -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;
Expand Down
20 changes: 20 additions & 0 deletions Classes/View/CatXmlView.php
Original file line number Diff line number Diff line change
Expand Up @@ -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" . '<pageGrp id="' . $pId . '" sourceUrl="' . $url . '">' . "\n";
foreach ($page['items'] as $table => $elements) {
foreach ($elements as $elementUid => $data) {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -9,15 +9,15 @@
<div class="form-group mb-2">
<div class="checkbox">
<label>
<input type="checkbox" value="1" name="check_exports" />
<input type="checkbox" value="1" name="check_exports" {f:if(condition:'{moduleContent.check_exports}',then:'checked="checked"')}/>
<f:translate key="{lll}export.xml.check_exports.title" />
</label>
</div>
</div>
<div class="form-group mb-2">
<div class="checkbox">
<label>
<input type="checkbox" value="1" name="import_asdefaultlanguage" />
<input type="checkbox" value="1" name="import_asdefaultlanguage" {f:if(condition:'{moduleContent.import_asdefaultlanguage}',then:'checked="checked"')}/>
<f:translate key="{lll}import.xml.asdefaultlanguage.title"/>
</label>
</div>
Expand All @@ -42,7 +42,7 @@
<input type="checkbox" value="1" name="export_xml_forcepreviewlanguage_only" checked="checked" disabled="disabled" />
</f:then>
<f:else>
<input type="checkbox" value="1" name="export_xml_forcepreviewlanguage_only" />
<input type="checkbox" value="1" name="export_xml_forcepreviewlanguage_only" {f:if(condition:'{moduleContent.export_xml_forcepreviewlanguage_only}',then:'checked="checked"')} />
</f:else>
</f:if>
<f:translate key="{lll}export.xml.source-language-only.title"/>
Expand Down