modules/base: dispatcher: use default language if automatic choice fails 659/head
authorMatthias Schiffer <mschiffer@universe-factory.net>
Tue, 1 Mar 2016 16:25:55 +0000 (17:25 +0100)
committerMatthias Schiffer <mschiffer@universe-factory.net>
Tue, 1 Mar 2016 16:25:55 +0000 (17:25 +0100)
Fall back to default language if "auto" is configured, but none provided by
the browser matches.

Signed-off-by: Matthias Schiffer <mschiffer@universe-factory.net>
modules/luci-base/luasrc/dispatcher.lua

index c7903e6384e7a2f07f2952d352fddbf02aee9f25..0876ce658580cf2848f419dd3411638b3f59aaa7 100644 (file)
@@ -197,6 +197,7 @@ function dispatch(request)
        assert(conf.main,
                "/etc/config/luci seems to be corrupt, unable to find section 'main'")
 
+       local i18n = require "luci.i18n"
        local lang = conf.main.lang or "auto"
        if lang == "auto" then
                local aclang = http.getenv("HTTP_ACCEPT_LANGUAGE") or ""
@@ -208,7 +209,10 @@ function dispatch(request)
                        end
                end
        end
-       require "luci.i18n".setlanguage(lang)
+       if lang == "auto" then
+               lang = i18n.default
+       end
+       i18n.setlanguage(lang)
 
        local c = ctx.tree
        local stat