summaryrefslogtreecommitdiffstats
path: root/modules/translation/translation.go
diff options
context:
space:
mode:
Diffstat (limited to 'modules/translation/translation.go')
-rw-r--r--modules/translation/translation.go16
1 files changed, 9 insertions, 7 deletions
diff --git a/modules/translation/translation.go b/modules/translation/translation.go
index dec48c7a65..77cc9ac7f5 100644
--- a/modules/translation/translation.go
+++ b/modules/translation/translation.go
@@ -25,8 +25,9 @@ type LangType struct {
}
var (
- matcher language.Matcher
- allLangs []LangType
+ matcher language.Matcher
+ allLangs []LangType
+ supportedTags []language.Tag
)
// AllLangs returns all supported langauages
@@ -50,12 +51,12 @@ func InitLocales() {
}
}
- tags := make([]language.Tag, len(setting.Langs))
+ supportedTags = make([]language.Tag, len(setting.Langs))
for i, lang := range setting.Langs {
- tags[i] = language.Raw.Make(lang)
+ supportedTags[i] = language.Raw.Make(lang)
}
- matcher = language.NewMatcher(tags)
+ matcher = language.NewMatcher(supportedTags)
for i := range setting.Names {
key := "locale_" + setting.Langs[i] + ".ini"
if err = i18n.SetMessageWithDesc(setting.Langs[i], setting.Names[i], localFiles[key]); err != nil {
@@ -73,8 +74,9 @@ func InitLocales() {
}
// Match matches accept languages
-func Match(tags ...language.Tag) (tag language.Tag, index int, c language.Confidence) {
- return matcher.Match(tags...)
+func Match(tags ...language.Tag) language.Tag {
+ _, i, _ := matcher.Match(tags...)
+ return supportedTags[i]
}
// locale represents the information of localization.