From 2849e973118a5e9677a306c002543dfd8622f98c Mon Sep 17 00:00:00 2001 From: Fraenkiman Date: Sun, 29 Jan 2023 02:06:29 +0100 Subject: [PATCH] Setup should use the user's browser language. This closes issue #197 Please check if it works with php8.1. Tested with php 7.4 Update main.php 'el-gr','es-es','fr-fr' removed as browser language, because the FlatPress setup currently has no language files for it Update lang.de-de.php Update main.php some code formatting --- setup/lang/lang.de-de.php | 2 +- setup/main.php | 70 +++++++++++++++++++++++++++++++++++---- 2 files changed, 65 insertions(+), 7 deletions(-) diff --git a/setup/lang/lang.de-de.php b/setup/lang/lang.de-de.php index ddde6df..73aaeaf 100644 --- a/setup/lang/lang.de-de.php +++ b/setup/lang/lang.de-de.php @@ -63,7 +63,7 @@ $lang ['step3'] = array( ); $lang ['buttonbar'] = array( - 'next' => 'Next >' + 'next' => 'Weiter >' ); $lang ['samplecontent'] = array(); diff --git a/setup/main.php b/setup/main.php index 37cc5b8..38187d7 100644 --- a/setup/main.php +++ b/setup/main.php @@ -1,6 +1,66 @@ - $intCurrentQ) { + $strCurrentLanguage = strtolower (join ('-', $arrLangCode)); + $intCurrentQ = $intLangQuality; + break; + } + } + if ($boolStrictMode) break; + array_pop ($arrLangCode); + } + } + return $strCurrentLanguage; +} -$language = @$_POST['language']? $_POST['language'] :'en-us'; +// accept the following languages, otherwise fall back to "en-us" +$browserLang = getBrowserLanguage(array('cs-cz', 'de-de', 'en-us', 'it-it', 'ja-jp', 'nl-nl', 'pt-br'), 'en-us'); + +$language = @$_POST ['language']? $_POST ['language'] : $browserLang; $lf = "lang.$language.php"; if (!preg_match('|^lang\.[a-z]{2}-[a-z]{2}\.php$|', $lf)) @@ -13,12 +73,10 @@ $step = null; $id = getstep($step); -$l =& $lang[$step]; - +$l =& $lang [$step]; include("./setup/tpls/header.tpl.php"); include("./setup/tpls/{$step}.tpl.php"); include("./setup/tpls/footer.tpl.php"); - -?> \ No newline at end of file +?>