. */ require_once(ROOT_DIR . "/helpers/config.php"); /** * Localization */ class uLang { /** * Available languages * * @var array */ private static $languages = [ "cs" => "Čeština", "de" => "Deutsch", "en" => "English", "es" => "Español", "fr" => "Français", "it" => "Italiano", "hu" => "Magyar", "nl" => "Nederlands", "pl" => "Polski", "ru" => "Русский", "zh" => "中文" ]; /** * Application strings * Array of key => translation pairs * * @var array */ private $strings = []; /** * Setup script strings * Array of key => translation pairs * * @var array */ private $setupStrings = []; /** * Constructor * * @param string $language Language code (IANA) */ public function __construct($language = "en") { $lang = []; $langSetup = []; // always load en base require(ROOT_DIR . "/lang/en.php"); // override with translated strings if needed // missing strings will be displayed in English if ($language != "en" && array_key_exists($language, self::$languages)) { require(ROOT_DIR . "/lang/$language.php"); } // choose password messages based on config $lang['passrules'] = isset($lang["passrules_" . uConfig::$pass_strength]) ? $lang["passrules_" . uConfig::$pass_strength] : ""; $lang['passlenmin'] = sprintf($lang["passlenmin"], uConfig::$pass_lenmin); $this->strings = $lang; $this->setupStrings = $langSetup; } /** * Get supported languages array * Language code => Native language name * * @return array */ public static function getLanguages() { return self::$languages; } /** * Get translated strings array * Key => translation string * * @return array */ public function getStrings() { return $this->strings; } /** * Get translated strings array for setup script * Key => translation string * * @return array */ public function getSetupStrings() { return $this->setupStrings; } } ?>