diff options
Diffstat (limited to 'libs/web/luasrc/dispatcher.lua')
-rw-r--r-- | libs/web/luasrc/dispatcher.lua | 13 |
1 files changed, 12 insertions, 1 deletions
diff --git a/libs/web/luasrc/dispatcher.lua b/libs/web/luasrc/dispatcher.lua index 5f450eb5e..c0d8b98c2 100644 --- a/libs/web/luasrc/dispatcher.lua +++ b/libs/web/luasrc/dispatcher.lua @@ -130,7 +130,18 @@ function dispatch(request) ctx.path = request ctx.urltoken = ctx.urltoken or {} - require "luci.i18n".setlanguage(require "luci.config".main.lang) + local conf = require "luci.config" + local lang = conf.main.lang + if lang == "auto" then + local aclang = http.getenv("HTTP_ACCEPT_LANGUAGE") or "" + for lpat in aclang:gmatch("[%w]+") do + if conf.languages[lpat] then + lang = lpat + break + end + end + end + require "luci.i18n".setlanguage(lang) local c = ctx.tree local stat |