0002-modules-base-dispatcher-set-default-language-if-none-provided-by-the-browser-matches.patch 936 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/luci-base/luasrc/dispatcher.lua b/modules/luci-base/luasrc/dispatcher.lua
  5. index 2526950..be2fc34 100644
  6. --- a/modules/luci-base/luasrc/dispatcher.lua
  7. +++ b/modules/luci-base/luasrc/dispatcher.lua
  8. @@ -182,6 +182,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. @@ -193,7 +194,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