Translate copy okay

This commit is contained in:
Fred Tempez 2022-09-29 10:55:20 +02:00
parent 469581e37f
commit ac8f65277e

View File

@ -63,7 +63,7 @@ class translate extends common
} else { } else {
$success = true; $success = true;
} }
// Copier les données par défaut avec gestion des erreurs // Copier les données par défaut
$success = (copy(self::DATA_DIR . $copyFrom . '/locale.json', self::DATA_DIR . $toCreate . '/locale.json') === true && $success === true) ? true : false; $success = (copy(self::DATA_DIR . $copyFrom . '/locale.json', self::DATA_DIR . $toCreate . '/locale.json') === true && $success === true) ? true : false;
$success = (copy(self::DATA_DIR . $copyFrom . '/module.json', self::DATA_DIR . $toCreate . '/module.json') === true && $success === true) ? true : false; $success = (copy(self::DATA_DIR . $copyFrom . '/module.json', self::DATA_DIR . $toCreate . '/module.json') === true && $success === true) ? true : false;
$success = (copy(self::DATA_DIR . $copyFrom . '/page.json', self::DATA_DIR . $toCreate . '/page.json') === true && $success === true) ? true : false; $success = (copy(self::DATA_DIR . $copyFrom . '/page.json', self::DATA_DIR . $toCreate . '/page.json') === true && $success === true) ? true : false;
@ -87,14 +87,17 @@ class translate extends common
'state' => $success 'state' => $success
]); ]);
} }
// Tableau des langues installées // Tableau des langues installées
foreach (self::$languages as $key => $value) { foreach (self::$languages as $key => $value) {
if ($this->getData(['config', 'i18n', $key]) === 'site') { // tableau des langues installées
self::$languagesTarget[$key] = $value; if (is_dir(self::DATA_DIR . $key)) {
self::$languagesTarget[$key] = self::$languages[$key];
} }
} }
// Langues cibles fr en plus // Langues cibles fr en plus
self::$languagesInstalled = array_merge(['fr_FR' => 'Français (fr_FR)'], self::$languagesTarget); self::$languagesInstalled = self::$languagesTarget;
// Valeurs en sortie // Valeurs en sortie
$this->addOutput([ $this->addOutput([
@ -127,22 +130,22 @@ class translate extends common
// ------------------------- // -------------------------
// Onglet des langues de contenu // Onglet des langues de contenu
foreach (self::$languages as $keyi18n => $value) { foreach (self::$languages as $key => $value) {
// tableau des langues installées // tableau des langues installées
if (is_dir(self::DATA_DIR . $keyi18n)) { if (is_dir(self::DATA_DIR . $key)) {
self::$languagesInstalled[] = [ self::$languagesInstalled[] = [
template::flag($keyi18n, '50%'), template::flag($key, '50%'),
$value . ' (' . $keyi18n . ')', $value . ' (' . $key . ')',
self::$i18nUI === $keyi18n ? '(langue de l\'interface)' : '', self::$i18nUI === $key ? '(langue de l\'interface)' : '',
'', '',
template::button('translateContentLanguageEdit' . $keyi18n, [ template::button('translateContentLanguageEdit' . $key, [
'href' => helper::baseUrl() . $this->getUrl(0) . '/edit/' . $keyi18n . '/' . $_SESSION['csrf'], 'href' => helper::baseUrl() . $this->getUrl(0) . '/edit/' . $key . '/' . $_SESSION['csrf'],
'value' => template::ico('flag'), 'value' => template::ico('flag'),
'help' => 'Editer les locales' 'help' => 'Editer les locales'
]), ]),
template::button('translateContentLanguageDelete' . $keyi18n, [ template::button('translateContentLanguageDelete' . $key, [
'class' => 'translateDelete buttonRed' . (self::$i18nUI === $keyi18n ? ' disabled' : ''), 'class' => 'translateDelete buttonRed' . (self::$i18nUI === $key ? ' disabled' : ''),
'href' => helper::baseUrl() . $this->getUrl(0) . '/delete/' . $keyi18n . '/' . $_SESSION['csrf'], 'href' => helper::baseUrl() . $this->getUrl(0) . '/delete/' . $key . '/' . $_SESSION['csrf'],
'value' => template::ico('trash'), 'value' => template::ico('trash'),
'help' => 'Supprimer cette langue' 'help' => 'Supprimer cette langue'
]) ])