basedir = realpath(dirname(__FILE__)) . "/../../.."; $this->charger_langues('request'); $this->show_all = intval($_REQUEST['manquants']) == 0 ? 1 : 0; $this->simplescan = intval(Variable::lire(self::SIMPLESCAN_VAR)); } function normaliser_path($path) { $path = str_replace('\\', '/', str_replace($this->base_thelia, '', realpath($path))); if ($path[0] == '/') $path = substr($path, 1); return $path; } function charger_repertoire($dir) { if ($dh = opendir($dir)) { while (($file = readdir($dh)) !== false) { $fp = realpath($dir.'/'.$file); $short_path = $this->normaliser_path($fp); if ($file != '.' && $file != '..' && is_dir($fp)) $this->charger_repertoire($fp); if (! is_file($fp) || (! preg_match('/\.html$/', $fp) && ! preg_match('/\.xml$/', $fp))) continue; if ($content = file_get_contents($fp)) { $matches = array(); if (preg_match_all('!'.Traduction::MARQUE_DEBUT.'(.*?)'.Traduction::MARQUE_FIN.'!is', $content, $matches)) { foreach($matches[1] as $match) { $hash = hash('md5', $match); if (isset($this->reference[$hash])) { if (! in_array($short_path, $this->reference[$hash]['files'])) { $this->reference[$hash]['files'][] = $short_path; } } else $this->reference[$hash] = array('files' => array($short_path), 'chaine' => $match); } } } } @closedir($dh); } } // Charger les chaines à traduire function charger_reference() { $this->reference = array(); if ($this->simplescan) { $this->charger_repertoire($this->basedir."/template"); $this->charger_repertoire($this->basedir."/client/pdf/template"); } else { $this->charger_repertoire($this->basedir); } uasort($this->reference, 'TraductionAdmin::tri'); } static function tri($a, $b) { $as = implode(',', $a['files']). strtoupper($a['chaine']); $bs = implode(',', $b['files']). strtoupper($b['chaine']); return strcmp($as, $bs); } // Consituer le tableau des chaines dans la langue courante function charger_traduction() { $transfile = $this->basedir . self::LANGDIR.'/traduction_'.$this->idlangue.'.php'; if (is_file($transfile)) { include($transfile); } else { $traduction = array(); } // Trouver les nouvelles chaines foreach($this->reference as $hash => $chaine) { if (! isset($traduction[$hash])) { $traduction[$hash] = ''; } } // Supprimer les chaines obsoletes foreach($traduction as $hash => $chaine) { if (! isset($this->reference[$hash])) { unset($traduction[$hash]); } } $this->traduction = $traduction; } function ecrire_fichier_traduction() { $this->charger_reference(); $this->charger_traduction(); $file = $this->basedir . self::LANGDIR.'/traduction_'.$this->idlangue.'.php'; if ($fp = @fopen($file, 'w')) { fwrite($fp, '<' . '?php' . "\n"); fwrite($fp, '$traduction = array('."\n"); foreach($this->traduction as $hash => $chaine) { if (isset($_REQUEST[$hash]) && trim($_REQUEST[$hash]) != '') { $val = $_REQUEST[$hash]; if (! get_magic_quotes_gpc()) $val = str_replace("'", "\'", $val); else $val = str_replace('\"', '"', $val); } else if (isset($_REQUEST['hidden_' . $hash])) { $val = str_replace("'", "\'", $chaine); } else { continue; } fwrite($fp, "\t'$hash' => '".$val."',\n"); } fwrite($fp, ");\n"); fwrite($fp, '?' . ">\n"); @fclose($fh); } else { die("Erreur à l'ouverture du fichier $file pour écriture. Vérifiez les droits d'accès de ce fichier et du répertoire qui le contient."); } } public function maj_options() { $simplescan = intval(lireParam('simplescan', 'int')); $opt = new Variable(); if ($opt->charger(self::SIMPLESCAN_VAR)) { $opt->valeur = $simplescan; $opt->maj(); } else { $opt->nom = self::SIMPLESCAN_VAR; $opt->valeur = $simplescan; $opt->cache = 1; $opt->protege = 1; $opt->add(); } } } $adm = new TraductionAdmin(); if ($commande == 'maj_trans') { $adm->ecrire_fichier_traduction(); } else if ($commande == 'maj_options') { $adm->maj_options(); } $adm->charger_reference(); $adm->charger_traduction(); ?>
Accueil
Liste des modules
Traductions v
Aucun message a traduire n'a été trouvé dans vos fichiers HTML.
Vous devez les modifier, et
entourer les messages à traduire avec les balises et .
Par exemple, "Mon Panier" devient "Mon Panier".
Attention, les messages à traduire ne doivent pas contenir de variables Thélia. Le cas échéant, la traduction ne pourra pas fonctionner.
Plugin Thelia réalisé par Franck Allimant - CQFDev. Contact: www.cqfdev.fr