diff --git a/contrib/backends/srndv2/src/srnd/i18n.go b/contrib/backends/srndv2/src/srnd/i18n.go index c8e43b5..2d6566f 100644 --- a/contrib/backends/srndv2/src/srnd/i18n.go +++ b/contrib/backends/srndv2/src/srnd/i18n.go @@ -7,6 +7,7 @@ import ( "log" "path/filepath" "strings" + "errors" ) type I18N struct { @@ -22,6 +23,7 @@ type I18N struct { } var I18nProvider *I18N = nil +var ErrNoLang = errors.New("no such language") //Read all .ini files in dir, where the filenames are BCP 47 tags //Use the language matcher to get the best match for the locale preference @@ -41,17 +43,23 @@ func NewI18n(locale, dir string) (*I18N, error) { return nil, err } + found:= false serverLangs := make([]language.Tag, 1) - serverLangs[0] = language.AmericanEnglish // en-US fallback + // serverLangs[0] = language.AmericanEnglish // en-US fallback for _, file := range files { if filepath.Ext(file.Name()) == ".ini" { name := strings.TrimSuffix(file.Name(), ".ini") tag, err := language.Parse(name) if err == nil { serverLangs = append(serverLangs, tag) + found = true; } } } + if !found { + return nil, ErrNoLang + } + matcher := language.NewMatcher(serverLangs) tag, _, _ := matcher.Match(pref) diff --git a/contrib/backends/srndv2/src/srnd/null_cache.go b/contrib/backends/srndv2/src/srnd/null_cache.go index 8011296..a9722cd 100644 --- a/contrib/backends/srndv2/src/srnd/null_cache.go +++ b/contrib/backends/srndv2/src/srnd/null_cache.go @@ -51,6 +51,7 @@ func (self *nullHandler) GetI18N(r *http.Request) *I18N { i, err = NewI18n(lang, self.translations) if err != nil { log.Println(err) + return nil } if i != nil { self.i18n[lang] = i @@ -64,7 +65,10 @@ func (self *nullHandler) ServeHTTP(w http.ResponseWriter, r *http.Request) { sfw := strings.Count(r.URL.RawQuery, "sfw=1") > 0 i18n := self.GetI18N(r) - + if i18n == nil { + http.Redirect(w, r, r.URL.Path, http.StatusFound) + return + } path := r.URL.Path _, file := filepath.Split(path) diff --git a/contrib/static/krane.css b/contrib/static/krane.css index 34c08e0..705b292 100644 --- a/contrib/static/krane.css +++ b/contrib/static/krane.css @@ -544,3 +544,10 @@ background-repeat: repeat; :target { background-color: #493769; } + +body { + display: inline-flex; + flex-direction: column; + flex-wrap: wrap; + flex-flow: wrap; +}