summaryrefslogtreecommitdiff
path: root/tex/context/modules/mkiv/s-setups-missing.mkiv
blob: 53037a78db4a9c39dbfe1e21937979a72b0075ab (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
% show missing translations

\startluacode
function interfaces.show_missing(whatinterfaces)
    whatinterfaces = whatinterfaces or interfaces.interfaces
    local list = dofile(resolvers.find_file("mult-def.lua"))
    local NC, NR, HL = context.NC, context.NR, context.HL
    for k,v in table.sortedhash(list) do
        context.title(k)
        context.starttabulate { string.rep("|",#whatinterfaces+1) }
        for i=1,#whatinterfaces do
            NC()
            context(whatinterfaces[i])
        end
        NC() NR() HL()
        for kk, vv in next, v do
            if not string.find(kk,"subsub") then
                local okay = true
                for i=1,#whatinterfaces do
                    local int = whatinterfaces[i]
                    local str = vv[int]
                    if not str or (int ~= "en" and str == vv.en) then
                        okay = false
                        break
                    end
                end
                if not okay then
                    for i=1,#whatinterfaces do
                        local int = whatinterfaces[i]
                        local str = vv[int]
                        context.NC()
                        if not str then
                            -- nothing
                        elseif int == "en" then
                            context.color( { "darkgreen" }, str )
                        elseif str == vv.en then
                            context.color( { "darkred" }, str )
                        elseif int == "pe" then
                            context("\\righttoleft " .. str)
                        else
                            context(str)
                        end
                    end
                    NC() NR()
                end
            end
        end
        context.stoptabulate()
    end
end

function interfaces.show_missing_messages(whatinterfaces)
    whatinterfaces = whatinterfaces or interfaces.interfaces
    local list = dofile(resolvers.find_file("mult-mes.lua"))
    local NC, NR, HL = context.NC, context.NR, context.HL
    for k,v in table.sortedhash(list) do
        context.title("message: " .. k)
        context.starttabulate { "|l|" .. string.rep("pl|",#whatinterfaces) }
        NC()
        for i=1,#whatinterfaces do
            NC()
            context(whatinterfaces[i])
        end
        NC() NR() HL()
        local sorted = table.sortedkeys(v)
        for i=1,#sorted do
            local kk = sorted[i]
            local vv = v[kk]
            if kk ~= "files" then
                local okay = true
                for i=1,#whatinterfaces do
                    local int = whatinterfaces[i]
                    local str = vv[int]
                    if not str or (int ~= "en" and str == vv.en) then
                        okay = false
                        break
                    end
                end
                if not okay then
                    context.NC()
                    context(kk)
                    for i=1,#whatinterfaces do
                        local int = whatinterfaces[i]
                        local str = vv[int]
                        NC()
                        if not str then
                            -- nothing
                        elseif int == "en" then
                            context.color( { "darkgreen" }, str )
                        elseif str == vv.en then
                            context.color( { "darkred" }, str )
                        elseif int == "pe" then
                            context("\\righttoleft " .. str)
                        else
                            context(str)
                        end
                    end
                    NC() NR()
                end
            end
        end
        context.stoptabulate()
    end
end
\stopluacode

\starttext

\setupbodyfont[dejavu,7pt,tt]
\setuppapersize[A4,landscape][A4,landscape]
\setuplayout[backspace=.5cm,width=middle,topspace=.5cm,height=middle,header=1cm,footer=0cm]

\startluacode
    interfaces.show_missing() --  { "en","nl" }
    interfaces.show_missing_messages() --  { "en","nl" }
\stopluacode

\stoptext