[10.0.92.dev] Nouvelle option de traduction automatique
This commit is contained in:
parent
3736852d80
commit
3476366cce
|
@ -32,7 +32,7 @@ class common {
|
|||
const I18N_DIR = 'site/i18n/';
|
||||
|
||||
// Numéro de version
|
||||
const ZWII_VERSION = '10.0.91.dev';
|
||||
const ZWII_VERSION = '10.0.92.dev';
|
||||
|
||||
public static $actions = [];
|
||||
public static $coreModuleIds = [
|
||||
|
@ -390,7 +390,7 @@ class common {
|
|||
if ( $lan !== 'fr') {
|
||||
setlocale (LC_TIME, $lan . '_' . strtoupper ($lan) );
|
||||
}
|
||||
setrawcookie("googtrans", htmlspecialchars('/fr') . htmlspecialchars ('/'. $lan), null, '/', null ) ;
|
||||
setrawcookie("googtrans", '/fr/'. $lan) ;
|
||||
}
|
||||
|
||||
/**
|
||||
|
@ -398,9 +398,9 @@ class common {
|
|||
* @return @string
|
||||
* @param @string code iso de la langue
|
||||
*/
|
||||
public function geti18FlagFolder($iso = '') {
|
||||
public function geti18nFlagFolder($iso = '') {
|
||||
$default = array ('de', 'en', 'es' , 'fr', 'it', 'nl', 'pt');
|
||||
return (in_array($iso,$default) === true ? 'core/vendor/i18n/png/' . $iso : self::FILE_DIR . 'source/i18n/png/' . $iso);
|
||||
return (in_array($iso,$default) === true ? 'core/vendor/i18n/png/' : self::FILE_DIR . 'source/i18n/png/' );
|
||||
}
|
||||
|
||||
|
||||
|
@ -907,7 +907,6 @@ class common {
|
|||
* @return array avec les données à importer dans le tableau de base
|
||||
*
|
||||
*/
|
||||
|
||||
public function importi18n() {
|
||||
$folder = self::FILE_DIR . '/source/i18n';
|
||||
// Des données valides existent-elles ?
|
||||
|
@ -1214,8 +1213,13 @@ class common {
|
|||
if($this->getData(['core', 'dataVersion']) < 10000) {
|
||||
$this->setData(['page',$this->getData(['config','homePageId']),'homePageId', true]);
|
||||
$this->deleteData(['config','homePageId']);
|
||||
// Données de la barre de langue dans le menu
|
||||
$this->setData(['theme','menu','burgerTitle',true]);
|
||||
$this->setData(['theme','menu','i18nPosition', 'right']);
|
||||
// Données de langue par défaut
|
||||
$this->setData(['config','i18n','fr', 'flagFolder', 'core/vendor/i18n/png/']);
|
||||
$this->setData(['config','i18n','fr', 'autotranslate', false]);
|
||||
|
||||
$this->setData(['core', 'dataVersion', 10000]);
|
||||
}
|
||||
}
|
||||
|
@ -2518,14 +2522,14 @@ class layout extends common {
|
|||
|
||||
$items .= '<li><form method="POST" action="' . helper::baseUrl() . 'i18n/lang" id="barFormSelectLanguage">';
|
||||
$items .= '<input type="image" alt="' . self::$i18nList[$this->geti18n()] . '(' . $this->geti18n() . ')' . '" class="flag flagSelected"';
|
||||
$items .= ' name="'.$this->geti18n().'" src="' . helper::baseUrl(false) . $this->geti18FlagFolder($this->geti18n()) . '.png" data-tippy-content="' . self::$i18nList[$this->geti18n()] . '" />';
|
||||
$items .= ' name="'.$this->geti18n().'" src="' . helper::baseUrl(false) . $this->getData(['config','i18n',$this->geti18n(),'flagFolder']) . $this->geti18n() . '.png" data-tippy-content="' . self::$i18nList[$this->geti18n()] . '" />';
|
||||
$items .= '</form></li>';
|
||||
foreach ($this->i18nInstalled() as $itemKey => $item) {
|
||||
if ($this->geti18n() !== $itemKey ) {
|
||||
|
||||
$items .= '<li><form method="POST" action="' . helper::baseUrl() . 'i18n/lang" id="barFormSelectLanguage">';
|
||||
$items .= '<input type="image" alt="'.$itemKey.'" class="flag"';
|
||||
$items .= ' name="'.$itemKey.'" src="' . helper::baseUrl(false) . $this->geti18FlagFolder($itemKey) . '.png" data-tippy-content="'. $item .'" />';
|
||||
$items .= ' name="'.$itemKey.'" src="' . helper::baseUrl(false) . $this->getData(['config','i18n',$itemKey,'flagFolder']) . $itemKey . '.png" data-tippy-content="'. $item .'" />';
|
||||
$items .= '</form></li>';
|
||||
}
|
||||
}
|
||||
|
|
|
@ -46,6 +46,10 @@ class i18n extends common {
|
|||
// Copier les données par défaut avec gestion des erreurs
|
||||
$success = (copy ($copyFrom . 'module.json', self::DATA_DIR . $this->getInput('i18nLanguageAdd') . '/module.json') === true && $success === true) ? true : false;
|
||||
$success = (copy ($copyFrom . 'page.json', self::DATA_DIR . $this->getInput('i18nLanguageAdd') . '/page.json') === true && $success === true) ? true : false;
|
||||
// Enregistrement des données de langue dans la config
|
||||
// Chemin des images
|
||||
$this->setData(['config','i18n',$create,'flagFolder',$this->geti18nFlagFolder($create)]);
|
||||
$this->setData(['config','i18n',$create,'autoTranslate',$this->getInput('i18AutoTranslation',helper::FILTER_BOOLEAN)]);
|
||||
} else {
|
||||
$notification = $create . ' est déjà ajoutée.';
|
||||
$success = false;
|
||||
|
@ -70,6 +74,8 @@ class i18n extends common {
|
|||
foreach($langIds as $itemKeyLang => $itemLang) {
|
||||
self::$languages[] = [
|
||||
$itemLang,
|
||||
$this->getData(['config','i18n',$itemKeyLang,'flagFolder']),
|
||||
$this->getData(['config','i18n',$itemKeyLang,'autoTranslate']) === true ? 'Oui' : 'Non',
|
||||
template::button('i18nDelete' . $itemKeyLang, [
|
||||
'class' => 'i18nDelete buttonRed',
|
||||
'href' => helper::baseUrl() . 'i18n/delete/' . $itemKeyLang. '/' . $_SESSION['csrf'],
|
||||
|
@ -114,6 +120,9 @@ class i18n extends common {
|
|||
$success = unlink (self::DATA_DIR . $this->getUrl(2) . '/module.json');
|
||||
$success = (unlink (self::DATA_DIR . $this->getUrl(2) . '/page.json') && $success === true) ? true : false ;
|
||||
$success = (rmdir (self::DATA_DIR . $this->getUrl(2)) === true && $success === true) ? true : false ;
|
||||
// Effacer les données de config
|
||||
$this->deleteData(['config','i18n',$this->getUrl(2)]);
|
||||
|
||||
} else {
|
||||
$success = false;
|
||||
}
|
||||
|
|
|
@ -15,7 +15,7 @@
|
|||
<div class="row">
|
||||
<div class="col12">
|
||||
<div class="block">
|
||||
<h4>Ajouter ou dupliquer une nouvelle langue <a href="./core/module/i18n/ressource/help.html" data-lity data-tippy-content="Aide en ligne"<?php echo template::ico('help'); ?></a></h4>
|
||||
<h4>Ajouter ou dupliquer <a href="./core/module/i18n/ressource/help.html" data-lity data-tippy-content="Aide en ligne"<?php echo template::ico('help'); ?></a></h4>
|
||||
<div class="row">
|
||||
<div class="col6">
|
||||
<?php
|
||||
|
@ -23,18 +23,23 @@
|
|||
$available = array_merge ($available, array_diff(self::$i18nList,$this->i18nInstalled()));
|
||||
echo template::select('i18nLanguageAdd', $available, [
|
||||
'label' => 'Nouvelle langue'
|
||||
]); ?>
|
||||
]); ?>
|
||||
</div>
|
||||
<div class="col6">
|
||||
<?php echo template::select('i18nLanguageCopyFrom', $this->i18nInstalled(true), [
|
||||
'label' => 'Site à copier',
|
||||
'selected' => -1
|
||||
]); ?>
|
||||
<div class="row">
|
||||
<?php echo template::select('i18nLanguageCopyFrom', $this->i18nInstalled(true), [
|
||||
'label' => 'Langue à dupliquer',
|
||||
'selected' => -1
|
||||
]); ?>
|
||||
</div>
|
||||
<div class="row">
|
||||
<?php echo template::checkbox('i18AutoTranslation', true, 'Traduction automatique'); ?>
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
|
||||
<?php echo template::table([11, 1], $module::$languages, ['Langues installées', '']); ?>
|
||||
<?php echo template::table([5,2,2,1], $module::$languages, ['Langues installées', 'Chemin du drapeau', 'Traduction Automatisée' ,'']); ?>
|
||||
<?php echo template::formClose(); ?>
|
||||
|
|
|
@ -21,6 +21,12 @@ class init extends common {
|
|||
'legalPageId' => '',
|
||||
'metaDescription' => 'Zwii est un CMS sans base de données qui permet de créer et gérer facilement un site web sans aucune connaissance en programmation.',
|
||||
'title' => 'Zwii, votre site en quelques clics !',
|
||||
'i18n' => [
|
||||
'fr' => [
|
||||
'flagFolder' => "core\/vendor\/i18n\/png\/",
|
||||
'AutoTranslate' => false
|
||||
]
|
||||
]
|
||||
],
|
||||
'core' => [
|
||||
'dataVersion' => 10000,
|
||||
|
|
Loading…
Reference in New Issue