diff options
Diffstat (limited to 'utils')
-rw-r--r-- | utils/i18n.go | 14 |
1 files changed, 13 insertions, 1 deletions
diff --git a/utils/i18n.go b/utils/i18n.go index 4fc8c725a..0f9b65617 100644 --- a/utils/i18n.go +++ b/utils/i18n.go @@ -36,7 +36,10 @@ func InitTranslations() { func GetTranslationsBySystemLocale() i18n.TranslateFunc { locale := model.DEFAULT_LOCALE if userLanguage, err := jibber_jabber.DetectLanguage(); err == nil { - locale = userLanguage + // only set the system locale if is supported, fallback to DEFAULT_LOCALE + if contains(userLanguage) { + locale = userLanguage + } } if locales[locale] == "" { @@ -138,3 +141,12 @@ func getTranslationsAndLocale(w http.ResponseWriter, r *http.Request) (i18n.Tran SetLocaleCookie(w, model.DEFAULT_LOCALE, 10) return translations, model.DEFAULT_LOCALE } + +func contains(l string) bool { + for _, a := range locales { + if a == l { + return true + } + } + return false +} |