]> _ Git - fluidbook-toolbox.git/commitdiff
wip #6634 @1
authorVincent Vanwaelscappel <vincent@cubedesigners.com>
Wed, 17 Jan 2024 18:22:17 +0000 (19:22 +0100)
committerVincent Vanwaelscappel <vincent@cubedesigners.com>
Wed, 17 Jan 2024 18:22:17 +0000 (19:22 +0100)
app/Fluidbook/Packager/WindowsInstaller.php
app/Models/Base/ToolboxBaseTranslate.php

index 85cdf193108086f2c29c878e6e05a083588d7ae0..bb43b71161e3e50005a3d7ae4a03cb19cd5dc808 100644 (file)
@@ -26,7 +26,9 @@ class WindowsInstaller extends WindowsZIP
     {
         $winvdir = $this->getFinalPackageDir();
 
-        $locale = $this->book->getDefaultTranslations()['nsis'];
+        $trans=$this->book->getDefaultTranslations();
+
+        $locale = $trans['nsis'];
         if ($locale === 'Arabic') {
             $locale = 'English';
         }
index cfc6f5c396a3d914bc79606fd9bf3f7ffe177604..f60ff9a89c5884bebe29b061ffd880dfead7f91b 100644 (file)
@@ -7,6 +7,7 @@ use App\Http\Controllers\Admin\Operations\ContentTranslate\ExcelImportOperation;
 use Cubist\Backpack\Facades\App;
 use Cubist\Backpack\Magic\Models\Translate;
 use Cubist\Util\Files\Files;
+use Cubist\Util\Json;
 use Cubist\Util\PHP;
 use Illuminate\Support\Facades\Cache;
 
@@ -60,14 +61,13 @@ class ToolboxBaseTranslate extends Translate
     public static function getAllTranslations($force = true)
     {
         if (null === static::$_allTranslations) {
-
-
             $cacheKey = static::_getCacheKey();
-            if ($force) {
+            if (true || $force) {
                 Cache::forget($cacheKey);
             }
             static::$_allTranslations = Cache::remember($cacheKey, 3600, function () {
                 start_measure('Get all ' . static::$_name . ' translations !');
+                /** @var ToolboxBaseTranslate $t */
                 $t = static::find(1);
                 try {
                     $json = json_decode($t->getRawOriginal('content_translatable'), true, 512, JSON_THROW_ON_ERROR);
@@ -82,6 +82,26 @@ class ToolboxBaseTranslate extends Translate
                         $res[$code][$k] = ['str' => static::keyToStr($k), 'translation' => $v];
                     }
                 }
+
+                foreach ($t->getAttributes() as $k => $item) {
+                    if (in_array($k, ['content_translatable', 'id', 'deleted_at', 'created_at', 'updated_at', 'created_ok'])) {
+                        continue;
+                    }
+                    $v = $item;
+                    if (Json::isJson($v)) {
+                        $v = json_decode($v, true);
+                    }
+                    if (is_scalar($v)) {
+                        continue;
+                    }
+                    foreach ($v as $locale => $str) {
+                        if (isset($res[$locale])) {
+                            $res[$locale][$k] = ['str' => $k, 'translation' => $str];
+                        }
+                    }
+
+                }
+
                 stop_measure('Get all ' . static::$_name . ' translations !');
                 return $res;