Ajout de traduction + moteur d'auto traduction
This commit is contained in:
parent
2a840251bc
commit
1ad9ae68b9
|
@ -27,20 +27,14 @@ class helper
|
|||
public static function translate($text)
|
||||
{
|
||||
|
||||
// Captation
|
||||
/*
|
||||
$data = json_decode(file_get_contents('site/i18n/template.json'), true);
|
||||
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) && !empty(core::$dialog[$text]) ? core::$dialog[$text] : $text;
|
||||
|
||||
return $r;
|
||||
}
|
||||
|
||||
|
||||
|
||||
|
||||
/**
|
||||
* Récupérer l'adresse IP sans tenir compte du proxy
|
||||
* @param integer Niveau d'anonymat 0 aucun, 1 octet à droite, etc..
|
||||
|
|
|
@ -420,6 +420,15 @@ class common
|
|||
// Chargement des dialogues
|
||||
self::$dialog = json_decode(file_get_contents(self::I18N_DIR . self::$i18nUI . '.json'), true);
|
||||
|
||||
// Traduction des dialogues
|
||||
// --- A SUPPRIMER --------
|
||||
/*
|
||||
foreach (self::$dialog as $key => $value) {
|
||||
$this->googleTranslate('fr', 'it', $key);
|
||||
}
|
||||
*/
|
||||
|
||||
|
||||
// Mise à jour des données core
|
||||
if ($this->getData(['core', 'dataVersion']) !== intval(str_replace('.', '', self::ZWII_VERSION))) include('core/include/update.inc.php');
|
||||
|
||||
|
@ -445,6 +454,26 @@ class common
|
|||
}
|
||||
}
|
||||
|
||||
|
||||
/**
|
||||
* Fonction pour assurer la traduction des messages
|
||||
*/
|
||||
public function googleTranslate($from, $to, $text){
|
||||
$arrayjson = json_decode(file_get_contents('https://clients5.google.com/translate_a/t?client=dict-chrome-ex&sl=auto&tl=' . $to . '&q=' . rawurlencode($text)),true);
|
||||
$response = $arrayjson[0][0];
|
||||
sleep(0.5);
|
||||
// Captation
|
||||
$data = json_decode(file_get_contents('site/i18n/' . $to . '.json'), true);
|
||||
if ($data && array_key_exists($text, $data) ) {
|
||||
if ($text !== '' ) {
|
||||
$data = array_merge($data,[$text => $response] );
|
||||
file_put_contents ('site/i18n/' . $to . '.json', json_encode($data, JSON_UNESCAPED_UNICODE), LOCK_EX);
|
||||
}
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
|
||||
/**
|
||||
* Ajoute les valeurs en sortie
|
||||
* @param array $output Valeurs en sortie
|
||||
|
|
|
@ -29,7 +29,7 @@
|
|||
'href' => helper::baseUrl() . 'translate/copy',
|
||||
'value' => template::ico('docs'),
|
||||
'disabled' => $module::$siteCopy,
|
||||
'help' => 'Copie de contenus localisés'
|
||||
'help' =>'Copie de contenus localisés'
|
||||
]); ?>
|
||||
</div>
|
||||
<div class="col2">
|
||||
|
|
File diff suppressed because one or more lines are too long
File diff suppressed because one or more lines are too long
File diff suppressed because one or more lines are too long
Loading…
Reference in New Issue