From b08718fcc3b422b1146d07172864f1742b014f12 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Bal=C3=A1zs=20=C3=9Ar?= Date: Wed, 5 Jan 2022 00:33:04 +0100 Subject: [PATCH] Add native language names to language selector --- src/Core/L10n.php | 34 +++++++++++++++++++++++++++++++--- 1 file changed, 31 insertions(+), 3 deletions(-) diff --git a/src/Core/L10n.php b/src/Core/L10n.php index 90d4c0fe5..33c670443 100644 --- a/src/Core/L10n.php +++ b/src/Core/L10n.php @@ -340,9 +340,10 @@ class L10n * * Scans the view/lang directory for the existence of "strings.php" files, and * returns an alphabetical list of their folder names (@-char language codes). - * Adds the english language if it's missing from the list. + * Adds the english language if it's missing from the list. Folder names are + * replaced by nativ language names. * - * Ex: array('de' => 'de', 'en' => 'en', 'fr' => 'fr', ...) + * Ex: array('de' => 'Deutsch', 'en' => 'English', 'fr' => 'Français', ...) * * @return array */ @@ -350,6 +351,33 @@ class L10n { $langs = []; $strings_file_paths = glob('view/lang/*/strings.php'); + $lang_names = [ + 'ar' => 'العربية', + 'bg' => 'Български', + 'ca' => 'Català', + 'cs' => 'Česky', + 'de' => 'Deutsch', + 'en-gb' => 'English (United Kingdom)', + 'en-us' => 'English (United States)', + 'en' => 'English (Default)', + 'eo' => 'Esperanto', + 'es' => 'Español', + 'et' => 'Eesti', + 'fi-fi' => 'Suomi', + 'fr' => 'Français', + 'hu' => 'Magyar', + 'is' => 'Íslenska', + 'it' => 'Italiano', + 'ja' => '日本語', + 'nb-no' => 'Norsk bokmål', + 'nl' => 'Nederlands', + 'pl' => 'Polski', + 'pt-br' => 'Português Brasileiro', + 'ro' => 'Română', + 'ru' => 'Русский', + 'sv' => 'Svenska', + 'zh-cn' => '简体中文', + ]; if (is_array($strings_file_paths) && count($strings_file_paths)) { if (!in_array('view/lang/en/strings.php', $strings_file_paths)) { @@ -358,7 +386,7 @@ class L10n asort($strings_file_paths); foreach ($strings_file_paths as $strings_file_path) { $path_array = explode('/', $strings_file_path); - $langs[$path_array[2]] = $path_array[2]; + $langs[$path_array[2]] = isset($lang_names[$path_array[2]]) ? $lang_names[$path_array[2]] : $path_array[2]; } } return $langs;