]> _ Git - fluidbook-toolbox.git/commitdiff
wait #6468 @5
authorVincent Vanwaelscappel <vincent@cubedesigners.com>
Fri, 10 Nov 2023 18:03:40 +0000 (19:03 +0100)
committerVincent Vanwaelscappel <vincent@cubedesigners.com>
Fri, 10 Nov 2023 18:03:40 +0000 (19:03 +0100)
app/Http/Controllers/Admin/Operations/ContentTranslate/ExcelExportOperation.php
app/Http/Controllers/Admin/Operations/ContentTranslate/ExcelImportOperation.php
app/Models/Base/ToolboxContentTranslate.php
resources/views/content_translate/excel_import.blade.php

index 50532466d14296e27504e90d271129c7efbb5e30..01f147c02c656a72acdb9ec1ff7cd60cd7952f61 100644 (file)
@@ -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;
index bb0cf55f73eefb9f771992fdd21188faef86c266..25eafc9f21d59fa96e018e6c452c5c011dd6fe27 100644 (file)
@@ -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('<b>' . $updated . ' translations</b> 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);
     }
 }
index 061e86d458e4bd79fe3f9081b47a9066343c0b78..70171040e0d57d2c3ad220f89d81712c56e4eaba 100644 (file)
@@ -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];
                     }
                 }
index e0fee160da236da2a13dd92a650da6191728a56e..3596d41ce0686487f41e03faaabc4dd217fe8186 100644 (file)
@@ -1,11 +1,12 @@
 {{-- __('!! Traduction des fluidbooks') --}}
 @push("after_form")
-<form method="post" style="visibility: hidden;width: 0;height: 0;" enctype="multipart/form-data" action="{{$crud->route}}/excel/import/{{request()->get('locale',app()->getLocale())}}"
-      style="visibility:hidden;height:1px;position:absolute;top:0;" id="uploadimportform">
-    @csrf
-    <input type="file" name="file" id="uploadimport"
-           accept="application/vnd.openxmlformats-officedocument.spreadsheetml.sheet">
-</form>
+    <form method="post" style="visibility: hidden;width: 0;height: 0;" enctype="multipart/form-data"
+          action="{{$crud->route}}/excel/import/{{request()->get('_locale',app()->getLocale())}}"
+          style="visibility:hidden;height:1px;position:absolute;top:0;" id="uploadimportform">
+        @csrf
+        <input type="file" name="file" id="uploadimport"
+               accept="application/vnd.openxmlformats-officedocument.spreadsheetml.sheet">
+    </form>
 @endpush
 
 <button class="btn btn-outline-notice" id="uploadimportbutton"><span