From ebfd83d494f9cca85a36083ee1f92ab3b410d1a7 Mon Sep 17 00:00:00 2001
From: Matthieu Marcillaud <marcimat@rezo.net>
Date: Tue, 11 Jul 2023 18:23:29 +0200
Subject: [PATCH] =?UTF-8?q?feat:=20Fonction=20permettant=20de=20retrouver?=
 =?UTF-8?q?=20le=20type=20d=E2=80=99export=20d=E2=80=99un=20fichier=20de?=
 =?UTF-8?q?=20lang=20(de=20type=20spip=20plut=C3=B4t)?=
MIME-Version: 1.0
Content-Type: text/plain; charset=UTF-8
Content-Transfer-Encoding: 8bit

---
 inc/salvatore.php | 21 +++++++++++++++++++++
 1 file changed, 21 insertions(+)

diff --git a/inc/salvatore.php b/inc/salvatore.php
index cd28b0e..950d715 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
-- 
GitLab