1<?php 2 3/* 4 5 This script tries to guess what language to use for 6 language dependent operations (lookup, search, books 7 page display, etc.), considering all possible factors 8 affecting language selection. 9 10 After this script run, $LANG is set to the preferred 11 language, or is the empty string, if no manual is 12 available on the current mirror site. 13 14 $EXPL_LANG will also be set to the explicitly provided 15 language, or will not exist if there are only implications 16 on the preferred language. 17 18 $UA_LANGS will contain the user agent language settings 19 parsed as an array. The language names are corrected for 20 php.net usage in this array. This is just to present to 21 the user in case he would like to get information on the 22 parsed language information (see /my.php). 23 24 The $_SERVER['STRIPPED_URI'] var is also set to the 25 stripped request URI (in case of a shortcut, the 26 language is stipped, so the shortcut handling code 27 is not bothered with it). 28 29*/ 30 31use phpweb\I18n\Languages; 32use phpweb\LangChooser; 33 34require_once __DIR__ . '/../src/autoload.php'; 35 36// Default STRIPPED_URI 37$_SERVER['STRIPPED_URI'] = htmlspecialchars($_SERVER['REQUEST_URI'], ENT_QUOTES, 'UTF-8'); 38 39// The code is encapsulated in a function, 40// so the variable namespace is not polluted 41list($LANG, $EXPL_LANG) = (new LangChooser(Languages::LANGUAGES, Languages::INACTIVE_ONLINE_LANGUAGES, $userPreferences->languageCode, default_language() ?: ''))->chooseCode( 42 $_REQUEST['lang'] ?? null, 43 $_SERVER['REQUEST_URI'], 44 $_SERVER['HTTP_ACCEPT_LANGUAGE'] ?? null, 45); 46 47// Compatibility 48if ($EXPL_LANG == '') { unset($EXPL_LANG); } 49