s-setups-missing.mkiv /size: 4279 b    last modification: 2025-02-21 11:03
1% show missing translations
2
3\startluacode
4local gsub    = string.gsub
5local find    = string.find
6local context = context
7
8function interfaces.show_missing(whatinterfaces)
9    whatinterfaces = whatinterfaces or interfaces.interfaces
10    local list = dofile(resolvers.find_file("mult-def.lua"))
11    local NC, NR, HL = context.NC, context.NR, context.HL
12    for k,v in table.sortedhash(list) do
13        context.title(k)
14        context.starttabulate { string.rep("|",#whatinterfaces+1) }
15        for i=1,#whatinterfaces do
16            NC()
17            context(whatinterfaces[i])
18        end
19        NC() NR() HL()
20        for kk, vv in next, v do
21            if not find(kk,"subsub") then
22                local okay = true
23                for i=1,#whatinterfaces do
24                    local int = whatinterfaces[i]
25                    local str = vv[int]
26                    if not str or (int ~= "en" and str == vv.en) then
27                        okay = false
28                        break
29                    end
30                end
31                if not okay then
32                    for i=1,#whatinterfaces do
33                        local int = whatinterfaces[i]
34                        local str = context.ctxescape(vv[int] or "")
35                        context.NC()
36                        if str == "" then
37                            -- nothing
38                        elseif int == "en" then
39                            context.color( { "darkgreen" }, str )
40                        elseif str == vv.en then
41                            context.color( { "darkred" }, str )
42                        elseif int == "pe" then
43                            context("\\righttoleft " .. str)
44                        else
45                            context(str)
46                        end
47                    end
48                    NC() NR()
49                end
50            end
51        end
52        context.stoptabulate()
53    end
54end
55
56function interfaces.show_missing_messages(whatinterfaces)
57    whatinterfaces = whatinterfaces or interfaces.interfaces
58    local list = dofile(resolvers.find_file("mult-mes.lua"))
59    local NC, NR, HL = context.NC, context.NR, context.HL
60    for k,v in table.sortedhash(list) do
61        context.title("message: " .. k)
62        context.starttabulate { "|l|" .. string.rep("pl|",#whatinterfaces) }
63        NC()
64        for i=1,#whatinterfaces do
65            NC()
66            context(whatinterfaces[i])
67        end
68        NC() NR() HL()
69        local sorted = table.sortedkeys(v)
70        for i=1,#sorted do
71            local kk = sorted[i]
72            local vv = v[kk]
73            if kk ~= "files" then
74                local okay = true
75                for i=1,#whatinterfaces do
76                    local int = whatinterfaces[i]
77                    local str = vv[int]
78                    if not str or (int ~= "en" and str == vv.en) then
79                        okay = false
80                        break
81                    end
82                end
83                if not okay then
84                    context.NC()
85                    context(kk)
86                    for i=1,#whatinterfaces do
87                        local int = whatinterfaces[i]
88                        local str = context.ctxescape(vv[int] or "")
89                        NC()
90                        if str == "" then
91                            -- nothing
92                        elseif int == "en" then
93                            context.color( { "darkgreen" }, str )
94                        elseif str == vv.en then
95                            context.color( { "darkred" }, str )
96                        elseif int == "pe" then
97                            context("\\righttoleft " .. str)
98                        else
99                            context(str)
100                        end
101                    end
102                    NC() NR()
103                end
104            end
105        end
106        context.stoptabulate()
107    end
108end
109\stopluacode
110
111\starttext
112
113\setupbodyfont[dejavu,7pt,tt]
114\setuppapersize[A4,landscape][A4,landscape]
115\setuplayout[backspace=.5cm,width=middle,topspace=.5cm,height=middle,header=1cm,footer=0cm]
116
117\startluacode
118    interfaces.show_missing() --  { "en","nl" }
119    interfaces.show_missing_messages() --  { "en","nl" }
120\stopluacode
121
122\stoptext
123