Ejemplo n.º 1
0
func (d *JibberJabberDetector) DetectLanguage() string {
	lang, err := jibber_jabber.DetectLanguage()
	if err != nil {
		lang = ""
	}
	return lang
}
Ejemplo n.º 2
0
func GetTranslationsBySystemLocale() i18n.TranslateFunc {
	locale := model.DEFAULT_LOCALE
	if userLanguage, err := jibber_jabber.DetectLanguage(); err == nil {
		locale = userLanguage
	}

	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 + "'")
		}
	}

	translations, _ := i18n.Tfunc(locale)
	if translations == nil {
		panic("Failed to load system translations")
	}

	l4g.Info(translations("utils.i18n.loaded"), locale, locales[locale])
	return translations
}