[www-doc] [Git][VideoLAN.org/websites][master] Replace hardcoded list of languages with a dynamic list from filesystem

Konstantin Pavlov gitlab at videolan.org
Fri Mar 26 21:04:12 UTC 2021



Konstantin Pavlov pushed to branch master at VideoLAN organization / websites


Commits:
1f6df714 by Konstantin Pavlov at 2021-03-27T00:03:36+03:00
Replace hardcoded list of languages with a dynamic list from filesystem

- - - - -


1 changed file:

- www.videolan.org/include/language.php


Changes:

=====================================
www.videolan.org/include/language.php
=====================================
@@ -1,95 +1,18 @@
 <?php
-$alternate_lang = array(
-    "af",
-    "am",
-    "an",
-    "ar",
-    "as-IN",
-    "ast",
-    "az",
-    "be",
-    "bg",
-    "bn",
-    "bn-IN",
-    "br",
-    "bs",
-    "ca",
-    "co",
-    "cs",
-    "cy",
-    "da",
-    "de",
-    "dv",
-    "el",
-    "en",
-    "en-GB",
-    "es",
-    "es-MX",
-    "et",
-    "eu",
-    "fa",
-    "fi",
-    "fo",
-    "fr",
-    "fy",
-    "ga",
-    "gd",
-    "gl",
-    "gu",
-    "he",
-    "hi",
-    "hr",
-    "hu",
-    "id",
-    "is",
-    "it",
-    "ja",
-    "ka",
-    "km",
-    "kn",
-    "ko",
-    "ky",
-    "lb",
-    "lo",
-    "lt",
-    "lv",
-    "mk",
-    "ml",
-    "mn",
-    "mr",
-    "ms",
-    "my",
-    "my-MM",
-    "nb",
-    "ne",
-    "nl",
-    "nn",
-    "or",
-    "pl",
-    "pt",
-    "pt-BR",
-    "ro",
-    "ru",
-    "sc",
-    "si",
-    "sk",
-    "sl",
-    "sq",
-    "sr",
-    "sv",
-    "ta",
-    "te",
-    "th",
-    "tr",
-    "tt",
-    "ug",
-    "uk",
-    "ur",
-    "uz",
-    "vi",
-    "wa",
-    "zh",
-    "zh-TW"
-);
+
+$alternate_lang = array();
+
+if ( $handle = opendir( $_SERVER["DOCUMENT_ROOT"]."/locale/" ) ) {
+    while ( false !== ( $file = readdir( $handle ) ) ) {
+        if ( $file === "." ) { continue; }
+        if ( $file === ".." ) { continue; }
+        if ( is_dir( $_SERVER["DOCUMENT_ROOT"]."/locale/".$file ) ) {
+            array_push( $alternate_lang, $file );
+        }
+    }
+    closedir($handle);
+}
+
+sort( $alternate_lang );
 
 ?>



View it on GitLab: https://code.videolan.org/VideoLAN.org/websites/-/commit/1f6df714bd17aee9f6a8d47a652ff8c18aa6f3ff

-- 
View it on GitLab: https://code.videolan.org/VideoLAN.org/websites/-/commit/1f6df714bd17aee9f6a8d47a652ff8c18aa6f3ff
You're receiving this email because of your account on code.videolan.org.




More information about the www-doc mailing list