mirror of
				https://github.com/go-gitea/gitea
				synced 2025-11-04 05:18:25 +00:00 
			
		
		
		
	Sort locales according to their names (#18211)
* Sort locales according to their names * Fix documentation and sort case insensitive
This commit is contained in:
		@@ -5,6 +5,9 @@
 | 
				
			|||||||
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"
 | 
				
			||||||
@@ -31,7 +34,7 @@ var (
 | 
				
			|||||||
	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
 | 
				
			||||||
}
 | 
					}
 | 
				
			||||||
@@ -72,6 +75,11 @@ func InitLocales() {
 | 
				
			|||||||
	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
 | 
				
			||||||
 
 | 
				
			|||||||
		Reference in New Issue
	
	Block a user