diff --git a/app/modules/UtilsModule.php b/app/modules/UtilsModule.php index f47c2e7..11c24e8 100644 --- a/app/modules/UtilsModule.php +++ b/app/modules/UtilsModule.php @@ -248,13 +248,50 @@ class UtilsModule { $files = scandir(app_path('/lang')); foreach ($files as $file) { if (substr($file, 0, 1) !== '.') { - $result[] = ['ident' => $file, 'name' => locale_get_display_language($file, static::getLanguage())]; + $result[] = [ + 'ident' => $file, + 'name' => locale_get_display_language($file, static::getLanguage()), + 'region' => locale_get_display_region($file, static::getLanguage()) + ]; } } return $result; } + /** + * @return array + */ + public static function getLabeledLanguageList() + { + $result = []; + + $list = static::getLanguageList(); + $duplicates = []; + + foreach ($list as $item) { + if (isset($duplicates[$item['name']])) { + $duplicates[$item['name']]++; + } else { + $duplicates[$item['name']] = 0; + } + } + + foreach ($list as $item) { + $entry = $item; + + if ($duplicates[$item['name']] > 0) { + $entry['label'] = $item['name'] . ' (' . $item['region'] . ')'; + } else { + $entry['label'] = $item['name']; + } + + $result[] = $entry; + } + + return $result; + } + /** * @return bool */ diff --git a/app/views/layout.php b/app/views/layout.php index 9589fe0..1c18c56 100644 --- a/app/views/layout.php +++ b/app/views/layout.php @@ -949,8 +949,8 @@