Merge pull request #18638 from owncloud/issue-18141-sort-languages-with-names-before-code-only

Sort languages with a name before those with language code only
This commit is contained in:
Jan-Christoph Borchardt 2015-08-28 20:06:31 +02:00
commit dc04b618bc
1 changed files with 9 additions and 0 deletions

View File

@ -95,6 +95,15 @@ ksort($commonlanguages);
// sort now by displayed language not the iso-code // sort now by displayed language not the iso-code
usort( $languages, function ($a, $b) { usort( $languages, function ($a, $b) {
if ($a['code'] === $a['name'] && $b['code'] !== $b['name']) {
// If a doesn't have a name, but b does, list b before a
return 1;
}
if ($a['code'] !== $a['name'] && $b['code'] === $b['name']) {
// If a does have a name, but b doesn't, list a before b
return -1;
}
// Otherwise compare the names
return strcmp($a['name'], $b['name']); return strcmp($a['name'], $b['name']);
}); });