X-Git-Url: https://git.immae.eu/?a=blobdiff_plain;f=application%2FLanguages.php;h=3eb3388f48f6a01ac87c872c408018c9c574cdec;hb=06ca7c102ba058d99f19e614023c539dbdb58b36;hp=4ba32f29384d55490af8db47d5416de615216f80;hpb=12266213d098a53c5f005b9afcbbe62771fd580c;p=github%2Fshaarli%2FShaarli.git diff --git a/application/Languages.php b/application/Languages.php index 4ba32f29..3eb3388f 100644 --- a/application/Languages.php +++ b/application/Languages.php @@ -62,13 +62,15 @@ class Languages /** * Languages constructor. * - * @param string $language lang determined by autoLocale(), can be override. + * @param string $language lang determined by autoLocale(), can be overridden. * @param ConfigManager $conf instance. */ public function __construct($language, $conf) { $this->conf = $conf; $confLanguage = $this->conf->get('translation.language', 'auto'); + // Auto mode or invalid parameter, use the detected language. + // If the detected language is invalid, it doesn't matter, it will use English. if ($confLanguage === 'auto' || ! $this->isValidLanguage($confLanguage)) { $this->language = substr($language, 0, 5); } else { @@ -147,4 +149,18 @@ class Languages { return preg_match('/^[a-z]{2}(_[A-Z]{2})?/', $language) === 1; } + + /** + * Get the list of available languages for Shaarli. + * + * @return array List of available languages, with their label. + */ + public static function getAvailableLanguages() + { + return [ + 'auto' => t('Automatic'), + 'en' => t('English'), + 'fr' => t('French'), + ]; + } }