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;
$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);
$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;
}
$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) {
"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",
"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",
},
{
"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": {
"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": [
"type": "tidelift"
}
],
- "time": "2024-01-25T10:35:09+00:00"
+ "time": "2024-06-03T19:18:41+00:00"
},
{
"name": "nette/schema",
},
{
"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": {
],
"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": [
{
"type": "other"
}
],
- "time": "2024-05-02T13:09:01+00:00"
+ "time": "2024-06-04T11:31:33+00:00"
},
{
"name": "spatie/laravel-googletagmanager",
},
{
"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": {
"psr6"
],
"support": {
- "source": "https://github.com/symfony/cache/tree/v7.1.0"
+ "source": "https://github.com/symfony/cache/tree/v7.1.1"
},
"funding": [
{
"type": "tidelift"
}
],
- "time": "2024-05-28T08:39:33+00:00"
+ "time": "2024-05-31T14:57:53+00:00"
},
{
"name": "symfony/cache-contracts",
},
{
"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": {
"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": [
{
"type": "tidelift"
}
],
- "time": "2024-04-18T09:32:20+00:00"
+ "time": "2024-05-31T14:57:53+00:00"
},
{
"name": "symfony/deprecation-contracts",
},
{
"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": {
"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": [
{
"type": "tidelift"
}
],
- "time": "2024-04-18T09:32:20+00:00"
+ "time": "2024-05-31T14:57:53+00:00"
},
{
"name": "symfony/event-dispatcher-contracts",
},
{
"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": {
"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": [
{
"type": "tidelift"
}
],
- "time": "2024-05-17T10:55:18+00:00"
+ "time": "2024-05-31T14:57:53+00:00"
},
{
"name": "symfony/finder",
},
{
"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": {
"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": [
{
"type": "tidelift"
}
],
- "time": "2024-04-18T09:32:20+00:00"
+ "time": "2024-05-31T14:57:53+00:00"
},
{
"name": "symfony/polyfill-ctype",
},
{
"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": {
"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": [
{
"type": "tidelift"
}
],
- "time": "2024-05-21T15:59:31+00:00"
+ "time": "2024-05-31T14:57:53+00:00"
},
{
"name": "symfony/service-contracts",
},
{
"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": {
"utf8"
],
"support": {
- "source": "https://github.com/symfony/string/tree/v7.1.0"
+ "source": "https://github.com/symfony/string/tree/v7.1.1"
},
"funding": [
{
"type": "tidelift"
}
],
- "time": "2024-05-17T10:55:18+00:00"
+ "time": "2024-06-04T06:40:14+00:00"
},
{
"name": "symfony/translation",
},
{
"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": {
"Symfony\\Component\\Validator\\": ""
},
"exclude-from-classmap": [
- "/Tests/"
+ "/Tests/",
+ "/Resources/bin/"
]
},
"notification-url": "https://packagist.org/downloads/",
"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": [
{
"type": "tidelift"
}
],
- "time": "2024-05-21T15:59:31+00:00"
+ "time": "2024-06-04T05:58:56+00:00"
},
{
"name": "symfony/var-dumper",
},
{
"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": {
"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": [
{
"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": {
"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": [
{
"type": "tidelift"
}
],
- "time": "2024-04-28T18:29:00+00:00"
+ "time": "2024-05-31T14:57:53+00:00"
},
{
"name": "tijsverkoyen/css-to-inline-styles",
"stability-flags": {
"cubedesigners/userdatabase": 20,
"cubist/azuretts": 20,
+ "cubist/azuretranslate": 20,
"cubist/cms-back": 20,
"cubist/excel": 20,
"cubist/matomo": 20,