0002-modules-base-dispatcher-set-default-language-if-none-provided-by-the-browser-matches.patch 916 B

12345678910111213141516171819202122232425262728
  1. From: Matthias Schiffer <mschiffer@universe-factory.net>
  2. Date: Thu, 19 Mar 2015 18:44:52 +0100
  3. Subject: modules/base: dispatcher: set default language if none provided by the browser matches
  4. diff --git a/modules/base/luasrc/dispatcher.lua b/modules/base/luasrc/dispatcher.lua
  5. index f7e16e7..479ac54 100644
  6. --- a/modules/base/luasrc/dispatcher.lua
  7. +++ b/modules/base/luasrc/dispatcher.lua
  8. @@ -211,6 +211,7 @@ function dispatch(request)
  9. assert(conf.main,
  10. "/etc/config/luci seems to be corrupt, unable to find section 'main'")
  11. + local i18n = require "luci.i18n"
  12. local lang = conf.main.lang or "auto"
  13. if lang == "auto" then
  14. local aclang = http.getenv("HTTP_ACCEPT_LANGUAGE") or ""
  15. @@ -222,7 +223,10 @@ function dispatch(request)
  16. end
  17. end
  18. end
  19. - require "luci.i18n".setlanguage(lang)
  20. + if lang == "auto" then
  21. + lang = i18n.default
  22. + end
  23. + i18n.setlanguage(lang)
  24. local c = ctx.tree
  25. local stat