From c405994451dfec1cd3903ab81100647bb0b5e174 Mon Sep 17 00:00:00 2001 From: Fred Tempez Date: Thu, 13 Apr 2023 15:45:02 +0200 Subject: [PATCH] =?UTF-8?q?Installation=20d'un=20site=20=C3=A0=20tester=20?= =?UTF-8?q?en=20espagnol?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- core/core.php | 12 +--- core/module/install/ressource/defaultdata.php | 55 ++++++++++++++++++- core/module/translate/translate.php | 22 +++++++- 3 files changed, 74 insertions(+), 15 deletions(-) diff --git a/core/core.php b/core/core.php index 186be521..40923489 100644 --- a/core/core.php +++ b/core/core.php @@ -598,16 +598,6 @@ class common public function initData($module, $lang, $sampleSite = false) { - // Créer la base de données des langues - /* - if ($module === 'language') { - copy('core/module/install/ressource/i18n/language.json', self::DATA_DIR . 'language.json'); - $this->copyDir('core/module/install/ressource/i18n', self::I18N_DIR); - unlink(self::I18N_DIR . 'language.json'); - return; - } - */ - // Tableau avec les données vierges require_once('core/module/install/ressource/defaultdata.php'); @@ -647,7 +637,7 @@ class common } else { // En_EN si le contenu localisé n'est pas traduit if (!isset(init::$defaultDataI18n[$lang])) { - $lang = 'en_EN'; + $lang = 'default'; } // Messages localisés $this->setData(['locale', init::$defaultDataI18n[$lang]['locale']]); diff --git a/core/module/install/ressource/defaultdata.php b/core/module/install/ressource/defaultdata.php index 7f2836f8..b77792c9 100644 --- a/core/module/install/ressource/defaultdata.php +++ b/core/module/install/ressource/defaultdata.php @@ -478,7 +478,60 @@ class init extends common ] ]; public static $defaultDataI18n = [ - 'en_EN' => [ + 'es' => [ + 'locale' => [ + 'homePageId' => 'home', + 'page302' => 'none', + 'page403' => 'none', + 'page404' => 'none', + 'legalPageId' => 'none', + 'searchPageId' => 'none', + 'searchPageLabel' => 'none', + 'sitemapPageLabel' => 'none', + 'legalPageLabel' => 'legales', + "metaDescription" => "Zwii es un CMS sin base de datos que facilita la creación y gestión de un sitio web sin necesidad de conocimientos de programación.", + "title" => "¡Tu sitio en unos clics!", + "cookies" => [ + "mainLabel" => "Este sitio web utiliza cookies necesarias para su funcionamiento. Estas cookies permiten optimizar su funcionamiento, por ejemplo, memorizando los datos de conexión, el idioma que has elegido o la validación de este mensaje.", + "titleLabel" => "Cookies esenciales", + "linkLegalLabel" => "Consultar el aviso legal", + "cookiesFooterText" => "Cookies", + "buttonValidLabel" => "Aceptar" + ] + ], + 'page' => [ + 'home' => [ + 'typeMenu' => 'text', + 'iconUrl' => '', + 'disable' => false, + 'content' => 'home.html', + 'hideTitle' => false, + 'homePageId' => true, + 'breadCrumb' => false, + 'metaDescription' => '', + 'metaTitle' => '', + 'moduleId' => '', + 'modulePosition' => 'bottom', + 'parentPageId' => '', + 'position' => 1, + 'group' => self::GROUP_VISITOR, + 'targetBlank' => false, + 'title' => 'Home page', + 'shortTitle' => 'Home', + 'block' => '12', + 'barLeft' => '', + 'barRight' => '', + 'displayMenu' => 'none', + 'hideMenuSide' => false, + 'hideMenuChildren' => false, + 'extraPosition' => false, + 'css' => '', + 'js' => '' + ] + ], + 'html' => '¡Bienvenido a ZwiiCMS, felicidades, esta es su primera página!' + ], + 'default' => [ 'locale' => [ 'homePageId' => 'home', 'page302' => 'none', diff --git a/core/module/translate/translate.php b/core/module/translate/translate.php index 6fb59d46..cc76b770 100644 --- a/core/module/translate/translate.php +++ b/core/module/translate/translate.php @@ -180,9 +180,8 @@ class translate extends common file_exists(self::DATA_DIR . $key . '/page.json') && file_exists(self::DATA_DIR . $key . '/module.json') && file_exists(self::DATA_DIR . $key . '/locale.json') - ) - { - + ) { + if (self::$i18nUI === $key) { $messageLocale = helper::translate('Langue par défaut'); } elseif (isset($_SESSION['ZWII_CONTENT']) && $_SESSION['ZWII_CONTENT'] === $key) { @@ -308,11 +307,28 @@ class translate extends common // Création du contenu $lang = $this->getInput('translateAddContent'); + require_once('core/module/install/ressource/defaultdata.php'); // Stockage dans un sous-dossier localisé if (!file_exists(self::DATA_DIR . $lang)) { mkdir(self::DATA_DIR . $lang, 0755); + mkdir(self::DATA_DIR . $lang . '/content', 0755); } + + // En_EN si le contenu localisé n'est pas traduit + if (!isset(init::$defaultDataI18n[$lang])) { + $langSource = 'default'; + } + + file_put_contents(self::DATA_DIR . $lang . '/locale.json', json_encode(['locale' => init::$defaultDataI18n[$langSource]['locale']])); + file_put_contents(self::DATA_DIR . $lang . '/page.json', json_encode(['page' => init::$defaultDataI18n[$langSource]['page']])); + file_put_contents(self::DATA_DIR . $lang . '/module.json', json_encode(['module' => []])); + + // Créer la page d'accueil + $pageId = init::$defaultDataI18n[$langSource]['locale']['homePageId']; + $content = init::$defaultDataI18n[$langSource]['html']; + file_put_contents(self::DATA_DIR . $lang . '/content/' . init::$defaultDataI18n[$langSource]['page'][$pageId]['content'], $content); + // Valeurs en sortie $this->addOutput([ 'redirect' => helper::baseUrl() . 'translate',