]> git.immae.eu Git - github/shaarli/Shaarli.git/blobdiff - application/Languages.php
Merge pull request #1096 from ArthurHoaro/feature/download-params
[github/shaarli/Shaarli.git] / application / Languages.php
index 4ba32f29384d55490af8db47d5416de615216f80..3eb3388f48f6a01ac87c872c408018c9c574cdec 100644 (file)
@@ -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'),
+        ];
+    }
 }