From 915997a3ff070bc32388b7ebec20f3afe0774d63 Mon Sep 17 00:00:00 2001 From: fredtempez Date: Mon, 5 Sep 2022 20:17:50 +0200 Subject: [PATCH] =?UTF-8?q?traduction=20g=C3=A9n=C3=A9ration=20du=20templa?= =?UTF-8?q?te.json?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- core/class/helper.class.php | 13 +++++++------ core/class/template.class.php | 10 +++++----- 2 files changed, 12 insertions(+), 11 deletions(-) diff --git a/core/class/helper.class.php b/core/class/helper.class.php index 4f13538b..9db23419 100644 --- a/core/class/helper.class.php +++ b/core/class/helper.class.php @@ -24,15 +24,16 @@ class helper { */ public static function translate($text) { - $r = (array_key_exists($text, core::$dialog)) ? core::$dialog[$text] : $text; + // Captation $data = json_decode(file_get_contents('site/i18n/template.json'), true); - if (!array_key_exists($text, $data) - && !empty($text) - ) { - $data = array_merge($data,[$text => ''] ); - file_put_contents ('site/i18n/template.json', json_encode($data, JSON_UNESCAPED_UNICODE), LOCK_EX); + if (!array_key_exists($text, $data) ) { + if ($text !== '' ) { + $data = array_merge($data,[$text => ''] ); + file_put_contents ('site/i18n/template.json', json_encode($data, JSON_UNESCAPED_UNICODE), LOCK_EX); + } } + $r = (array_key_exists($text, core::$dialog)) ? core::$dialog[$text] : $text; return ($r); } diff --git a/core/class/template.class.php b/core/class/template.class.php index 4aab90be..764668e4 100644 --- a/core/class/template.class.php +++ b/core/class/template.class.php @@ -239,7 +239,7 @@ class template { // Traduction de l'aide et de l'étiquette $attributes['label'] = helper::translate($attributes['label']); $attributes['help'] = helper::translate($attributes['help']); - $attributes['placeholder'] = helper::translate($attributes['placeholder']); + //$attributes['placeholder'] = helper::translate($attributes['placeholder']); // Sauvegarde des données en cas d'erreur if($attributes['before'] AND array_key_exists($attributes['id'], common::$inputBefore)) { $attributes['value'] = common::$inputBefore[$attributes['id']]; @@ -507,7 +507,7 @@ class template { 'help' => '' ], $attributes); // Traduction de l'étiquette si déjà appelée par une fonction de template -; if ( +; if ( get_called_class() !== 'template' ) { $attributes['help'] = helper::translate($attributes['help']); @@ -550,7 +550,7 @@ class template { // Traduction de l'aide et de l'étiquette $attributes['value'] = helper::translate($attributes['value']); $attributes['help'] = helper::translate($attributes['help']); - $attributes['placeholder'] = helper::translate($attributes['placeholder']); + //$attributes['placeholder'] = helper::translate($attributes['placeholder']); // Sauvegarde des données en cas d'erreur if($attributes['before'] AND array_key_exists($attributes['id'], common::$inputBefore)) { $attributes['value'] = common::$inputBefore[$attributes['id']]; @@ -615,7 +615,7 @@ class template { ], $attributes); // Traduction de l'aide et de l'étiquette $attributes['label'] = helper::translate($attributes['label']); - $attributes['placeholder'] = helper::translate($attributes['placeholder']); + //$attributes['placeholder'] = helper::translate($attributes['placeholder']); $attributes['help'] = helper::translate($attributes['help']); // Début du wrapper $html = '
'; @@ -841,7 +841,7 @@ class template { // Traduction de l'aide et de l'étiquette $attributes['label'] = helper::translate($attributes['label']); $attributes['help'] = helper::translate($attributes['help']); - $attributes['placeholder'] = helper::translate($attributes['placeholder']); + //$attributes['placeholder'] = helper::translate($attributes['placeholder']); // Sauvegarde des données en cas d'erreur if($attributes['before'] AND array_key_exists($attributes['id'], common::$inputBefore)) { $attributes['value'] = common::$inputBefore[$attributes['id']];