12100 Restore database language

This commit is contained in:
Fred Tempez 2023-01-01 11:12:30 +01:00
parent 6e97d5c519
commit cf1e574173
4 changed files with 58 additions and 18 deletions

View File

@ -690,6 +690,14 @@ class common
}
$db->save;
// Créer la base de données des langues
if ($module === 'languages') {
copy('core/module/install/ressource/i18n/languages.json', self::DATA_DIR . 'languages.json');
$this->copyDir('core/module/install/ressource/i18n', self::I18N_DIR);
unlink(self::I18N_DIR . 'languages.json');
}
// Créer le jeu de pages du site de test
if ($module === 'page') {
$langFolder = $lang . '/content/';
@ -2141,16 +2149,15 @@ class common
foreach (self::$languages as $key => $value) {
if (is_dir(self::DATA_DIR . $key)) {
$c++;
$location = helper::baseUrl() . 'translate/content/' . $key ;
$location = helper::baseUrl() . 'translate/content/' . $key;
$leftItem .= '<option name="' . $key . '" value="' . $location . '" ' . ($key === self::$i18nContent ? 'selected' : '') . '>' . $value . '</option>';
}
}
if ($c > 1 ) {
if ($c > 1) {
$leftItems .= '<li><select id="barSelectLanguage">';
$leftItems .= $leftItem;
$leftItems .= '</select></li>';
}
}
// Liste des pages
if ($this->getUser('group') >= self::GROUP_MODERATOR) {

View File

@ -199,6 +199,7 @@ class install extends common
unlink(self::TEMP_DIR . 'files.tar');
helper::deleteCookie('ZWII_UI');
// Créer le dossier des fontes
if (!is_dir(self::DATA_DIR . 'fonts')) {
mkdir(self::DATA_DIR . 'fonts');
@ -224,8 +225,9 @@ class install extends common
if (is_dir(self::I18N_DIR) === false) {
mkdir(self::I18N_DIR);
}
$enums = json_decode(file_get_contents('core/module/install/ressource/i18n/languages.json'), true);
$this->setData(['languages', $enums]);
// Créer la base de données des langues
copy('core/module/install/ressource/i18n/languages.json', self::DATA_DIR . 'languages.json');
$this->copyDir('core/module/install/ressource/i18n', self::I18N_DIR);
unlink(self::I18N_DIR . 'languages.json');
@ -397,4 +399,33 @@ class install extends common
'view' => 'update'
]);
}
/**
* Génère un fichier d'énumération des langues de l'UI
*/
private function makeUiLanguages()
{
// Générer une énumération absente
if (empty($enums)) {
if (is_dir(self::I18N_DIR) === false) {
mkdir(self::I18N_DIR);
}
$dir = getcwd();
chdir(self::I18N_DIR);
$files = glob('*.json');
chdir($dir);
$enums = [];
foreach ($files as $file => $value) {
if (basename($value, '.json') === 'languages') {
continue;
}
$enums[basename($value, '.json')] = [
'version' => "?",
'date' => 1672052400
];
}
$this->setData(['languages', $enums]);
}
}
}

View File

@ -1,14 +1,16 @@
{
"fr_FR": {
"version": "1.0",
"date": 1672052400
},
"es": {
"version": "1.0",
"date": 1672052400
},
"en_EN": {
"version": "1.0",
"date": 1672052400
"languages": {
"en_EN": {
"version": "1.0",
"date": 1672052400
},
"es": {
"version": "1.0",
"date": 1672052400
},
"fr_FR": {
"version": "1.0",
"date": 1672052400
}
}
}

View File

@ -81,7 +81,7 @@ class translate extends common
$response = file_put_contents(self::I18N_DIR . $lang . '.json', json_encode($response, JSON_UNESCAPED_UNICODE | JSON_UNESCAPED_SLASHES | JSON_PRETTY_PRINT));
// Mettre à jour le descripteur
$enumsStore = json_decode(helper::getUrlContents(common::ZWII_UI_URL . 'languages.json'), true);
$enums = $this->getUiLanguages();
$enums = $this->getData(['languages']);
$enums = array_merge($enums, [
$lang => $enumsStore[$lang]
]);
@ -210,7 +210,7 @@ class translate extends common
}
// Langues installées
$installedUI = $this->getUiLanguages();
$installedUI = $this->getData(['languages']);
// Langues disponibles en ligne
$storeUI = json_decode(helper::getUrlContents(common::ZWII_UI_URL . 'languages.json'), true);