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
config core main
- option lang en
+ option lang auto
option mediaurlbase /luci-static/openwrt.org
option resourcebase /luci-static/resources
c = m:section(NamedSection, "main", "core", translate("general"))
l = c:option(ListValue, "lang", translate("language"))
+l:value("auto")
local i18ndir = luci.i18n.i18ndir .. "default."
for k, v in pairs(luci.config.languages) do
c = m:section(NamedSection, "main", "core", translate("general"))
l = c:option(ListValue, "lang", translate("language"))
+l:value("auto")
local i18ndir = luci.i18n.i18ndir .. "default."
for k, v in pairs(luci.config.languages) do