Préparation traduction rédigée

This commit is contained in:
Fred Tempez 2020-11-24 19:00:23 +01:00
parent 07b7c5350f
commit 19039a8eb2
6 changed files with 125 additions and 69 deletions

View File

@ -228,7 +228,7 @@ class common {
} }
// Traduction du site avec le script Google // Traduction du site avec le script Google
if ( $this->getData(['config','translate','activated'])) { if ( $this->getData(['config','translate','scriptGoogle'])) {
// Lire la langue stockée dans le cookie (choix manuel) // Lire la langue stockée dans le cookie (choix manuel)
if ( isset($_COOKIE['ZWII_USER_I18N']) ) { if ( isset($_COOKIE['ZWII_USER_I18N']) ) {
$lan_cookie = $_COOKIE['ZWII_USER_I18N']; $lan_cookie = $_COOKIE['ZWII_USER_I18N'];
@ -1567,7 +1567,7 @@ class common {
$this->setData(['locale','searchPageId',$this->getData(['config','searchPageId'])]); $this->setData(['locale','searchPageId',$this->getData(['config','searchPageId'])]);
$this->setData(['locale','metaDescription',$this->getData(['config','metaDescription'])]); $this->setData(['locale','metaDescription',$this->getData(['config','metaDescription'])]);
$this->setData(['locale','title',$this->getData(['config','title'])]); $this->setData(['locale','title',$this->getData(['config','title'])]);
$this->setData(['config','translate','activated',false]); $this->setData(['config','translate','scriptGoogle',false]);
$this->setData(['config','translate','showCredits',false]); $this->setData(['config','translate','showCredits',false]);
$this->setData(['config','translate','autoDetect',false]); $this->setData(['config','translate','autoDetect',false]);
$this->setData(['core', 'dataVersion', 10400]); $this->setData(['core', 'dataVersion', 10400]);
@ -2157,7 +2157,7 @@ class core extends common {
// Chargement de la librairie ggogtrans // Chargement de la librairie ggogtrans
// Le multi langue est actif // Le multi langue est actif
if ($this->getData(['config','translate','activated']) === true ) { if ($this->getData(['config','translate','scriptGoogle']) === true ) {
// la traduction auto est active // la traduction auto est active
if ( $this->getData(['config','translate','autoDetect']) === true if ( $this->getData(['config','translate','autoDetect']) === true
// Cas des pages d'administration // Cas des pages d'administration
@ -2312,7 +2312,7 @@ class layout extends common {
*/ */
if ( ( if ( (
( $this->getData(['config','translate','activated']) === true ( $this->getData(['config','translate','scriptGoogle']) === true
AND substr($_SERVER['HTTP_ACCEPT_LANGUAGE'], 0, 2) !== 'fr' AND substr($_SERVER['HTTP_ACCEPT_LANGUAGE'], 0, 2) !== 'fr'
) )
OR ( isset($_COOKIES['ZWII_USER_I18N']) OR ( isset($_COOKIES['ZWII_USER_I18N'])
@ -3010,10 +3010,10 @@ class layout extends common {
* Affiche le cadre avec les drapeaux * Affiche le cadre avec les drapeaux
*/ */
public function showi18n() { public function showi18n() {
if ( $this->getData(['config','translate','activated']) === true ) { if ( $this->getData(['config','translate','scriptGoogle']) === true ) {
echo '<div id="i18nContainer"><ul>'; echo '<div id="i18nContainer"><ul>';
foreach (self::$i18nList as $key => $value) { foreach (self::$i18nList as $key => $value) {
if ($this->getData(['config','translate','flag' . strtoupper($key)]) ) { if ($this->getData(['config','translate','script' . strtoupper($key)]) ) {
echo '<li>'; echo '<li>';
echo '<a href="' . helper::baseUrl() . 'translate/language/' . $key . '/' . $this->getUrl(0) . '"><img class= "flag" src="' . helper::baseUrl(false) . 'core/vendor/i18n/png/' . $key . '.png" /></a>'; echo '<a href="' . helper::baseUrl() . 'translate/language/' . $key . '/' . $this->getUrl(0) . '"><img class= "flag" src="' . helper::baseUrl(false) . 'core/vendor/i18n/png/' . $key . '.png" /></a>';
echo '</li>'; echo '</li>';

View File

@ -43,7 +43,7 @@ class init extends common {
'captcha' => true 'captcha' => true
], ],
'translate' => [ 'translate' => [
'activated' => false, 'scriptGoogle' => false,
'showCredits' => false, 'showCredits' => false,
'autoDetect' => false, 'autoDetect' => false,
'admin' => false, 'admin' => false,

View File

@ -27,17 +27,25 @@ class translate extends common {
// Soumission du formulaire // Soumission du formulaire
if($this->isPost()) { if($this->isPost()) {
$this->setData(['config','translate', [ $this->setData(['config','translate', [
'activated' => $this->getInput('translateActivated', helper::FILTER_BOOLEAN), 'scriptGoogle' => $this->getInput('translateScriptGoogle', helper::FILTER_BOOLEAN),
'showCredits' => $this->getInput('translateCredits', helper::FILTER_BOOLEAN) ? $this->getInput('translateCredits', helper::FILTER_BOOLEAN) : false, 'showCredits' => $this->getInput('translateCredits', helper::FILTER_BOOLEAN) ? $this->getInput('translateCredits', helper::FILTER_BOOLEAN) : false,
'autoDetect' => $this->getInput('translateAutoDetect', helper::FILTER_BOOLEAN), 'autoDetect' => $this->getInput('translateAutoDetect', helper::FILTER_BOOLEAN),
'admin' => $this->getInput('translateAdmin', helper::FILTER_BOOLEAN), 'admin' => $this->getInput('translateAdmin', helper::FILTER_BOOLEAN),
'flagFR' => $this->getInput('translateFlagFR', helper::FILTER_BOOLEAN), 'scriptFR' => $this->getInput('translateFlagScriptFR', helper::FILTER_BOOLEAN),
'flagDE' => $this->getInput('translateFlagDE', helper::FILTER_BOOLEAN), 'scriptDE' => $this->getInput('translateFlagScriptDE', helper::FILTER_BOOLEAN),
'flagEN' => $this->getInput('translateFlagEN', helper::FILTER_BOOLEAN), 'scriptEN' => $this->getInput('translateFlagScriptEN', helper::FILTER_BOOLEAN),
'flagES' => $this->getInput('translateFlagES', helper::FILTER_BOOLEAN), 'scriptES' => $this->getInput('translateFlagScriptES', helper::FILTER_BOOLEAN),
'flagIT' => $this->getInput('translateFlagIT', helper::FILTER_BOOLEAN), 'scriptIT' => $this->getInput('translateFlagScriptIT', helper::FILTER_BOOLEAN),
'flagNL' => $this->getInput('translateFlagNL', helper::FILTER_BOOLEAN), 'scriptNL' => $this->getInput('translateFlagScriptNL', helper::FILTER_BOOLEAN),
'flagPT' => $this->getInput('translateFlagPT', helper::FILTER_BOOLEAN) 'scriptPT' => $this->getInput('translateFlagScriptPT', helper::FILTER_BOOLEAN),
'site' => $this->getInput('translateSite', helper::FILTER_BOOLEAN),
'siteFR' => $this->getInput('translateFlagSiteFR', helper::FILTER_BOOLEAN),
'siteDE' => $this->getInput('translateFlagSiteDE', helper::FILTER_BOOLEAN),
'siteEN' => $this->getInput('translateFlagSiteEN', helper::FILTER_BOOLEAN),
'siteES' => $this->getInput('translateFlagSiteES', helper::FILTER_BOOLEAN),
'siteIT' => $this->getInput('translateFlagSiteIT', helper::FILTER_BOOLEAN),
'siteNL' => $this->getInput('translateFlagSiteNL', helper::FILTER_BOOLEAN),
'sitePT' => $this->getInput('translateFlagSitePT', helper::FILTER_BOOLEAN)
]]); ]]);
// Valeurs en sortie // Valeurs en sortie
$this->addOutput([ $this->addOutput([

View File

@ -15,77 +15,125 @@
<div class="row"> <div class="row">
<div class="col12"> <div class="col12">
<div class="block"> <div class="block">
<h4>Paramètres</h4> <h4>Traduction automatique (Google Translate)</h4>
<div class="row"> <div class="row">
<div class="col6"> <div class="col6">
<?php echo template::checkbox('translateActivated', true, 'Activer le mode multi-langues', [ <?php echo template::checkbox('translateScriptGoogle', true, 'Active le script de traduction automatique', [
'checked' => $this->getData(['config','translate', 'activated']) 'checked' => $this->getData(['config','translate', 'scriptGoogle'])
]); ?> ]); ?>
</div> </div>
</div> </div>
<div class="row">
<div class="col3">
<?php echo template::checkbox('translateAutoDetect', true, 'Détection automatique', [
'checked' => $this->getData(['config','translate', 'autoDetect']),
'help' => 'Détecte la langue du navigateur.'
]); ?>
</div>
<div class="col3">
<?php echo template::checkbox('translateFlagScriptFR', true, 'Français', [
'checked' => $this->getData(['config','translate', 'scriptFR'])
]); ?>
</div>
<div class="col3">
<?php echo template::checkbox('translateFlagScriptDE', true, 'Allemand', [
'checked' => $this->getData(['config','translate', 'scriptDE'])
]); ?>
</div>
<div class="col3">
<?php echo template::checkbox('translateFlagScriptEN', true, 'Anglais', [
'checked' => $this->getData(['config','translate', 'scriptEN'])
]); ?>
</div>
</div>
<div class="row">
<div class="col3">
<?php echo template::checkbox('translateFlagScriptES', true, 'Espagnol', [
'checked' => $this->getData(['config','translate', 'scriptES'])
]); ?>
</div>
<div class="col3">
<?php echo template::checkbox('translateFlagScriptIT', true, 'Italien', [
'checked' => $this->getData(['config','translate', 'scriptIT'])
]); ?>
</div>
<div class="col3">
<?php echo template::checkbox('translateFlagScriptNL', true, 'Néerlandais', [
'checked' => $this->getData(['config','translate', 'scriptNL'])
]); ?>
</div>
<div class="col3">
<?php echo template::checkbox('translateFlagScriptPT', true, 'Portugais', [
'checked' => $this->getData(['config','translate', 'scriptPT'])
]); ?>
</div>
</div>
<div class="row">
<div class="col6">
<?php echo template::checkbox('translateAdmin', true, 'Mode connexion', [
'checked' => $this->getData(['config','translate', 'admin']),
'help' => 'Traduction automatique du site et de l\'interface du CMS'
]); ?>
</div>
<div class="col6">
<?php echo template::checkbox('translateCredits', true, 'Afficher les crédits du script Google', [
'checked' => $this->getData(['config','translate', 'showCredits']),
'help' => 'Option vivement recommandée pour le respect du droit d\'auteur'
]); ?>
</div>
</div>
</div> </div>
</div> </div>
</div> </div>
<div class="row"> <div class="row">
<div class="col12"> <div class="col12">
<div class="block"> <div class="block">
<h4>Traduction automatique</h4> <h4>Traduction rédigée</h4>
<div class="row"> <div class="row">
<div class="col4"> <div class="col6">
<?php echo template::checkbox('translateAutoDetect', true, 'Détection automatique de langue', [ <?php echo template::checkbox('translateSite', true, 'Active la traduction manuelle', [
'checked' => $this->getData(['config','translate', 'autoDetect']), 'checked' => $this->getData(['config','translate', 'site'])
'help' => 'Détecte la langue du navigateur et effectue une traduction grâce à Google Translate.'
]); ?>
</div>
<div class="col4">
<?php echo template::checkbox('translateAdmin', true, 'Mode connexion', [
'checked' => $this->getData(['config','translate', 'admin']),
'help' => 'Traduction automatique du site et de l\'interface du CMS'
]); ?> ]); ?>
</div> </div>
</div>
<b>Sélectionnez les langues à activer :</b>
<div class="row">
<div class="col3">
<?php echo template::checkbox('translateFlagSiteFR', true, 'Français', [
'checked' => true,
'disabled' => true
]); ?>
</div>
<div class="col3">
<?php echo template::checkbox('translateFlagSiteDE', true, 'Allemand', [
'checked' => $this->getData(['config', 'translate', 'siteDE'])
]); ?>
</div>
<div class="col3">
<?php echo template::checkbox('translateFlagSiteEN', true, 'Anglais', [
'checked' => $this->getData(['config', 'translate', 'siteEN'])
]); ?>
</div>
<div class="col3">
<?php echo template::checkbox('translateFlagSiteES', true, 'Espagnol', [
'checked' => $this->getData(['config', 'translate', 'siteES'])
]); ?>
</div>
</div>
<div class="row">
<div class="col4"> <div class="col4">
<?php echo template::checkbox('translateCredits', true, 'Afficher les crédits du script Google', [ <?php echo template::checkbox('translateFlagSiteIT', true, 'Italien', [
'checked' => $this->getData(['config','translate', 'showCredits']), 'checked' => $this->getData(['config', 'translate', 'siteIT'])
'help' => 'Option vivement recommandée pour le respect du droit d\'auteur'
]); ?> ]); ?>
</div> </div>
</div> <div class="col4">
<div class="row"> <?php echo template::checkbox('translateFlagSiteNL', true, 'Néerlandais', [
<div class="col3"> 'checked' => $this->getData(['config', 'translate', 'siteNL'])
<?php echo template::checkbox('translateFlagFR', true, 'Français', [
'checked' => $this->getData(['config','translate', 'flagFR'])
]); ?> ]); ?>
</div> </div>
<div class="col3"> <div class="col4">
<?php echo template::checkbox('translateFlagDE', true, 'Allemand', [ <?php echo template::checkbox('translateFlagSitePT', true, 'Portugais', [
'checked' => $this->getData(['config','translate', 'flagDE']) 'checked' => $this->getData(['config', 'translate', 'sitePT'])
]); ?>
</div>
<div class="col3">
<?php echo template::checkbox('translateFlagEN', true, 'Anglais', [
'checked' => $this->getData(['config','translate', 'flagEN'])
]); ?>
</div>
<div class="col3">
<?php echo template::checkbox('translateFlagES', true, 'Espagnol', [
'checked' => $this->getData(['config','translate', 'flagES'])
]); ?>
</div>
</div>
<div class="row">
<div class="col3">
<?php echo template::checkbox('translateFlagIT', true, 'Italien', [
'checked' => $this->getData(['config','translate', 'flagIT'])
]); ?>
</div>
<div class="col3">
<?php echo template::checkbox('translateFlagNL', true, 'Néerlandais', [
'checked' => $this->getData(['config','translate', 'flagNL'])
]); ?>
</div>
<div class="col3">
<?php echo template::checkbox('translateFlagPT', true, 'Portugais', [
'checked' => $this->getData(['config','translate', 'flagPT'])
]); ?> ]); ?>
</div> </div>
</div> </div>

View File

@ -46,7 +46,7 @@
c._cest = gtConstEvalStartTime; c._cest = gtConstEvalStartTime;
gtConstEvalStartTime = undefined; gtConstEvalStartTime = undefined;
c._cl = 'fr'; c._cl = 'fr';
c._cuc = 'googleTranslateElementInit'; c._cuc = 'scriptGoogleElementInit';
c._cac = ''; c._cac = '';
c._cam = ''; c._cam = '';
c._ctkk = '433074.3898829376'; c._ctkk = '433074.3898829376';

View File

@ -1,4 +1,4 @@
function googleTranslateElementInit() { function scriptGoogleElementInit() {
new google.translate.TranslateElement({ new google.translate.TranslateElement({
pageLanguage: 'fr' pageLanguage: 'fr'
}, 'google_translate_element'); }, 'google_translate_element');