diff options
author | Corey Hulen <corey@hulen.com> | 2016-01-21 09:48:37 -0600 |
---|---|---|
committer | Corey Hulen <corey@hulen.com> | 2016-01-21 09:48:37 -0600 |
commit | 5b2b5828903b70bafcd81d2f216a3770c1e05202 (patch) | |
tree | ca960da2c65ac9ba493ef4eed3341f2f7f9b1880 /utils | |
parent | 302f210d66fd0850852aa2e636df14509688ee18 (diff) | |
parent | c8d22ed1fba591e7a6b18afc5e6a6d541c11645c (diff) | |
download | chat-5b2b5828903b70bafcd81d2f216a3770c1e05202.tar.gz chat-5b2b5828903b70bafcd81d2f216a3770c1e05202.tar.bz2 chat-5b2b5828903b70bafcd81d2f216a3770c1e05202.zip |
Merge pull request #1940 from ZBoxApp/PLT-7-go
Refactoring api to use translations (chunk 1)
Diffstat (limited to 'utils')
-rw-r--r-- | utils/i18n.go | 15 |
1 files changed, 8 insertions, 7 deletions
diff --git a/utils/i18n.go b/utils/i18n.go index 4fc8c725a..4b7b187a8 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 + "'") - } + if locales[model.DEFAULT_LOCALE] == "" { + panic("Failed to load system translations for '" + model.DEFAULT_LOCALE + "'") } translations, _ := i18n.Tfunc(locale) |