s-languages-counters.lua /size: 1532 b    last modification: 2020-07-01 14:35
1if not modules then modules = { } end modules ['s-languages-counters'] = {
2    version   = 1.001,
3    comment   = "companion to s-languages-counters.mkiv",
4    author    = "Hans Hagen, PRAGMA-ADE, Hasselt NL",
5    copyright = "PRAGMA ADE / ConTeXt Development Team",
6    license   = "see context related readme files"
7}
8
9moduledata.languages          = moduledata.languages          or { }
10moduledata.languages.counters = moduledata.languages.counters or { }
11
12local data = converters.verbose.data
13
14function moduledata.languages.counters.showverbose(specification)
15    specification = interfaces.checkedspecification(specification)
16    local list = utilities.parsers.settings_to_array(specification.language or "")
17    if #list == 0 then
18        return
19    end
20    local used = { }
21    local words = { }
22    for i=1,#list do
23        local ai = list[i]
24        local di = data[ai]
25        if di and di.words then
26            used[#used+1] = ai
27            table.merge(words,di.words)
28        end
29    end
30    context.starttabulate { string.rep("|l",#used) .. "|r|" }
31    context.HL()
32    context.NC()
33    for i=1,#used do
34        context.bold(used[i])
35        context.NC()
36    end
37    context.bold("number")
38    context.NC()
39    context.NR()
40    context.HL()
41    for k, v in table.sortedhash(words) do
42        context.NC()
43        for i=1,#used do
44            context(data[used[i]].words[k] or "")
45            context.NC()
46        end
47        context(k)
48        context.NC()
49        context.NR()
50    end
51    context.stoptabulate()
52end
53