Jump to content

Module:Wikt-lang/comparison

From Wikipedia, the free encyclopedia
This is an old revision of this page, as edited by Gonnym (talk | contribs) at 14:36, 1 December 2024. The present address (URL) is a permanent link to this revision, which may differ significantly from the current revision.

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 full_test_patterns = {}
	
	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