From: Vincent Vanwaelscappel Date: Wed, 5 Jun 2024 14:04:58 +0000 (+0200) Subject: wait #6945 @0.5 X-Git-Url: http://git.cubedesigners.com/?a=commitdiff_plain;h=65e2650562bd21ab431c3ee42c28698f7b8e276a;p=fluidbook-toolbox.git wait #6945 @0.5 --- diff --git a/app/Models/ToolWebflow.php b/app/Models/ToolWebflow.php index b26e42ec0..0fe896eae 100644 --- a/app/Models/ToolWebflow.php +++ b/app/Models/ToolWebflow.php @@ -11,6 +11,7 @@ use App\Models\Base\ToolboxTranslatableModel; use App\Services\Webflow; use App\SubForms\Webflow\SEOPage; use App\SubForms\Webflow\WebflowText; +use Cubist\Azure\Translate\Api; use Cubist\Backpack\Magic\Fields\BunchOfFieldsMultiple; use Cubist\Backpack\Magic\Fields\Code; use Cubist\Backpack\Magic\Fields\Hidden; @@ -57,7 +58,7 @@ class ToolWebflow extends ToolboxTranslatableModel $this->addField('upload', SelectFromArray::class, __('Uploader sur'), ['translatable' => false, 'options' => $sites, 'tab' => __('Paramètres')]); $this->addField('js', Code::class, __('Javascript complémentaire'), ['translatable' => false, 'language' => 'js', 'tab' => __('Code'), 'hint' => __('Code ajouté à toutes les pages')]); $this->addField('css', Code::class, __('CSS complémentaire'), ['translatable' => false, 'language' => 'css', 'tab' => __('Code'), 'hint' => __('Code ajouté à toutes les pages')]); - $this->addField('texts', WebflowTexts::class, '', ['tab' => __('Textes'), 'translatable' => true,'hint'=>__('Modifier un texte ici ne produira aucun changement sur webflow')]); + $this->addField('texts', WebflowTexts::class, '', ['tab' => __('Textes'), 'translatable' => true, 'hint' => __('Modifier un texte ici ne produira aucun changement sur webflow')]); $this->addField('images', WebflowImages::class, '', ['tab' => __('Images'), 'translatable' => true]); $this->addField('seo', BunchOfFieldsMultiple::class, '', ['translatable' => true, 'edit_label' => '%url | %seo_title', 'allows_add' => false, 'allows_delete' => false, 'allows_clone' => false, 'allows_reorder' => false, 'bunch' => SEOPage::class, 'tab' => __('SEO')]); $this->addField('api', Hidden::class); @@ -174,12 +175,13 @@ class ToolWebflow extends ToolboxTranslatableModel $this->api = Webflow::getEditableData($this->webflow); $mainLocale = $this->getMainLocale(); + $locales = $this->getLocalesCodes(); - $props = ['seo'/*, 'texts', 'images'*/]; + $props = ['seo']; foreach ($props as $prop) { $data = Json::decode($this->$prop, Json::TYPE_ARRAY); $data[$mainLocale] = $this->api[$prop]; - foreach ($this->getLocalesCodes() as $locale) { + foreach ($locales as $locale) { if ($locale === $mainLocale) { continue; } @@ -193,6 +195,24 @@ class ToolWebflow extends ToolboxTranslatableModel $this->setTranslations($prop, $data); } + Api::setCache(Files::mkdir(protected_path('cache/azure_translate'))); + $translateAPI = new Api(env('AZURE_TRANSLATE_API_KEY')); + + $translations = $this->getTranslations('texts'); + foreach ($locales as $locale) { + if (!isset($translations[$locale])) { + $translations[$locale] = []; + } + } + foreach ($this->api['texts'] as $text => $details) { + foreach ($locales as $locale) { + if (!isset($translations[$locale][$details['key']])) { + $translations[$locale][$details['key']] = $locale === $mainLocale ? '' : $translateAPI->translate($text, $locale, $mainLocale); + } + } + } + $this->setTranslations('texts', $translations); + $this->saveQuietly(); } catch (LockTimeoutException $e) { diff --git a/composer.json b/composer.json index 785af1a68..88143b219 100644 --- a/composer.json +++ b/composer.json @@ -35,6 +35,7 @@ "ext-zlib": "*", "cubedesigners/userdatabase": "dev-master", "cubist/azuretts": "dev-master", + "cubist/azuretranslate": "dev-master", "cubist/cms-back": "dev-master", "cubist/excel": "dev-master", "cubist/matomo": "dev-master", diff --git a/composer.lock b/composer.lock index 94d476dee..48d0b19eb 100644 --- a/composer.lock +++ b/composer.lock @@ -4,7 +4,7 @@ "Read more about it at https://getcomposer.org/doc/01-basic-usage.md#installing-dependencies", "This file is @generated automatically" ], - "content-hash": "06f032dba93afca18a24b1684cfc5463", + "content-hash": "157805c6a6d172fefa13890c40b34535", "packages": [ { "name": "archtechx/enums", @@ -1633,6 +1633,49 @@ "description": "Cubedesigners common users database", "time": "2024-03-06T16:54:54+00:00" }, + { + "name": "cubist/azuretranslate", + "version": "dev-master", + "source": { + "type": "git", + "url": "git://git.cubedesigners.com/cubist_azuretranslation.git", + "reference": "96c398a7b3b02ffce5596ccec70f652c835a8f0f" + }, + "dist": { + "type": "tar", + "url": "https://composer.cubedesigners.com/dist/cubist/azuretranslate/cubist-azuretranslate-dev-master-08a45c.tar", + "reference": "96c398a7b3b02ffce5596ccec70f652c835a8f0f", + "shasum": "e518821d744806b22e9203506a439ee4567eae5e" + }, + "require": { + "ext-json": "*", + "ext-mbstring": "*", + "guzzlehttp/guzzle": "^7.7.0", + "illuminate/cache": "~5.8|^6.0|^7.0|^8.0|^9.0|^10.0", + "php": ">=7.2.5" + }, + "suggest": { + "laravel/framework": "~5.8|^6.0|^7.0|^8.0|^9.0|^10.0" + }, + "default-branch": true, + "type": "library", + "autoload": { + "psr-4": { + "Cubist\\Azure\\Translate\\": "src" + } + }, + "license": [ + "proprietary" + ], + "authors": [ + { + "name": "Vincent Vanwaelscappel", + "email": "vincent@cubedesigners.com" + } + ], + "description": "Azure Translate REST API", + "time": "2024-06-05T10:59:57+00:00" + }, { "name": "cubist/azuretts", "version": "dev-master", @@ -6897,16 +6940,16 @@ }, { "name": "nesbot/carbon", - "version": "2.72.3", + "version": "2.72.5", "source": { "type": "git", "url": "https://github.com/briannesbitt/Carbon.git", - "reference": "0c6fd108360c562f6e4fd1dedb8233b423e91c83" + "reference": "afd46589c216118ecd48ff2b95d77596af1e57ed" }, "dist": { "type": "zip", - "url": "https://api.github.com/repos/briannesbitt/Carbon/zipball/0c6fd108360c562f6e4fd1dedb8233b423e91c83", - "reference": "0c6fd108360c562f6e4fd1dedb8233b423e91c83", + "url": "https://api.github.com/repos/briannesbitt/Carbon/zipball/afd46589c216118ecd48ff2b95d77596af1e57ed", + "reference": "afd46589c216118ecd48ff2b95d77596af1e57ed", "shasum": "" }, "require": { @@ -6940,8 +6983,8 @@ "type": "library", "extra": { "branch-alias": { - "dev-3.x": "3.x-dev", - "dev-master": "2.x-dev" + "dev-master": "3.x-dev", + "dev-2.x": "2.x-dev" }, "laravel": { "providers": [ @@ -7000,7 +7043,7 @@ "type": "tidelift" } ], - "time": "2024-01-25T10:35:09+00:00" + "time": "2024-06-03T19:18:41+00:00" }, { "name": "nette/schema", @@ -9625,16 +9668,16 @@ }, { "name": "spatie/laravel-backup", - "version": "8.8.0", + "version": "8.8.1", "source": { "type": "git", "url": "https://github.com/spatie/laravel-backup.git", - "reference": "7e74431fc5c46319a27daa44897df1c7bf4afe5a" + "reference": "a9c2d2f726f4c60c2dc5d7c0c8380f72492638c2" }, "dist": { "type": "zip", - "url": "https://api.github.com/repos/spatie/laravel-backup/zipball/7e74431fc5c46319a27daa44897df1c7bf4afe5a", - "reference": "7e74431fc5c46319a27daa44897df1c7bf4afe5a", + "url": "https://api.github.com/repos/spatie/laravel-backup/zipball/a9c2d2f726f4c60c2dc5d7c0c8380f72492638c2", + "reference": "a9c2d2f726f4c60c2dc5d7c0c8380f72492638c2", "shasum": "" }, "require": { @@ -9708,7 +9751,7 @@ ], "support": { "issues": "https://github.com/spatie/laravel-backup/issues", - "source": "https://github.com/spatie/laravel-backup/tree/8.8.0" + "source": "https://github.com/spatie/laravel-backup/tree/8.8.1" }, "funding": [ { @@ -9720,7 +9763,7 @@ "type": "other" } ], - "time": "2024-05-02T13:09:01+00:00" + "time": "2024-06-04T11:31:33+00:00" }, { "name": "spatie/laravel-googletagmanager", @@ -10641,16 +10684,16 @@ }, { "name": "symfony/cache", - "version": "v7.1.0", + "version": "v7.1.1", "source": { "type": "git", "url": "https://github.com/symfony/cache.git", - "reference": "c36a10e6456b32e40d1ef516b3a2749883f9117b" + "reference": "760294dc7158372699dccd077965c16c328f8719" }, "dist": { "type": "zip", - "url": "https://api.github.com/repos/symfony/cache/zipball/c36a10e6456b32e40d1ef516b3a2749883f9117b", - "reference": "c36a10e6456b32e40d1ef516b3a2749883f9117b", + "url": "https://api.github.com/repos/symfony/cache/zipball/760294dc7158372699dccd077965c16c328f8719", + "reference": "760294dc7158372699dccd077965c16c328f8719", "shasum": "" }, "require": { @@ -10718,7 +10761,7 @@ "psr6" ], "support": { - "source": "https://github.com/symfony/cache/tree/v7.1.0" + "source": "https://github.com/symfony/cache/tree/v7.1.1" }, "funding": [ { @@ -10734,7 +10777,7 @@ "type": "tidelift" } ], - "time": "2024-05-28T08:39:33+00:00" + "time": "2024-05-31T14:57:53+00:00" }, { "name": "symfony/cache-contracts", @@ -10911,16 +10954,16 @@ }, { "name": "symfony/css-selector", - "version": "v7.1.0", + "version": "v7.1.1", "source": { "type": "git", "url": "https://github.com/symfony/css-selector.git", - "reference": "843f2f7ac5e4c5bf0ec77daef23ca6d4d8922adc" + "reference": "1c7cee86c6f812896af54434f8ce29c8d94f9ff4" }, "dist": { "type": "zip", - "url": "https://api.github.com/repos/symfony/css-selector/zipball/843f2f7ac5e4c5bf0ec77daef23ca6d4d8922adc", - "reference": "843f2f7ac5e4c5bf0ec77daef23ca6d4d8922adc", + "url": "https://api.github.com/repos/symfony/css-selector/zipball/1c7cee86c6f812896af54434f8ce29c8d94f9ff4", + "reference": "1c7cee86c6f812896af54434f8ce29c8d94f9ff4", "shasum": "" }, "require": { @@ -10956,7 +10999,7 @@ "description": "Converts CSS selectors to XPath expressions", "homepage": "https://symfony.com", "support": { - "source": "https://github.com/symfony/css-selector/tree/v7.1.0" + "source": "https://github.com/symfony/css-selector/tree/v7.1.1" }, "funding": [ { @@ -10972,7 +11015,7 @@ "type": "tidelift" } ], - "time": "2024-04-18T09:32:20+00:00" + "time": "2024-05-31T14:57:53+00:00" }, { "name": "symfony/deprecation-contracts", @@ -11118,16 +11161,16 @@ }, { "name": "symfony/event-dispatcher", - "version": "v7.1.0", + "version": "v7.1.1", "source": { "type": "git", "url": "https://github.com/symfony/event-dispatcher.git", - "reference": "522d2772d6c7bab843b0c52466dc7844622bacc2" + "reference": "9fa7f7a21beb22a39a8f3f28618b29e50d7a55a7" }, "dist": { "type": "zip", - "url": "https://api.github.com/repos/symfony/event-dispatcher/zipball/522d2772d6c7bab843b0c52466dc7844622bacc2", - "reference": "522d2772d6c7bab843b0c52466dc7844622bacc2", + "url": "https://api.github.com/repos/symfony/event-dispatcher/zipball/9fa7f7a21beb22a39a8f3f28618b29e50d7a55a7", + "reference": "9fa7f7a21beb22a39a8f3f28618b29e50d7a55a7", "shasum": "" }, "require": { @@ -11178,7 +11221,7 @@ "description": "Provides tools that allow your application components to communicate with each other by dispatching events and listening to them", "homepage": "https://symfony.com", "support": { - "source": "https://github.com/symfony/event-dispatcher/tree/v7.1.0" + "source": "https://github.com/symfony/event-dispatcher/tree/v7.1.1" }, "funding": [ { @@ -11194,7 +11237,7 @@ "type": "tidelift" } ], - "time": "2024-04-18T09:32:20+00:00" + "time": "2024-05-31T14:57:53+00:00" }, { "name": "symfony/event-dispatcher-contracts", @@ -11274,16 +11317,16 @@ }, { "name": "symfony/filesystem", - "version": "v7.1.0", + "version": "v7.1.1", "source": { "type": "git", "url": "https://github.com/symfony/filesystem.git", - "reference": "8ecdde25881598f86cdd7cfe8b25302b66a402e9" + "reference": "802e87002f919296c9f606457d9fa327a0b3d6b2" }, "dist": { "type": "zip", - "url": "https://api.github.com/repos/symfony/filesystem/zipball/8ecdde25881598f86cdd7cfe8b25302b66a402e9", - "reference": "8ecdde25881598f86cdd7cfe8b25302b66a402e9", + "url": "https://api.github.com/repos/symfony/filesystem/zipball/802e87002f919296c9f606457d9fa327a0b3d6b2", + "reference": "802e87002f919296c9f606457d9fa327a0b3d6b2", "shasum": "" }, "require": { @@ -11320,7 +11363,7 @@ "description": "Provides basic utilities for the filesystem", "homepage": "https://symfony.com", "support": { - "source": "https://github.com/symfony/filesystem/tree/v7.1.0" + "source": "https://github.com/symfony/filesystem/tree/v7.1.1" }, "funding": [ { @@ -11336,7 +11379,7 @@ "type": "tidelift" } ], - "time": "2024-05-17T10:55:18+00:00" + "time": "2024-05-31T14:57:53+00:00" }, { "name": "symfony/finder", @@ -11931,16 +11974,16 @@ }, { "name": "symfony/options-resolver", - "version": "v7.1.0", + "version": "v7.1.1", "source": { "type": "git", "url": "https://github.com/symfony/options-resolver.git", - "reference": "9564f64c16f99e29f252eafc642965e8fcb755ce" + "reference": "47aa818121ed3950acd2b58d1d37d08a94f9bf55" }, "dist": { "type": "zip", - "url": "https://api.github.com/repos/symfony/options-resolver/zipball/9564f64c16f99e29f252eafc642965e8fcb755ce", - "reference": "9564f64c16f99e29f252eafc642965e8fcb755ce", + "url": "https://api.github.com/repos/symfony/options-resolver/zipball/47aa818121ed3950acd2b58d1d37d08a94f9bf55", + "reference": "47aa818121ed3950acd2b58d1d37d08a94f9bf55", "shasum": "" }, "require": { @@ -11978,7 +12021,7 @@ "options" ], "support": { - "source": "https://github.com/symfony/options-resolver/tree/v7.1.0" + "source": "https://github.com/symfony/options-resolver/tree/v7.1.1" }, "funding": [ { @@ -11994,7 +12037,7 @@ "type": "tidelift" } ], - "time": "2024-04-18T09:32:20+00:00" + "time": "2024-05-31T14:57:53+00:00" }, { "name": "symfony/polyfill-ctype", @@ -12929,16 +12972,16 @@ }, { "name": "symfony/serializer", - "version": "v7.1.0", + "version": "v7.1.1", "source": { "type": "git", "url": "https://github.com/symfony/serializer.git", - "reference": "972eb05320d06d07399b71b05e6da9032c865f1d" + "reference": "74817ee48e37cce1a1b33c66ffdb750e7e048c3c" }, "dist": { "type": "zip", - "url": "https://api.github.com/repos/symfony/serializer/zipball/972eb05320d06d07399b71b05e6da9032c865f1d", - "reference": "972eb05320d06d07399b71b05e6da9032c865f1d", + "url": "https://api.github.com/repos/symfony/serializer/zipball/74817ee48e37cce1a1b33c66ffdb750e7e048c3c", + "reference": "74817ee48e37cce1a1b33c66ffdb750e7e048c3c", "shasum": "" }, "require": { @@ -13006,7 +13049,7 @@ "description": "Handles serializing and deserializing data structures, including object graphs, into array structures or other formats like XML and JSON.", "homepage": "https://symfony.com", "support": { - "source": "https://github.com/symfony/serializer/tree/v7.1.0" + "source": "https://github.com/symfony/serializer/tree/v7.1.1" }, "funding": [ { @@ -13022,7 +13065,7 @@ "type": "tidelift" } ], - "time": "2024-05-21T15:59:31+00:00" + "time": "2024-05-31T14:57:53+00:00" }, { "name": "symfony/service-contracts", @@ -13109,16 +13152,16 @@ }, { "name": "symfony/string", - "version": "v7.1.0", + "version": "v7.1.1", "source": { "type": "git", "url": "https://github.com/symfony/string.git", - "reference": "6f41b185e742737917e6f2e3eca37767fba5f17a" + "reference": "60bc311c74e0af215101235aa6f471bcbc032df2" }, "dist": { "type": "zip", - "url": "https://api.github.com/repos/symfony/string/zipball/6f41b185e742737917e6f2e3eca37767fba5f17a", - "reference": "6f41b185e742737917e6f2e3eca37767fba5f17a", + "url": "https://api.github.com/repos/symfony/string/zipball/60bc311c74e0af215101235aa6f471bcbc032df2", + "reference": "60bc311c74e0af215101235aa6f471bcbc032df2", "shasum": "" }, "require": { @@ -13176,7 +13219,7 @@ "utf8" ], "support": { - "source": "https://github.com/symfony/string/tree/v7.1.0" + "source": "https://github.com/symfony/string/tree/v7.1.1" }, "funding": [ { @@ -13192,7 +13235,7 @@ "type": "tidelift" } ], - "time": "2024-05-17T10:55:18+00:00" + "time": "2024-06-04T06:40:14+00:00" }, { "name": "symfony/translation", @@ -13443,16 +13486,16 @@ }, { "name": "symfony/validator", - "version": "v7.1.0", + "version": "v7.1.1", "source": { "type": "git", "url": "https://github.com/symfony/validator.git", - "reference": "ffcc8c56502f6adaeaf6307aef5b98b53a8d0326" + "reference": "fcab7598968b21c361becc930fcae8846638c4c0" }, "dist": { "type": "zip", - "url": "https://api.github.com/repos/symfony/validator/zipball/ffcc8c56502f6adaeaf6307aef5b98b53a8d0326", - "reference": "ffcc8c56502f6adaeaf6307aef5b98b53a8d0326", + "url": "https://api.github.com/repos/symfony/validator/zipball/fcab7598968b21c361becc930fcae8846638c4c0", + "reference": "fcab7598968b21c361becc930fcae8846638c4c0", "shasum": "" }, "require": { @@ -13499,7 +13542,8 @@ "Symfony\\Component\\Validator\\": "" }, "exclude-from-classmap": [ - "/Tests/" + "/Tests/", + "/Resources/bin/" ] }, "notification-url": "https://packagist.org/downloads/", @@ -13519,7 +13563,7 @@ "description": "Provides tools to validate values", "homepage": "https://symfony.com", "support": { - "source": "https://github.com/symfony/validator/tree/v7.1.0" + "source": "https://github.com/symfony/validator/tree/v7.1.1" }, "funding": [ { @@ -13535,7 +13579,7 @@ "type": "tidelift" } ], - "time": "2024-05-21T15:59:31+00:00" + "time": "2024-06-04T05:58:56+00:00" }, { "name": "symfony/var-dumper", @@ -13624,16 +13668,16 @@ }, { "name": "symfony/var-exporter", - "version": "v7.1.0", + "version": "v7.1.1", "source": { "type": "git", "url": "https://github.com/symfony/var-exporter.git", - "reference": "353688d70dcd43e8f7a5cc13b9afba49d4946c39" + "reference": "db82c2b73b88734557cfc30e3270d83fa651b712" }, "dist": { "type": "zip", - "url": "https://api.github.com/repos/symfony/var-exporter/zipball/353688d70dcd43e8f7a5cc13b9afba49d4946c39", - "reference": "353688d70dcd43e8f7a5cc13b9afba49d4946c39", + "url": "https://api.github.com/repos/symfony/var-exporter/zipball/db82c2b73b88734557cfc30e3270d83fa651b712", + "reference": "db82c2b73b88734557cfc30e3270d83fa651b712", "shasum": "" }, "require": { @@ -13680,7 +13724,7 @@ "serialize" ], "support": { - "source": "https://github.com/symfony/var-exporter/tree/v7.1.0" + "source": "https://github.com/symfony/var-exporter/tree/v7.1.1" }, "funding": [ { @@ -13696,20 +13740,20 @@ "type": "tidelift" } ], - "time": "2024-05-22T10:14:54+00:00" + "time": "2024-05-31T14:57:53+00:00" }, { "name": "symfony/yaml", - "version": "v7.1.0", + "version": "v7.1.1", "source": { "type": "git", "url": "https://github.com/symfony/yaml.git", - "reference": "c5f718c94e3c37dd77b77484e6cf0b524b2d405e" + "reference": "fa34c77015aa6720469db7003567b9f772492bf2" }, "dist": { "type": "zip", - "url": "https://api.github.com/repos/symfony/yaml/zipball/c5f718c94e3c37dd77b77484e6cf0b524b2d405e", - "reference": "c5f718c94e3c37dd77b77484e6cf0b524b2d405e", + "url": "https://api.github.com/repos/symfony/yaml/zipball/fa34c77015aa6720469db7003567b9f772492bf2", + "reference": "fa34c77015aa6720469db7003567b9f772492bf2", "shasum": "" }, "require": { @@ -13751,7 +13795,7 @@ "description": "Loads and dumps YAML files", "homepage": "https://symfony.com", "support": { - "source": "https://github.com/symfony/yaml/tree/v7.1.0" + "source": "https://github.com/symfony/yaml/tree/v7.1.1" }, "funding": [ { @@ -13767,7 +13811,7 @@ "type": "tidelift" } ], - "time": "2024-04-28T18:29:00+00:00" + "time": "2024-05-31T14:57:53+00:00" }, { "name": "tijsverkoyen/css-to-inline-styles", @@ -17571,6 +17615,7 @@ "stability-flags": { "cubedesigners/userdatabase": 20, "cubist/azuretts": 20, + "cubist/azuretranslate": 20, "cubist/cms-back": 20, "cubist/excel": 20, "cubist/matomo": 20, diff --git a/resources/views/fields/webflow/texts.blade.php b/resources/views/fields/webflow/texts.blade.php index 8e7c46a68..9dbf340cc 100644 --- a/resources/views/fields/webflow/texts.blade.php +++ b/resources/views/fields/webflow/texts.blade.php @@ -16,9 +16,8 @@ @foreach($texts as $text=>$details) - + @if (isset($field['hint']))

{{__(':nb occurences',['nb'=>$details['occurences']])}}