getById($_SESSION['php-censor-user-id']); } if ($user) { $language = $user->getLanguage(); if ($user && self::setLanguage($language)) { return; } } // Try the installation default language: $language = $config->get('php-censor.language', self::DEFAULT_LANGUAGE); if (self::setLanguage($language)) { return; } } /** * Load a specific language file. * * @param string $language * * @return string[]|null */ protected static function loadLanguage($language = null) { $language = $language ? $language : self::$language; $langFile = SRC_DIR . 'Languages/lang.' . $language . '.php'; if (!file_exists($langFile)) { return null; } $strings = include($langFile); if (is_null($strings) || !is_array($strings) || !count($strings)) { return null; } return $strings; } /** * Load the names of all available languages. */ protected static function loadAvailableLanguages() { $matches = []; foreach (glob(SRC_DIR . 'Languages/lang.*.php') as $file) { if (preg_match('/lang\.([a-z]{2}\-?[a-z]*)\.php/', $file, $matches)) { self::$languages[] = $matches[1]; } } } }