From 96f832423dc0bb0ada997d10b451024aa6cd0e58 Mon Sep 17 00:00:00 2001 From: Vincent Vanwaelscappel Date: Fri, 10 Nov 2023 19:03:40 +0100 Subject: [PATCH] wait #6468 @5 --- .../ContentTranslate/ExcelExportOperation.php | 8 +++++--- .../ContentTranslate/ExcelImportOperation.php | 15 ++++++++------- app/Models/Base/ToolboxContentTranslate.php | 3 ++- .../content_translate/excel_import.blade.php | 13 +++++++------ 4 files changed, 22 insertions(+), 17 deletions(-) diff --git a/app/Http/Controllers/Admin/Operations/ContentTranslate/ExcelExportOperation.php b/app/Http/Controllers/Admin/Operations/ContentTranslate/ExcelExportOperation.php index 50532466d..01f147c02 100644 --- a/app/Http/Controllers/Admin/Operations/ContentTranslate/ExcelExportOperation.php +++ b/app/Http/Controllers/Admin/Operations/ContentTranslate/ExcelExportOperation.php @@ -42,9 +42,9 @@ trait ExcelExportOperation $xls->getDefaultStyle()->getProtection()->setLocked(false); $worksheet->setCellValueByColumnAndRow(1, 1, 'ID'); - $worksheet->setCellValueByColumnAndRow(2, 1, 'Reference string'); - $worksheet->setCellValueByColumnAndRow(3, 1, 'Reference translation'); - $worksheet->setCellValueByColumnAndRow(4, 1, 'Translation'); + $worksheet->setCellValueByColumnAndRow(2, 1, 'Reference string (text in the code)'); + $worksheet->setCellValueByColumnAndRow(3, 1, 'Reference translation (translation in the reference language ' . $ref . ')'); + $worksheet->setCellValueByColumnAndRow(4, 1, 'Translation (edit this column)'); for ($i = 2; $i <= 4; $i++) { $style = $worksheet->getStyleByColumnAndRow($i, 1); $style->getAlignment()->setWrapText(true); @@ -97,6 +97,8 @@ trait ExcelExportOperation } } $res = []; + + foreach ($data as $k => $v) { if ($k === 'k') { continue; diff --git a/app/Http/Controllers/Admin/Operations/ContentTranslate/ExcelImportOperation.php b/app/Http/Controllers/Admin/Operations/ContentTranslate/ExcelImportOperation.php index bb0cf55f7..25eafc9f2 100644 --- a/app/Http/Controllers/Admin/Operations/ContentTranslate/ExcelImportOperation.php +++ b/app/Http/Controllers/Admin/Operations/ContentTranslate/ExcelImportOperation.php @@ -10,6 +10,7 @@ use Illuminate\Support\Facades\Route; use PhpOffice\PhpSpreadsheet\Reader\Xlsx; use PhpOffice\PhpSpreadsheet\RichText\RichText; use Prologue\Alerts\Facades\Alert; + // __('!! Traduction de l\'interface fluidbook') trait ExcelImportOperation { @@ -26,7 +27,7 @@ trait ExcelImportOperation $file = $_FILES['file']; if ($file['error']) { - Alert::warning('No file were imported')->flash(); + Alert::warning(__('Aucun fichier chargé'))->flash(); return; } @@ -50,8 +51,8 @@ trait ExcelImportOperation } $v = $sheet->getCellByColumnAndRow(4, $ri)->getValue(); - if($v instanceof RichText){ - $v=$v->getPlainText(); + if ($v instanceof RichText) { + $v = $v->getPlainText(); } if (!isset($existingTranslation[$k]['translation']) || $v != $existingTranslation[$k]['translation']) { @@ -63,13 +64,13 @@ trait ExcelImportOperation if (!$count) { - Alert::warning('No translation were find')->flash(); + Alert::warning(__('Aucune traduction n\'a été trouvée dans le fichier'))->flash(); } elseif (!$updated) { - Alert::warning('No translation were updated')->flash(); + Alert::warning(__('Aucune traduction n\'a été mise à jour'))->flash(); } else { $class::updateTranslation($locale, $translations); - Alert::success('' . $updated . ' translations were updated (' . $count . ' total)')->flash(); + Alert::success(__(':nb traductions ont été mises à jour (sur un total de :total) pour la langue :locale', ['nb' => $updated, 'total' => $count, 'locale' => $locale]))->flash(); } - return redirect($this->crud->route . '/1/edit/?locale=' . $locale); + return redirect($this->crud->route . '/1/edit?_locale=' . $locale); } } diff --git a/app/Models/Base/ToolboxContentTranslate.php b/app/Models/Base/ToolboxContentTranslate.php index 061e86d45..70171040e 100644 --- a/app/Models/Base/ToolboxContentTranslate.php +++ b/app/Models/Base/ToolboxContentTranslate.php @@ -62,6 +62,8 @@ class ToolboxContentTranslate extends Translate public static function getAllTranslations($force = true) { if (null === static::$_allTranslations) { + + $cacheKey = static::_getCacheKey(); if ($force) { Cache::forget($cacheKey); @@ -79,7 +81,6 @@ class ToolboxContentTranslate extends Translate foreach ($json as $code => $tr) { $res[$code] = []; foreach ($tr as $k => $v) { - $res[$code][$k] = ['str' => static::keyToStr($k), 'translation' => $v]; } } diff --git a/resources/views/content_translate/excel_import.blade.php b/resources/views/content_translate/excel_import.blade.php index e0fee160d..3596d41ce 100644 --- a/resources/views/content_translate/excel_import.blade.php +++ b/resources/views/content_translate/excel_import.blade.php @@ -1,11 +1,12 @@ {{-- __('!! Traduction des fluidbooks') --}} @push("after_form") - + @endpush