diff --git a/inc/salvatore.php b/inc/salvatore.php index cd28b0e5f46411bd473ee34bd14de8c2070a7b07..950d715a91264fa639cc9ba4555c33c4e0f924f3 100644 --- a/inc/salvatore.php +++ b/inc/salvatore.php @@ -330,6 +330,27 @@ function salvatore_retrouver_tradlang_module($dir_module, $module) { return false; } + +/** + * Retrouve le type de fichier de lang + */ +function salvatore_retrouver_type_export(string $lang_file): string { + $ext = pathinfo($lang_file, \PATHINFO_EXTENSION); + if (in_array($ext, ['csv', 'po'])) { + return $ext; + } + if ($ext !== 'php') { + return ''; + } + $content = file_get_contents($lang_file); + if (str_contains($content, '$GLOBALS[$GLOBALS[\'idx_lang\']] = array(')) { + return 'spip'; + } elseif (str_contains($content, 'return [')) { + return 'spip5'; + } + return ''; +} + /** * Ajouter les credentials user/pass sur les urls de repo * @param string $methode