Jump to content

Module:Wikt-lang/comparison: Difference between revisions

From Wikipedia, the free encyclopedia
Content deleted Content added
Created page with '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 main(frame) local wiktionary_test_patterns = get_test_patterns(true)...'
 
No edit summary
Line 19: Line 19:
end
end


function main(frame)
function p.main(frame)
local wiktionary_test_patterns = get_test_patterns(true)
local wiktionary_test_patterns = get_test_patterns(true)
local full_test_patterns = {}
local full_test_patterns = {}

Revision as of 14:36, 1 December 2024

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