From 75cd173c980a87a7ccb8b9ecba8349583256ea54 Mon Sep 17 00:00:00 2001
From: =?UTF-8?q?Karel=20Ko=C4=8D=C3=AD?= <karel.koci@nic.cz>
Date: Tue, 9 Jul 2019 17:06:05 +0200
Subject: [PATCH] lists: fix and improve even more Luci l18n support

---
 lists/luci.lua.m4 | 77 ++++++++++++++++++++++++++++++++++++++---------
 1 file changed, 62 insertions(+), 15 deletions(-)

diff --git a/lists/luci.lua.m4 b/lists/luci.lua.m4
index b03e46816..c5cc2fd87 100644
--- a/lists/luci.lua.m4
+++ b/lists/luci.lua.m4
@@ -8,29 +8,28 @@ forInstall(luci,base,proto-ipv6,proto-ppp,app-commands)
 --[[
 All packages with localization packages
 Generated using:
- curl https://repo.turris.cz/hbd/omnia/packages/luci/Packages | sed -n 's/^Package: luci-i18n-\([^-]\+\).*/\1/p' | sort | uniq | sed 's/^/"/;s/$/",/'
+ curl https://repo.turris.cz/hbd/omnia/packages/luci/Packages | sed -n '/Package: luci-i18n-/,/^$/{ s/Depends:.*luci-app-\([^ ,]\+\).*/\1/p }' | sort | uniq | sed 's/^/"/;s/$/",/'
 ]]
-local luci_i18n_pkgs = {
+local luci_apps = {
 	"adblock",
-	"advanced",
+	"advanced-reboot",
 	"ahcp",
 	"aria2",
-	"base",
 	"bcp38",
 	"clamav",
 	"commands",
 	"ddns",
-	"diag",
-	"dnscrypt",
+	"diag-core",
+	"dnscrypt-proxy",
 	"dynapoint",
 	"firewall",
 	"fwknopd",
-	"hd",
+	"hd-idle",
 	"https_dns_proxy",
 	"minidlna",
-	"mjpg",
+	"mjpg-streamer",
 	"mwan3",
-	"nft",
+	"nft-qos",
 	"nlbwmon",
 	"noddos",
 	"ntpc",
@@ -45,12 +44,12 @@ local luci_i18n_pkgs = {
 	"qos",
 	"radicale",
 	"radicale2",
-	"rp",
+	"rp-pppoe-server",
 	"samba",
 	"samba4",
-	"shadowsocks",
+	"shadowsocks-libev",
 	"shairplay",
-	"simple",
+	"simple-adblock",
 	"splash",
 	"statistics",
 	"tinyproxy",
@@ -67,15 +66,63 @@ local luci_i18n_pkgs = {
 	"wol",
 }
 
+--[[
+Some packages have separate EN support. This is only few packages so we list them
+instead of having warning for multiple packages missing.
+Generated using:
+ curl https://repo.turris.cz/hbd/omnia/packages/luci/Packages | sed -n 's/^Package: luci-i18n-\(.*\)-en.*/\1/p' | sort | sed 's/^/["/;s/$/"] = true,/'
+]]
+local luci_i18n_en = {
+	["ahcp"] = true,
+	["base"] = true,
+	["commands"] = true,
+	["diag-core"] = true,
+	["firewall"] = true,
+	["fwknopd"] = true,
+	["hd-idle"] = true,
+	["minidlna"] = true,
+	["ntpc"] = true,
+	["nut"] = true,
+	["olsr"] = true,
+	["openvpn"] = true,
+	["opkg"] = true,
+	["p910nd"] = true,
+	["polipo"] = true,
+	["qos"] = true,
+	["radicale2"] = true,
+	["rp-pppoe-server"] = true,
+	["samba"] = true,
+	["samba4"] = true,
+	["splash"] = true,
+	["statistics"] = true,
+	["tinyproxy"] = true,
+	["transmission"] = true,
+	["uhttpd"] = true,
+	["upnp"] = true,
+	["vnstat"] = true,
+	["watchcat"] = true,
+	["wol"] = true,
+}
+
 if l10n then
-	local luci_i18n = {["en"] = true} -- we always install English localization
+	local luci_i18n = {}
 	for _, lang in pairs(l10n or {}) do
 		luci_i18n[lang] = true
 	end
 
+	Install("luci-i18n-base-en", { optional = true, priority = 20 })
 	for lang in pairs(luci_i18n) do
-		for _, pkg in pairs(luci_i18n_pkgs) do
-			Install("luci-i18n-" .. pkg .. "-" .. lang, { optional = true, priority = 20 })
+		Install("luci-i18n-base-" .. lang, { optional = true, priority = 20 })
+	end
+
+	for _, app in pairs(luci_i18n_pkgs) do
+		if installed["luci-app-" .. app] then
+			if luci_i18n_en[app] then
+				Install("luci-i18n-" .. app .. "-en", { optional = true, priority = 20 })
+			end
+			for lang in pairs(luci_i18n) do
+				Install("luci-i18n-" .. app .. "-" .. lang, { optional = true, priority = 20 })
+			end
 		end
 	end
 end
-- 
GitLab