Traduction rédigée ok

This commit is contained in:
fredtempez 2020-11-26 09:52:22 +01:00
parent 49e8603ff9
commit de6c83380a
3 changed files with 34 additions and 24 deletions

3
.gitignore vendored
View File

@ -51,3 +51,6 @@ site/data/it/page.json
site/data/nl/locale.json site/data/nl/locale.json
site/data/nl/module.json site/data/nl/module.json
site/data/nl/page.json site/data/nl/page.json
site/data/pt/locale.json
site/data/pt/module.json
site/data/pt/page.json

View File

@ -152,7 +152,7 @@ class common {
'pt' => 'Portugais (pt)', 'pt' => 'Portugais (pt)',
]; ];
// Langue courante // Langue courante
public static $i18nSite = 'fr'; public static $i18nSite;
public static $timezone; public static $timezone;
private $url = ''; private $url = '';
// Données de site // Données de site
@ -196,6 +196,8 @@ class common {
) { ) {
self::$i18nSite = $this->input['_COOKIE']['ZWII_I18N_SITE']; self::$i18nSite = $this->input['_COOKIE']['ZWII_I18N_SITE'];
setlocale (LC_TIME, self::$i18nSite . '_' . strtoupper (self::$i18nSite) ); setlocale (LC_TIME, self::$i18nSite . '_' . strtoupper (self::$i18nSite) );
} else {
self::$i18nSite = 'fr';
} }
// Instanciation de la classe des entrées / sorties // Instanciation de la classe des entrées / sorties
@ -2182,19 +2184,20 @@ class core extends common {
} }
// Chargement de la bibliothèque googtrans // Chargement de la bibliothèque googtrans
// Le multi langue est actif // Le multi langue est sélectionné et la traduction n'est pas manuelle
if ($this->getData(['config','translate','scriptGoogle']) === true ) { if ($this->getData(['config','translate','scriptGoogle']) === true
// la traduction auto est active ) {
if ( $this->getData(['config','translate','autoDetect']) === true
// Cas des pages d'administration // Cas des pages d'administration
/*
AND $this->getUser('password') !== $this->getInput('ZWII_USER_PASSWORD') AND $this->getUser('password') !== $this->getInput('ZWII_USER_PASSWORD')
OR ($this->getUser('password') === $this->getInput('ZWII_USER_PASSWORD') OR ($this->getUser('password') === $this->getInput('ZWII_USER_PASSWORD')
AND $this->getData(['config','translate','admin']) === true ) AND $this->getData(['config','translate','admin']) === true )
) { ) {
*/
$this->addOutput([ $this->addOutput([
'vendor' => array_merge($this->output['vendor'], ['i18n']) 'vendor' => array_merge($this->output['vendor'], ['i18n'])
]); ]);
}
} }
// Erreurs // Erreurs
if($access === 'login') { if($access === 'login') {
@ -2339,6 +2342,7 @@ class layout extends common {
*/ */
if ( ( if ( (
( $this->getData(['config','translate','scriptGoogle']) === true ( $this->getData(['config','translate','scriptGoogle']) === true
AND isset($_COOKIES['googtrans'])
AND substr($_SERVER['HTTP_ACCEPT_LANGUAGE'], 0, 2) !== 'fr' AND substr($_SERVER['HTTP_ACCEPT_LANGUAGE'], 0, 2) !== 'fr'
) )
OR ( isset($_COOKIES['ZWII_I18N_SITE']) OR ( isset($_COOKIES['ZWII_I18N_SITE'])
@ -3033,7 +3037,7 @@ class layout extends common {
} }
} }
/** /**
* Affiche le cadre avec les drapeaux * Affiche le cadre avec les drapeaux sélectionnés
*/ */
public function showi18n() { public function showi18n() {
echo '<div id="i18nContainer"><ul>'; echo '<div id="i18nContainer"><ul>';
@ -3045,7 +3049,7 @@ class layout extends common {
) )
) { ) {
echo '<li>'; echo '<li>';
echo '<a href="' . helper::baseUrl() . 'translate/language/' . $key . '/' . $this->getData(['config','translate',$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->getData(['config','translate',$key]) . '"><img class= "flag" src="' . helper::baseUrl(false) . 'core/vendor/i18n/png/' . $key . '.png" /></a>';
echo '</li>'; echo '</li>';
} }
} }

View File

@ -37,7 +37,7 @@ class translate extends common {
foreach (self::$i18nList as $keyi18n => $value) { foreach (self::$i18nList as $keyi18n => $value) {
if ($keyi18n === 'fr') {continue;} if ($keyi18n === 'fr') {continue;}
// Effacement d'une langue installée // Effacement d'une langue installée
if ( is_dir( self::DATA_DIR . $keyi18n ) === false if ( is_dir( self::DATA_DIR . $keyi18n ) === true
AND $this->getInput('translate' . strtoupper($keyi18n)) === 'none') AND $this->getInput('translate' . strtoupper($keyi18n)) === 'none')
{ {
$this->removeDir( self::DATA_DIR . $keyi18n); $this->removeDir( self::DATA_DIR . $keyi18n);
@ -45,22 +45,22 @@ class translate extends common {
// Installation d'une langue // Installation d'une langue
if ( $this->getInput('translate' . strtoupper($keyi18n)) === 'site') if ( $this->getInput('translate' . strtoupper($keyi18n)) === 'site')
{ {
// Créer le dossier // Créer les données absentes
if (is_dir( self::DATA_DIR . $keyi18n ) === false ) { if (is_dir( self::DATA_DIR . $keyi18n ) === false ) {
mkdir( self::DATA_DIR . $keyi18n); mkdir( self::DATA_DIR . $keyi18n);
} // Charger les modèles
// Charger les modèles require_once('core/module/install/ressource/defaultdata.php');
require_once('core/module/install/ressource/defaultdata.php'); // Nouvelle instance page, module, locale
// Nouvelle instance page, module, locale $files = ['page','module','locale'];
$files = ['page','module','locale']; foreach ($files as $keyFile) {
foreach ($files as $keyFile) { echo $keyFile;
echo $keyFile; $e = new \Prowebcraft\JsonDb([
$e = new \Prowebcraft\JsonDb([ 'name' => $keyFile . '.json',
'name' => $keyFile . '.json', 'dir' => $this->dirData ($keyFile,$keyi18n)
'dir' => $this->dirData ($keyFile,$keyi18n) ]);;
]);; $e->set($keyFile, init::$defaultData[$keyFile]);
$e->set($keyFile, init::$defaultData[$keyFile]); $e->save();
$e->save(); }
} }
} }
} }
@ -99,9 +99,12 @@ class translate extends common {
*/ */
public function language() { public function language() {
// Transmettre le choix au noyau // Transmettre le choix au noyau
setcookie('ZWII_I18N_SITE', $this->getUrl(2), time() + 3600, helper::baseUrl(false, false) , '', helper::isHttps(), true);
if ($this->getUrl(3) === 'script') { if ($this->getUrl(3) === 'script') {
setrawcookie("googtrans", '/fr/'. $this->getUrl(2), time() + 3600, helper::baseUrl()); setrawcookie("googtrans", '/fr/'. $this->getUrl(2), time() + 3600, helper::baseUrl());
helper::deleteCookie('ZWII_I18N_SITE');
} else {
setcookie('ZWII_I18N_SITE', $this->getUrl(2), time() + 3600, helper::baseUrl(false, false) , '', helper::isHttps(), true);
helper::deleteCookie ('googtrans');
} }
// Valeurs en sortie // Valeurs en sortie
$this->addOutput([ $this->addOutput([