From a6d90bb3d57ebf31d7e0e6be98e160158f7597f6 Mon Sep 17 00:00:00 2001 From: melaniekung <71947221+melaniekung@users.noreply.github.com> Date: Thu, 15 Feb 2024 13:18:45 -0800 Subject: [PATCH] Fix GUI CSV Repo export for translations. (#1755) (#1756) --- lib/job/arRepositoryCsvExportJob.class.php | 24 ++++++++++++++++++++-- 1 file changed, 22 insertions(+), 2 deletions(-) diff --git a/lib/job/arRepositoryCsvExportJob.class.php b/lib/job/arRepositoryCsvExportJob.class.php index 3b522023df..ecd987862a 100644 --- a/lib/job/arRepositoryCsvExportJob.class.php +++ b/lib/job/arRepositoryCsvExportJob.class.php @@ -98,16 +98,36 @@ protected function exportResults($path) return -1; } + $itemsExported = $this->csvActionExport($resource, $writer); + } + + return $itemsExported; + } + + protected function csvActionExport($resource, $writer) + { + $configuration = ProjectConfiguration::getApplicationConfiguration('qubit', 'prod', false); + $this->context = sfContext::createInstance($configuration); + + // Export repositories and, optionally, related data + $itemsExported = 0; + + $cultures = array_keys(DefaultTranslationLinksComponent::getOtherCulturesAvailable($resource->actorI18ns, 'authorizedFormOfName', $resource->getAuthorizedFormOfName(['sourceCulture' => true]))); + + // Write row to file and initialize row + foreach ($cultures as $culture) { + $this->context->getUser()->setCulture($culture); + $writer->exportResource($resource); // Log progress every 1000 rows if ($itemsExported && (0 == $itemsExported % 1000)) { $this->info($this->i18n->__('%1 items exported.', ['%1' => $itemsExported])); } - - ++$itemsExported; } + ++$itemsExported; + return $itemsExported; } }