Automatic language detection
This commit is contained in:
parent
5407471378
commit
62cba232e5
4 changed files with 15 additions and 2 deletions
|
@ -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
|
||||
|
|
|
@ -1,5 +1,5 @@
|
|||
config core main
|
||||
option lang en
|
||||
option lang auto
|
||||
option mediaurlbase /luci-static/openwrt.org
|
||||
option resourcebase /luci-static/resources
|
||||
|
||||
|
|
|
@ -25,6 +25,7 @@ end
|
|||
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
|
||||
|
|
|
@ -25,6 +25,7 @@ end
|
|||
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
|
||||
|
|
Loading…
Reference in a new issue