Traduction auto

This commit is contained in:
Fred Tempez 2020-11-14 15:49:01 +01:00
parent 784d3b9cb8
commit ea8fd8e097
15 changed files with 50 additions and 14 deletions

View File

@ -201,8 +201,6 @@ class common {
// Changer la locale
if ( $lan !== 'fr') {
setlocale (LC_TIME, $lan . '_' . strtoupper ($lan) );
}
if ($lan !== 'fr') {
// Charge la librairie Google Translate
setrawcookie("googtrans", '/fr/'. $lan, time() + 3600, helper::baseUrl());
} else {
@ -2047,8 +2045,10 @@ class core extends common {
}
}
}
// Librairie googtrans ajouté dynamiquement
if ( $this->getData(['translate','active']) === true
if ( substr($_SERVER['HTTP_ACCEPT_LANGUAGE'], 0, 2) !== 'fr'
AND $this->getData(['translate','active']) === true
AND $this->getUser('password') !== $this->getInput('ZWII_USER_PASSWORD')) {
$this->addOutput([
'vendor' => array_merge($this->output['vendor'], ['i18n'])
@ -2181,9 +2181,15 @@ class layout extends common {
) {
echo '<h1 id="sectionTitle">' . $this->core->output['title'] . '</h1>';
}
echo $this->core->output['content'];
}
echo $this->core->output['content'];
if ( substr($_SERVER['HTTP_ACCEPT_LANGUAGE'], 0, 2) !== 'fr'
AND $this->getData(['translate','showCredits']) === true
AND $this->getData(['translate','active']) === true )
{
echo '<div id="googTransLogo"><a href="//policies.google.com/terms#toc-content" data-lity><img src="core/module/translate/ressource/googtrans.png" /></a></div>';
}
}
/**
* Affiche le contenu de la barre gauche

View File

@ -1,6 +1,7 @@
<?php $layout = new layout($this); ?>
<?php $layout = new layout($this);
$lan = substr($_SERVER['HTTP_ACCEPT_LANGUAGE'], 0, 2); ?>
<!DOCTYPE html>
<html prefix="og: http://ogp.me/ns#" lang="fr">
<html prefix="og: http://ogp.me/ns#" lang="<?php echo $lan;?>">
<head>
<meta charset="UTF-8">
<meta name="viewport" content="width=device-width, initial-scale=1">

View File

@ -1433,3 +1433,28 @@ th.col12 {
-o-transform:scale(1.25); /* Opera */
transform:scale(1.25);
}
/* Traduction auto */
/*
* Supprimer Le tooltip Google
*
.goog-tooltip {
display: none !important;
}
.goog-tooltip:hover {
display: none !important;
}
.goog-text-highlight {
background-color: transparent !important;
border: none !important;
box-shadow: none !important;
} */
/* Emplacement des conditions d'utilisation */
#googTransLogo {
float: right;
}
#googTransLogo img {
width: 60%;
}

View File

@ -1,6 +1,7 @@
<?php $layout = new layout($this); ?>
<?php $layout = new layout($this);
$lan = substr($_SERVER['HTTP_ACCEPT_LANGUAGE'], 0, 2); ?>
<!DOCTYPE html>
<html prefix="og: http://ogp.me/ns#" lang="fr">
<html prefix="og: http://ogp.me/ns#" lang="<?php echo $lan;?>">
<head>
<meta charset="UTF-8">
<meta name="viewport" content="width=device-width, initial-scale=1">

View File

@ -1,6 +1,7 @@
<?php $layout = new layout($this); ?>
<?php $layout = new layout($this);
$lan = substr($_SERVER['HTTP_ACCEPT_LANGUAGE'], 0, 2); ?>
<!DOCTYPE html>
<html prefix="og: http://ogp.me/ns#" lang="fr">
<html prefix="og: http://ogp.me/ns#" lang="<?php echo $lan;?>">
<head>
<meta charset="UTF-8">
<meta name="viewport" content="width=device-width, initial-scale=1">

Binary file not shown.

After

Width:  |  Height:  |  Size: 119 B

Binary file not shown.

After

Width:  |  Height:  |  Size: 1.2 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 287 B

Binary file not shown.

After

Width:  |  Height:  |  Size: 96 B

Binary file not shown.

After

Width:  |  Height:  |  Size: 3.4 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 96 B

Binary file not shown.

After

Width:  |  Height:  |  Size: 108 B

Binary file not shown.

After

Width:  |  Height:  |  Size: 395 B

View File

@ -27,7 +27,7 @@ class translate extends common {
if($this->isPost()) {
$this->setData(['translate', [
'active' => $this->getInput('translateActive', helper::FILTER_BOOLEAN),
'showCredits' => $this->getInput('translateCredits', helper::FILTER_BOOLEAN),
'showCredits' => $this->getInput('translateActive', helper::FILTER_BOOLEAN) ? $this->getInput('translateCredits', helper::FILTER_BOOLEAN) : false,
]]);
// Valeurs en sortie
$this->addOutput([

View File

@ -19,12 +19,14 @@
<div class="row">
<div class="col6">
<?php echo template::checkbox('translateActive', true, 'Traduction automatique', [
'checked' => $this->getData(['translate', 'active'])
'checked' => $this->getData(['translate', 'active']),
'check' => 'Traduction automatique du site hors connexion par le script Google Traduction basée sur la langue du navigateur du visiteur.'
]); ?>
</div>
<div class="col6">
<?php echo template::checkbox('translateCredits', true, 'Afficher les crédits', [
'checked' => $this->getData(['translate', 'showCredits'])
'checked' => $this->getData(['translate', 'showCredits']),
'help' => 'Option vivement recommandée pour le respect du droit d\'auteur'
]); ?>
</div>
</div>