From 70e32f0cb1ecfdb565ee1d0497d45acdebf73b94 Mon Sep 17 00:00:00 2001 From: Jo-Philipp Wich Date: Tue, 25 Oct 2022 13:01:31 +0200 Subject: [PATCH] luci-base: dispatcher.uc: ensure usage of dashes in language tags The LuCI uci configuration requires language tags with underscores due limitations of uci option names but the language catalogs themselves are designated with dash separated language tags. Make sure to substitute underscores with dashes when determining the desired request language in order to fix loading of languages such as `pt-br` or `zh-cn`. Ref: https://github.com/openwrt/luci/pull/5976#issuecomment-1290352951 Signed-off-by: Jo-Philipp Wich --- modules/luci-base/ucode/dispatcher.uc | 2 ++ 1 file changed, 2 insertions(+) diff --git a/modules/luci-base/ucode/dispatcher.uc b/modules/luci-base/ucode/dispatcher.uc index 50c1a7d0f2..1d10d7876d 100644 --- a/modules/luci-base/ucode/dispatcher.uc +++ b/modules/luci-base/ucode/dispatcher.uc @@ -103,6 +103,8 @@ function determine_request_language() { if (lang == 'auto') lang = 'en'; + else + lang = replace(lang, '_', '-'); if (load_catalog(lang, '/usr/lib/lua/luci/i18n')) change_catalog(lang);