Browse Source

Sort locales according to their names (#18211)

* Sort locales according to their names

* Fix documentation and sort case insensitive
tags/v1.16.0-rc1
delvh 2 years ago
parent
commit
4f7764561a
No account linked to committer's email address
1 changed files with 9 additions and 1 deletions
  1. 9
    1
      modules/translation/translation.go

+ 9
- 1
modules/translation/translation.go View File

package translation package translation


import ( import (
"sort"
"strings"

"code.gitea.io/gitea/modules/log" "code.gitea.io/gitea/modules/log"
"code.gitea.io/gitea/modules/options" "code.gitea.io/gitea/modules/options"
"code.gitea.io/gitea/modules/setting" "code.gitea.io/gitea/modules/setting"
supportedTags []language.Tag supportedTags []language.Tag
) )


// AllLangs returns all supported langauages
// AllLangs returns all supported languages sorted by name
func AllLangs() []LangType { func AllLangs() []LangType {
return allLangs return allLangs
} }
for i, v := range langs { for i, v := range langs {
allLangs = append(allLangs, LangType{v, names[i]}) 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 // Match matches accept languages

Loading…
Cancel
Save