diff options
author | delvh <leon@kske.dev> | 2022-01-08 13:18:39 +0100 |
---|---|---|
committer | GitHub <noreply@github.com> | 2022-01-08 12:18:39 +0000 |
commit | 4f7764561a31c89b7b1097436d64fee4ded4a77c (patch) | |
tree | 08599896a4ee84f825b698e131d28e382464fcb1 | |
parent | 832f987d80d0eb1dca8fb764359e8fe5d2fbbb57 (diff) | |
download | gitea-4f7764561a31c89b7b1097436d64fee4ded4a77c.tar.gz gitea-4f7764561a31c89b7b1097436d64fee4ded4a77c.zip |
Sort locales according to their names (#18211)
* Sort locales according to their names
* Fix documentation and sort case insensitive
-rw-r--r-- | modules/translation/translation.go | 10 |
1 files changed, 9 insertions, 1 deletions
diff --git a/modules/translation/translation.go b/modules/translation/translation.go index af1e5d25df..2dce6e16b9 100644 --- a/modules/translation/translation.go +++ b/modules/translation/translation.go @@ -5,6 +5,9 @@ package translation import ( + "sort" + "strings" + "code.gitea.io/gitea/modules/log" "code.gitea.io/gitea/modules/options" "code.gitea.io/gitea/modules/setting" @@ -31,7 +34,7 @@ var ( supportedTags []language.Tag ) -// AllLangs returns all supported langauages +// AllLangs returns all supported languages sorted by name func AllLangs() []LangType { return allLangs } @@ -72,6 +75,11 @@ func InitLocales() { for i, v := range langs { allLangs = append(allLangs, LangType{v, names[i]}) } + + // Sort languages case insensitive according to their name - needed for the user settings + sort.Slice(allLangs, func(i, j int) bool { + return strings.ToLower(allLangs[i].Name) < strings.ToLower(allLangs[j].Name) + }) } // Match matches accept languages |