From 316b48fe72e26b37f25e3b66710c1e0d0af52b5f Mon Sep 17 00:00:00 2001
From: EV-soft <21997911+EV-soft@users.noreply.github.com>
Date: Fri, 13 Mar 2026 11:55:09 +0100
Subject: [PATCH 1/3] Implement language string extraction for translation
Added functionality to extract and display language strings for translation.
---
tinyfilemanager.php | 27 +++++++++++++++++++++++++++
1 file changed, 27 insertions(+)
diff --git a/tinyfilemanager.php b/tinyfilemanager.php
index 81da5483..8b97346c 100644
--- a/tinyfilemanager.php
+++ b/tinyfilemanager.php
@@ -5609,5 +5609,32 @@ function lng($txt)
else if (isset($tr['en'][$txt])) return fm_enc($tr['en'][$txt]);
else return "$txt";
}
+
+if ($lang != 'en') { # Check your language
+// if (@$_GET['lng'] != 'lng') { # URL-trigger: tinyfilemanager.php?lng=lng
+ function extractLngStrings($input) { # Make a updated lng-keylist:
+ preg_match_all('/lng\([\'"]([^\'"]*)[\'"]\)/', $input, $matches); # Scann source-file for keywords in lng()-call
+ if (!isset($matches[1])) { return []; } #
+ $unique = array_unique($matches[1]); # Remove dublicates
+ sort($unique, SORT_NATURAL | SORT_FLAG_CASE); # Sort alphabetic
+ return $unique; #
+ } # Output result to screen:
+ echo '
Translate control:
';
+ echo 'Updated list of current keywords for your language, to be used in translation.json:
'; # 'Vers:'. VERSION .
+ echo 'Use CTRL-A to mark all in the green frame. Copy/Paste it to your UTF8 editor and complete translation.';
+ echo '
'; + echo '"name": "'.$lang_list[$lang].'",
'; + echo '"code": "'.$lang.'",
'; + echo '"translation": {
'; + $array= extractLngStrings(file_get_contents(__FILE__)); + $last = count($array) - 1; $n=0; + foreach ($array as $ix => $key) { if ($key==lng($key)) $n++; + echo ' "'.$key.'": "'.($key==lng($key) ? ''. $n.': ' : '').lng($key).''.'"'; + echo ($ix < $last) ? ",
" : "
"; + } + echo '}
';
echo '"name": "'.$lang_list[$lang].'",
';
echo '"code": "'.$lang.'",
';
+ echo '"vers": "'.APP_TITLE.' '.VERSION.'",
';
+ echo '"note": "vers, note, date, author are new fields 2026",
';
+ echo '"date": "'.date("Y-m-d").'",
';
+ echo '"author": "----",
';
echo '"translation": {
';
- $array= extractLngStrings(file_get_contents(__FILE__));
- $last = count($array) - 1; $n=0;
- foreach ($array as $ix => $key) { if ($key==lng($key)) $n++;
+ $array1= extractTxt(file_get_contents(__FILE__),'lng');
+ $array2= extractTxt(file_get_contents(__FILE__),'toast');
+ $array = array_merge(array_values($array1), array_values($array2));
+ $last = count($array) - 1; $n=0;
+ foreach ($array as $ix => $key) {
+ if ($key == lng($key)) $n++;
echo ' "'.$key.'": "'.($key==lng($key) ? ''. $n.': ' : '').lng($key).''.'"';
echo ($ix < $last) ? ",
" : "
";
}
echo '}Suggestions for updating the english tr table:
'; + $s= []; + foreach ($array as $a) { # in function lng($txt) add $tr as global: "global $lang, $tr;" + $str = ' $tr[\'en\'][\''.$a.'\'] '; + echo $str.indentAfter($str,70).'= \''.($tr['en'][($a)] > '' ? $tr['en'][($a)] : $a).'\';
'; + $newArr[$a] = $a; + } + echo ' Total: '.count($array) . ' keys in list.'; + $ar= array_merge($newArr, array_diff($tr['en'])); + } +} ?> From f353bc294ddb51b1db6c46fd2ce5fe6c176e7d63 Mon Sep 17 00:00:00 2001 From: EV-soft <21997911+EV-soft@users.noreply.github.com> Date: Mon, 16 Mar 2026 13:43:55 +0100 Subject: [PATCH 3/3] Update tinyfilemanager.php --- tinyfilemanager.php | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/tinyfilemanager.php b/tinyfilemanager.php index 70ffa5c9..16a92cf3 100644 --- a/tinyfilemanager.php +++ b/tinyfilemanager.php @@ -5681,5 +5681,5 @@ function arrPretty($arrVar,$titl='',$attr='rows="10" cols="120"',$wdth='50%',$rt $ar= array_merge($newArr, array_diff($tr['en'])); } } - + ?>