🏗️ microservice fabric splitting
This commit is contained in:
17
common/i18n/parse.go
Normal file
17
common/i18n/parse.go
Normal file
@@ -0,0 +1,17 @@
|
||||
package i18n
|
||||
|
||||
import "golang.org/x/text/language"
|
||||
|
||||
func MatchCurrentLanguageTag(accept string, supportTags []language.Tag) language.Tag {
|
||||
langTags, _, err := language.ParseAcceptLanguage(accept)
|
||||
if err != nil {
|
||||
langTags = []language.Tag{language.Chinese}
|
||||
}
|
||||
var matcher = language.NewMatcher(supportTags)
|
||||
_, i, _ := matcher.Match(langTags...)
|
||||
tag := supportTags[i]
|
||||
if tag == language.Und {
|
||||
tag = language.Chinese
|
||||
}
|
||||
return tag
|
||||
}
|
Reference in New Issue
Block a user