diff --git a/install/assets/css/overrides.css b/install/assets/css/overrides.css index 84d96320b..d75390c6d 100644 --- a/install/assets/css/overrides.css +++ b/install/assets/css/overrides.css @@ -204,3 +204,9 @@ div.alert-danger { --bs-tooltip-max-width: 400px; --bs-tooltip-opacity: 1; } + +#languageButton { + position: absolute; + bottom: 70px; + right: 20px; +} \ No newline at end of file diff --git a/install/includes/gettext/gettext_conf.php b/install/includes/gettext/gettext_conf.php index 514672841..88e5302bd 100644 --- a/install/includes/gettext/gettext_conf.php +++ b/install/includes/gettext/gettext_conf.php @@ -14,6 +14,8 @@ $gt_conf['default_domain'] = 'installer'; $gt_conf['default_lang'] = 'english'; +$gt_conf['lang_cookie'] = 'install_lang'; + $gt_conf['languages'] = array( 'bulgarian' => array( diff --git a/install/index.php b/install/index.php index e42183366..e8b870370 100644 --- a/install/index.php +++ b/install/index.php @@ -18,20 +18,32 @@ if (file_exists('config_unattended.php')) { return; } -// ######################################################### -// Gettext Implementation -// ######################################################### - -require_once('includes/gettext/gettext.php'); -require_once('includes/gettext/gettext_conf.php'); - -$language = _get_client_language(); -T_setlocale(LC_MESSAGES, $language['gettext']); - // ######################################################### // PRECONFIGURATION // ######################################################### +function is_https() { + if (isset($_SERVER['HTTPS']) && $_SERVER['HTTPS'] === 'on') { + return true; + } + if (!empty($_SERVER['HTTP_X_FORWARDED_PROTO']) && $_SERVER['HTTP_X_FORWARDED_PROTO'] === 'https') { + return true; + } + if (!empty($_SERVER['HTTP_X_FORWARDED_SSL']) && $_SERVER['HTTP_X_FORWARDED_SSL'] === 'on') { + return true; + } + return false; +} + +if (is_https()) { + $html_scheme = "https"; +} else { + $html_scheme = "http"; +} + +global $installer_url; +$installer_url = $html_scheme . '://' . $_SERVER['HTTP_HOST'] . '/' . substr(str_replace(["index.php", "/install/"], "", $_SERVER['REQUEST_URI']), 1) . '/install'; + // Config Paths $db_config_path = '../application/config/'; if (isset($_ENV['CI_ENV'])) { @@ -64,6 +76,38 @@ $required_php_modules = [ $mariadb_version = 10.1; $mysql_version = 5.7; +// ######################################################### +// Gettext Implementation +// ######################################################### + +// include the lib and the conf file +require_once('includes/gettext/gettext.php'); +require_once('includes/gettext/gettext_conf.php'); + +// if we come with a get call we can switch the language cookie +if (isset($_GET['lang'])) { + switch_lang($_GET['lang']); +} + +// get the browsers language if no cookie exists and set one +if (!isset($_COOKIE[$gt_conf['lang_cookie']])) { + $browser_language = _get_client_language(); + setcookie($gt_conf['lang_cookie'], $browser_language['gettext']); +} +// get the language from the cookie +$language = $_COOKIE[$gt_conf['lang_cookie']]; + +// and set the locale for gettext +T_setlocale(LC_MESSAGES, $language); + +// function to switch the language based on the user selection +function switch_lang($new_language) { + global $gt_conf, $installer_url; + setcookie($gt_conf['lang_cookie'], $new_language); + header("Location: " . $installer_url); + exit(); +} + // ######################################################### END OF PRECONFIGURATION // Function to check if a PHP extension is installed @@ -86,25 +130,6 @@ function delDir($dir) { } } -function is_https() { - if (isset($_SERVER['HTTPS']) && $_SERVER['HTTPS'] === 'on') { - return true; - } - if (!empty($_SERVER['HTTP_X_FORWARDED_PROTO']) && $_SERVER['HTTP_X_FORWARDED_PROTO'] === 'https') { - return true; - } - if (!empty($_SERVER['HTTP_X_FORWARDED_SSL']) && $_SERVER['HTTP_X_FORWARDED_SSL'] === 'on') { - return true; - } - return false; -} - -if (is_https()) { - $html_scheme = "https"; -} else { - $html_scheme = "http"; -} - if (file_exists($db_file_path)) { delDir(getcwd()); header("../"); @@ -175,7 +200,7 @@ global $wavelog_url; ?> - +
@@ -240,6 +265,12 @@ global $wavelog_url;= __("This installer will guide you through the necessary steps for the installation of Wavelog.
Wavelog is a powerful web-based amateur radio logging software. Follow the steps in each tab to configure and install Wavelog on your server."); ?>
= sprintf(__("If you encounter any issues or have questions, refer to the documentation (%s) or community forum (%s) on Github for assistance."), "" . __("Wiki") . "", "" . __("Discussions") . ""); ?>
= __("Thank you for installing Wavelog!"); ?>
+ + = $lang_html; ?> @@ -1497,20 +1528,20 @@ Add english Language Name here if you add new languages to application/config/ge This helps the po scanner --> \ No newline at end of file