Module:Wikt-lang/comparison: Difference between revisions
Appearance
Content deleted Content added
No edit summary |
No edit summary |
||
Line 1: | Line 1: | ||
require('strict') |
|||
local p = {} |
local p = {} |
||
Line 21: | Line 22: | ||
function p.main(frame) |
function p.main(frame) |
||
local wiktionary_test_patterns = get_test_patterns(true) |
local wiktionary_test_patterns = get_test_patterns(true) |
||
local name_from_tag = require('Module:Lang')._name_from_tag |
|||
local full_test_patterns = {} |
|||
wikitable = {} |
local wikitable = {} |
||
local header = '{|class="wikitable"\n|+\n! Languge code\n! Wikitionary name\n! English Wikipedia name' |
local header = '{|class="wikitable"\n|+\n! Languge code\n! Wikitionary name\n! English Wikipedia name' |
||
table.insert(wikitable, header) |
table.insert(wikitable, header) |
Revision as of 14:38, 1 December 2024
require('strict')
local p = {}
local function get_test_patterns(main)
local data = require('Module:Wikt-lang/data/sandbox')
local language_codes = {}
if main then
for code, values in pairs(data["languages"]) do
table.insert(language_codes, {code, values.name})
end
end
local function comp(a, b)
return a[1] < b[1]
end
table.sort(language_codes, comp)
return language_codes
end
function p.main(frame)
local wiktionary_test_patterns = get_test_patterns(true)
local name_from_tag = require('Module:Lang')._name_from_tag
local wikitable = {}
local header = '{|class="wikitable"\n|+\n! Languge code\n! Wikitionary name\n! English Wikipedia name'
table.insert(wikitable, header)
local row = '! scope="row" | %s\n | %s\n | %s\n|-\n'
for i = 1, #wiktionary_test_patterns do
local code = wiktionary_test_patterns[i][1]
local en_wiki_name = name_from_tag({code})
local wiktionary_name = wiktionary_test_patterns[i][2]
if wiktionary_name then
table.insert(wikitable, string.format(row, code, wiktionary_name, en_wiki_name))
end
end
table.insert(wikitable, "|}")
return table.concat(wikitable)
end
return p