zwiicms-translations/tools/cleanModules.php

35 lines
1.0 KiB
PHP
Raw Permalink Normal View History

2023-04-13 10:49:34 +02:00
<?php
$langTargetArray = ['fr_FR', 'de', 'en_EN', 'es', 'gr_GR', 'it', 'pt_PT'];
$folderTargetArray = [
'../modules/blog/',
'../modules/news/',
'../modules/form/',
'../modules/gallery/',
'../modules/redirection/',
'../modules/search/',
2023-08-06 10:06:31 +02:00
'../modules/slider/',
'../modules/download/',
2023-04-13 10:49:34 +02:00
];
foreach ($langTargetArray as $lang) {
echo $lang;
echo '<hr>';
foreach ($folderTargetArray as $module) {
$fichiers[] = $module . $lang . '.json';
$json = json_decode(file_get_contents($fichier), true);
2023-08-06 10:06:31 +02:00
$result = filterMatchingArrays($json, $lang);
2023-04-13 10:49:34 +02:00
2023-08-06 10:06:31 +02:00
// Enregistrer les clés uniques dans un fichier JSON
file_put_contents($target . '.json', json_encode($result, JSON_UNESCAPED_UNICODE | JSON_UNESCAPED_SLASHES | JSON_PRETTY_PRINT));
2023-04-13 10:49:34 +02:00
}
2023-08-06 10:06:31 +02:00
}
2023-04-13 10:49:34 +02:00
2023-08-06 10:06:31 +02:00
function filterMatchingArrays($array1, $array2) {
$filteredArray = array_filter($array2, function($item) use ($array1) {
return in_array($item, $array1);
});
2023-04-13 10:49:34 +02:00
2023-08-06 10:06:31 +02:00
return array_values($filteredArray);
2023-04-13 10:49:34 +02:00
}