From c44a6c42df0b5da783b6b5298808df8ac9636d70 Mon Sep 17 00:00:00 2001 From: Fred Tempez Date: Wed, 21 Sep 2022 16:02:06 +0200 Subject: [PATCH] =?UTF-8?q?Choix=20de=20la=20langue=20=C3=A0=20l'installat?= =?UTF-8?q?ion?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- core/core.php | 92 ++++++++++++++----- core/module/install/install.php | 44 +-------- core/module/install/view/index/update.css | 18 ++++ .../install/view/postinstall/update.css | 18 ++++ core/module/plugin/plugin.php | 2 +- core/module/translate/translate.php | 48 +--------- core/module/translate/view/index/index.php | 2 +- site/i18n/es.json | 3 + site/i18n/fr_FR.json | 3 + 9 files changed, 120 insertions(+), 110 deletions(-) create mode 100644 core/module/install/view/index/update.css create mode 100644 core/module/install/view/postinstall/update.css diff --git a/core/core.php b/core/core.php index 8f5c7465..f6063c34 100644 --- a/core/core.php +++ b/core/core.php @@ -147,8 +147,54 @@ class common { self::GROUP_MODERATOR => 'Éditeur', self::GROUP_ADMIN => 'Administrateur' ]; - // Langues proposées - public static $i18nList = [ + + //Langues de l'UI + // Langue de l'interface, tableau des dialogues + public static $dialog; + // Langue de l'interface sélectionnée + public static $i18nUI = 'fr_FR'; + public static $languagesUI = [ + 'az_AZ' => 'Azərbaycan dili', + 'bg_BG' => 'български език', + 'ca' => 'Català, valencià', + 'cs' => 'čeština, český jazyk', + 'da' => 'Dansk', + 'de' => 'Deutsch', + 'el_GR' => 'ελληνικά', + 'en_EN' => 'English', + 'es' => 'Español', + 'fa' => 'فارسی', + 'fr_FR' => 'Français', + 'he_IL' => 'Hebrew (Israel)', + 'hr' => 'Hrvatski jezik', + 'hu_HU' => 'Magyar', + 'id' => 'Bahasa Indonesia', + 'it' => 'Italiano', + 'ja' => '日本', + 'lt' => 'Lietuvių kalba', + 'mn_MN' => 'монгол', + 'nb_NO' => 'Norsk bokmål', + 'nn_NO' => 'Norsk nynorsk', + 'nl' => 'Nederlands, Vlaams', + 'pl' => 'Język polski, polszczyzna', + 'pt_BR' => 'Português(Brazil)', + 'pt_PT' => 'Português', + 'ro' => 'Română', + 'ru' => 'Pусский язык', + 'sk' => 'Slovenčina', + 'sl' => 'Slovenski jezik', + 'sv_SE' => 'Svenska', + 'th_TH' => 'ไทย', + 'tr_TR' => 'Türkçe', + 'uk_UA' => 'Yкраїнська мова', + 'vi' => 'Tiếng Việt', + 'zh_CN' => '中文 (Zhōngwén), 汉语, 漢語', + + // source: http://en.wikipedia.org/wiki/List_of_ISO_639-1_codes + ]; + + // Langues de contenu + public static $languagesContent = [ 'fr' => 'Français (fr)', 'de' => 'Allemand (de)', 'en' => 'Anglais (en)', @@ -160,11 +206,6 @@ class common { // Sélection de langue de l'interface public static $i18nContent = 'fr'; - // Langue de l'interface, tableau des dialogues - public static $dialog; - // Langue de l'interface sélectionnée - public static $i18n = 'fr_FR'; - // Zone de temps public static $timezone; private $url = ''; @@ -256,6 +297,8 @@ class common { ] ]; + + /** * Constructeur commun @@ -270,16 +313,6 @@ class common { $this->input['_COOKIE'] = $_COOKIE; } - // Déterminer la langue du contenu du site - if (isset($this->input['_COOKIE']['ZWII_I18N_SITE']) - ) { - self::$i18nContent = $this->input['_COOKIE']['ZWII_I18N_SITE']; - setlocale (LC_TIME, self::$i18nContent . '_' . strtoupper (self::$i18nContent) ); - - } else { - self::$i18nContent = 'fr'; - } - // Instanciation de la classe des entrées / sorties // Récupère les descripteurs foreach ($this->dataFiles as $keys => $value) { @@ -306,15 +339,28 @@ class common { } // Langue de l'administration - self::$i18n = $this->getData(['config', 'i18n', 'interface']); + self::$i18nUI = $this->getData(['config', 'i18n', 'interface']); // La langue par défaut du contenu est celle du site si le cookie est absent. - self::$i18n = (empty(self::$i18n) || is_null(self::$i18n)) ? self::$i18n = 'fr' : self::$i18n ; + self::$i18nUI = (empty(self::$i18nUI) || is_null(self::$i18nUI)) ? self::$i18nUI = 'fr_FR' : self::$i18nUI ; + // Le fichier existe-t-il ? - if (!file_exists(self::I18N_DIR . self::$i18n . '.json')) { - self::$i18n = 'fr_FR'; + if (!file_exists(self::I18N_DIR . self::$i18nUI . '.json')) { + self::$i18nUI = 'fr_FR'; } + // Déterminer la langue du contenu du site + if (isset($this->input['_COOKIE']['ZWII_I18N_SITE']) + ) { + self::$i18nContent = $this->input['_COOKIE']['ZWII_I18N_SITE']; + setlocale (LC_TIME, self::$i18nContent . '_' . strtoupper (self::$i18nContent) ); + + } else { + self::$i18nContent = substr(self::$i18nUI, 0, 2); + } + + + // Utilisateur connecté if($this->user === []) { $this->user = $this->getData(['user', $this->getInput('ZWII_USER_ID')]); @@ -386,7 +432,7 @@ class common { } // Chargement des dialogues - self::$dialog = json_decode(file_get_contents(self::I18N_DIR . self::$i18n . '.json'), true); + self::$dialog = json_decode(file_get_contents(self::I18N_DIR . self::$i18nUI . '.json'), true); // Mise à jour des données core if( $this->getData(['core', 'dataVersion']) !== intval(str_replace('.','',self::ZWII_VERSION))) include( 'core/include/update.inc.php'); @@ -2160,7 +2206,7 @@ class common { * Affiche le cadre avec les drapeaux sélectionnés */ public function showi18n() { - foreach (self::$i18nList as $key => $value) { + foreach (self::$languagesContent as $key => $value) { if ($this->getData(['config', 'i18n', $key]) === 'site' ) { if ( diff --git a/core/module/install/install.php b/core/module/install/install.php index 89e4babe..ab18d9bd 100644 --- a/core/module/install/install.php +++ b/core/module/install/install.php @@ -34,47 +34,9 @@ class install extends common { public static $newVersion; - // Fichiers des langues de l'interface - public static $i18nFiles = []; - public static $languagesUI = [ - 'az_AZ' => 'Azərbaycan dili', - 'bg_BG' => 'български език', - 'ca' => 'Català, valencià', - 'cs' => 'čeština, český jazyk', - 'da' => 'Dansk', - 'de' => 'Deutsch', - 'el_GR' => 'ελληνικά', - 'en_EN' => 'English', - 'es' => 'Español', - 'fa' => 'فارسی', - 'fr_FR' => 'Français', - 'he_IL' => 'Hebrew (Israel)', - 'hr' => 'Hrvatski jezik', - 'hu_HU' => 'Magyar', - 'id' => 'Bahasa Indonesia', - 'it' => 'Italiano', - 'ja' => '日本', - 'lt' => 'Lietuvių kalba', - 'mn_MN' => 'монгол', - 'nb_NO' => 'Norsk bokmål', - 'nn_NO' => 'Norsk nynorsk', - 'nl' => 'Nederlands, Vlaams', - 'pl' => 'Język polski, polszczyzna', - 'pt_BR' => 'Português(Brazil)', - 'pt_PT' => 'Português', - 'ro' => 'Română', - 'ru' => 'Pусский язык', - 'sk' => 'Slovenčina', - 'sl' => 'Slovenski jezik', - 'sv_SE' => 'Svenska', - 'th_TH' => 'ไทย', - 'tr_TR' => 'Türkçe', - 'uk_UA' => 'Yкраїнська мова', - 'vi' => 'Tiếng Việt', - 'zh_CN' => '中文 (Zhōngwén), 汉语, 漢語', - - // source: http://en.wikipedia.org/wiki/List_of_ISO_639-1_codes - ]; + // Fichiers des langues de l'interface + public static $i18nFiles = []; + /** * Pré-installation - choix de la langue diff --git a/core/module/install/view/index/update.css b/core/module/install/view/index/update.css new file mode 100644 index 00000000..52709ea6 --- /dev/null +++ b/core/module/install/view/index/update.css @@ -0,0 +1,18 @@ +/** + * This file is part of Zwii. + * + * For full copyright and license information, please see the LICENSE + * file that was distributed with this source code. + * + * @author Rémi Jean + * @copyright Copyright (C) 2008-2018, Rémi Jean + * @author Frédéric Tempez + * @copyright Copyright (C) 2018-2022, Frédéric Tempez + * @license GNU General Public License, version 3 + * @link http://zwiicms.fr/ + */ + + +/** NE PAS EFFACER +* admin.css +*/ \ No newline at end of file diff --git a/core/module/install/view/postinstall/update.css b/core/module/install/view/postinstall/update.css new file mode 100644 index 00000000..52709ea6 --- /dev/null +++ b/core/module/install/view/postinstall/update.css @@ -0,0 +1,18 @@ +/** + * This file is part of Zwii. + * + * For full copyright and license information, please see the LICENSE + * file that was distributed with this source code. + * + * @author Rémi Jean + * @copyright Copyright (C) 2008-2018, Rémi Jean + * @author Frédéric Tempez + * @copyright Copyright (C) 2018-2022, Frédéric Tempez + * @license GNU General Public License, version 3 + * @link http://zwiicms.fr/ + */ + + +/** NE PAS EFFACER +* admin.css +*/ \ No newline at end of file diff --git a/core/module/plugin/plugin.php b/core/module/plugin/plugin.php index 55db954e..9c433413 100644 --- a/core/module/plugin/plugin.php +++ b/core/module/plugin/plugin.php @@ -408,7 +408,7 @@ class plugin extends common { public function index() { // Tableau des langues rédigées - foreach (self::$i18nList as $key => $value) { + foreach (self::$languagesContent as $key => $value) { if ($this->getData(['config','i18n', $key]) === 'site' || $key === 'fr') { $i18nSites[$key] = $value; diff --git a/core/module/translate/translate.php b/core/module/translate/translate.php index f66c4613..86bb1aa8 100644 --- a/core/module/translate/translate.php +++ b/core/module/translate/translate.php @@ -37,46 +37,6 @@ class translate extends common { //UI // Fichiers des langues de l'interface public static $i18nFiles = []; - // Langues de l'interface acceptées - public static $languagesUI = [ - 'az_AZ' => 'Azərbaycan dili', - 'bg_BG' => 'български език', - 'ca' => 'Català, valencià', - 'cs' => 'čeština, český jazyk', - 'da' => 'Dansk', - 'de' => 'Deutsch', - 'el_GR' => 'ελληνικά', - 'en_EN' => 'English', - 'es' => 'Español', - 'fa' => 'فارسی', - 'fr_FR' => 'Français', - 'he_IL' => 'Hebrew (Israel)', - 'hr' => 'Hrvatski jezik', - 'hu_HU' => 'Magyar', - 'id' => 'Bahasa Indonesia', - 'it' => 'Italiano', - 'ja' => '日本', - 'lt' => 'Lietuvių kalba', - 'mn_MN' => 'монгол', - 'nb_NO' => 'Norsk bokmål', - 'nn_NO' => 'Norsk nynorsk', - 'nl' => 'Nederlands, Vlaams', - 'pl' => 'Język polski, polszczyzna', - 'pt_BR' => 'Português(Brazil)', - 'pt_PT' => 'Português', - 'ro' => 'Română', - 'ru' => 'Pусский язык', - 'sk' => 'Slovenčina', - 'sl' => 'Slovenski jezik', - 'sv_SE' => 'Svenska', - 'th_TH' => 'ไทย', - 'tr_TR' => 'Türkçe', - 'uk_UA' => 'Yкраїнська мова', - 'vi' => 'Tiếng Việt', - 'zh_CN' => '中文 (Zhōngwén), 汉语, 漢語', - - // source: http://en.wikipedia.org/wiki/List_of_ISO_639-1_codes - ]; /** * Configuration avancée des langues @@ -105,7 +65,7 @@ class translate extends common { // Enregistrer la langue if ($success) { $this->setData(['config', 'i18n', $toCreate, 'site' ]); - $notification = 'Données ' . self::$i18nList[$copyFrom] . ' copiées vers ' . self::$i18nList[$toCreate]; + $notification = 'Données ' . self::$languagesContent[$copyFrom] . ' copiées vers ' . self::$languagesContent[$toCreate]; } else { $notification = "Quelque chose n\'a pas fonctionné, vérifiez les permissions."; } @@ -122,7 +82,7 @@ class translate extends common { ]); } // Tableau des langues installées - foreach (self::$i18nList as $key => $value) { + foreach (self::$languagesContent as $key => $value) { if ($this->getData(['config','i18n', $key]) === 'site') { self::$languagesTarget[$key] = $value; } @@ -145,7 +105,7 @@ class translate extends common { // Soumission du formulaire if($this->isPost()) { // Edition des langues - foreach (self::$i18nList as $keyi18n => $value) { + foreach (self::$languagesContent as $keyi18n => $value) { if ($keyi18n === 'fr') continue; // Effacement d'une langue installée @@ -257,7 +217,7 @@ class translate extends common { } // Modification des options de suppression de la langue installée. - foreach (self::$i18nList as $key => $value) { + foreach (self::$languagesContent as $key => $value) { if ($this->getData(['config','i18n',$key]) === 'site') { self::$translateOptions [$key] = [ 'none' => 'Drapeau masqué', diff --git a/core/module/translate/view/index/index.php b/core/module/translate/view/index/index.php index 229159b8..97f6b6b4 100644 --- a/core/module/translate/view/index/index.php +++ b/core/module/translate/view/index/index.php @@ -46,7 +46,7 @@

- +

diff --git a/site/i18n/es.json b/site/i18n/es.json index 14b2defd..61c0a952 100644 --- a/site/i18n/es.json +++ b/site/i18n/es.json @@ -329,6 +329,9 @@ "Contenu du site": "", "Traductions installées": "", "Interface": "", + "Langue de l'administration": "", + "Langues installées": "", + "Dans quelle langue utiliserez-vous Zwii ?": "", "Paramétres": "", "Maintenance": "", "Scripts externes": "", diff --git a/site/i18n/fr_FR.json b/site/i18n/fr_FR.json index a3296c84..6ca473de 100644 --- a/site/i18n/fr_FR.json +++ b/site/i18n/fr_FR.json @@ -329,6 +329,9 @@ "Contenu du site": "", "Traductions installées": "", "Interface": "", + "Langue de l'administration": "", + "Langues installées": "", + "Dans quelle langue utiliserez-vous Zwii ?": "", "Paramétres": "", "Maintenance": "", "Scripts externes": "",