mirror of
https://github.com/danielbrendel/hortusfox-web.git
synced 2026-05-05 21:29:30 -05:00
Resolves #387
This commit is contained in:
@@ -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
|
||||
*/
|
||||
|
||||
@@ -949,8 +949,8 @@
|
||||
<label class="label">{{ __('app.language') }}</label>
|
||||
<div class="control">
|
||||
<select class="input" name="lang" id="selEditCombo">
|
||||
@foreach (UtilsModule::getLanguageList() as $lang)
|
||||
<option value="{{ $lang['ident'] }}" {{ (UtilsModule::getLanguage() === $lang['ident']) ? 'selected' : ''}}>{{ $lang['name'] }}</option>
|
||||
@foreach (UtilsModule::getLabeledLanguageList() as $lang)
|
||||
<option value="{{ $lang['ident'] }}" {{ (UtilsModule::getLanguage() === $lang['ident']) ? 'selected' : ''}}>{{ $lang['label'] }}</option>
|
||||
@endforeach
|
||||
</select>
|
||||
</div>
|
||||
|
||||
Reference in New Issue
Block a user