summaryrefslogtreecommitdiffstats
path: root/utils
diff options
context:
space:
mode:
Diffstat (limited to 'utils')
-rw-r--r--utils/config.go3
-rw-r--r--utils/i18n.go36
2 files changed, 26 insertions, 13 deletions
diff --git a/utils/config.go b/utils/config.go
index 12d03b5de..c2ae1f7a0 100644
--- a/utils/config.go
+++ b/utils/config.go
@@ -223,5 +223,8 @@ func getClientConfig(c *model.Config) map[string]string {
props["EnableLdap"] = strconv.FormatBool(*c.LdapSettings.Enable)
+ props["WebsocketPort"] = fmt.Sprintf("%v", *c.ServiceSettings.WebsocketPort)
+ props["WebsocketSecurePort"] = fmt.Sprintf("%v", *c.ServiceSettings.WebsocketSecurePort)
+
return props
}
diff --git a/utils/i18n.go b/utils/i18n.go
index 4fc8c725a..e02fee558 100644
--- a/utils/i18n.go
+++ b/utils/i18n.go
@@ -36,15 +36,16 @@ func InitTranslations() {
func GetTranslationsBySystemLocale() i18n.TranslateFunc {
locale := model.DEFAULT_LOCALE
if userLanguage, err := jibber_jabber.DetectLanguage(); err == nil {
- locale = userLanguage
+ if _, ok := locales[userLanguage]; ok {
+ locale = userLanguage
+ } else {
+ l4g.Error("Failed to load system translations for '%v' attempting to fall back to '%v'", locale, model.DEFAULT_LOCALE)
+ locale = model.DEFAULT_LOCALE
+ }
}
if locales[locale] == "" {
- l4g.Error("Failed to load system translations for '%v' attempting to fall back to '%v'", locale, model.DEFAULT_LOCALE)
-
- if locales[model.DEFAULT_LOCALE] == "" {
- panic("Failed to load system translations for '" + model.DEFAULT_LOCALE + "'")
- }
+ panic("Failed to load system translations for '" + model.DEFAULT_LOCALE + "'")
}
translations, _ := i18n.Tfunc(locale)
@@ -56,19 +57,28 @@ func GetTranslationsBySystemLocale() i18n.TranslateFunc {
return translations
}
-func SetTranslations(locale string) i18n.TranslateFunc {
+func GetUserTranslations(locale string) i18n.TranslateFunc {
+ if _, ok := locales[locale]; !ok {
+ locale = model.DEFAULT_LOCALE
+ }
+
translations, _ := i18n.Tfunc(locale)
return translations
}
-func GetTranslations(w http.ResponseWriter, r *http.Request) i18n.TranslateFunc {
- translations, _ := getTranslationsAndLocale(w, r)
+func SetTranslations(locale string) i18n.TranslateFunc {
+ translations, _ := i18n.Tfunc(locale)
return translations
}
-func GetTranslationsAndLocale(w http.ResponseWriter, r *http.Request) (i18n.TranslateFunc, string) {
- return getTranslationsAndLocale(w, r)
-}
+// func GetTranslations(w http.ResponseWriter, r *http.Request) i18n.TranslateFunc {
+// translations, _ := getTranslationsAndLocale(w, r)
+// return translations
+// }
+
+// func GetTranslationsAndLocale(w http.ResponseWriter, r *http.Request) (i18n.TranslateFunc, string) {
+// return getTranslationsAndLocale(w, r)
+// }
func SetLocaleCookie(w http.ResponseWriter, lang string, sessionCacheInMinutes int) {
maxAge := (sessionCacheInMinutes * 60)
@@ -115,7 +125,7 @@ func SetLocaleCookie(w http.ResponseWriter, lang string, sessionCacheInMinutes i
// })
// }
-func getTranslationsAndLocale(w http.ResponseWriter, r *http.Request) (i18n.TranslateFunc, string) {
+func GetTranslationsAndLocale(w http.ResponseWriter, r *http.Request) (i18n.TranslateFunc, string) {
var translations i18n.TranslateFunc
var _ error
localeCookie := ""