From: soufiane Date: Thu, 30 Nov 2023 14:37:15 +0000 (+0100) Subject: Merge remote-tracking branch 'origin/backpack5' into backpack5 X-Git-Url: http://git.cubedesigners.com/?a=commitdiff_plain;h=b82b88947218157683e261954895382cd2096193;p=fluidbook-toolbox.git Merge remote-tracking branch 'origin/backpack5' into backpack5 # Conflicts: # app/Console/Commands/FluidbookCollection.php # app/Console/Commands/FluidbookPackage.php # app/Console/Commands/WorkshopMigration.php # app/Console/Kernel.php --- b82b88947218157683e261954895382cd2096193 diff --cc app/Http/Controllers/Admin/Operations/ContentTranslate/ExcelImportOperation.php index bb0cf55f7,000000000..0421c7f88 mode 100644,000000..100644 --- a/app/Http/Controllers/Admin/Operations/ContentTranslate/ExcelImportOperation.php +++ b/app/Http/Controllers/Admin/Operations/ContentTranslate/ExcelImportOperation.php @@@ -1,75 -1,0 +1,75 @@@ +flash(); + return; + } + + $reader = new Xlsx(); + $xls = $reader->load($file['tmp_name']); + $sheet = $xls->getActiveSheet(); + + $class = get_class($this->getModelInstance()); + + $existingTranslation = $class::getLocaleTranslations($locale); + + + $translations = []; + $count = 0; + $updated = 0; + foreach ($sheet->getRowIterator(2) as $row) { + $ri = $row->getRowIndex(); + $k = $sheet->getCellByColumnAndRow(1, $ri)->getValue(); + if (!FluidbookTranslate::isKey($k)) { + continue; + } + + $v = $sheet->getCellByColumnAndRow(4, $ri)->getValue(); + if($v instanceof RichText){ + $v=$v->getPlainText(); + } + + if (!isset($existingTranslation[$k]['translation']) || $v != $existingTranslation[$k]['translation']) { + $translations[$k] = $v; + $updated++; + } + $count++; + } + + + if (!$count) { + Alert::warning('No translation were find')->flash(); + } elseif (!$updated) { + Alert::warning('No translation were updated')->flash(); + } else { + $class::updateTranslation($locale, $translations); + Alert::success('' . $updated . ' translations were updated (' . $count . ' total)')->flash(); + } - return redirect($this->crud->route . '/1/edit/?locale=' . $locale); ++ return redirect($this->crud->route . '/1/edit/?_locale=' . $locale); + } +}