Module:Sandbox/3df/grapheme

From English Wikipedia @ Freddythechick

This is the current revision of this page, as edited by imported>3df at 23:43, 29 April 2024. The present address (URL) is a permanent link to this version.

(diff) ← Older revision | Latest revision (diff) | Newer revision → (diff)
local p = {}

local abcd = {
	basiclatin = {
		alphabet = 'ABCDEFGHIJKLMNOPQRSTUVWXYZ',
		articles = {
			'A', 'B', 'C', 'D', 'E', 'F', 'G', 'H', 'I', 'J', 'K', 'L', 'M',
			'N', 'O', 'P', 'Q', 'R', 'S', 'T', 'U', 'V', 'W', 'X', 'Y', 'Z'
		}
	}
}

local function alphaNav(frame, series)
	local out = {width = 'abcd'}
	for i = 1, #series.alphabet do
		table.insert(out, '[[' .. series.articles[i] .. '|' .. series.alphabet:sub(i, i) .. series.alphabet:sub(i, i):lower() .. ']]')
	end
	return frame:expandTemplate({title = 'grid list', args = out})
end

p.main = function(frame)
	local pargs = frame:getParent().args
	
	local ibArgs = {title = 'A'}
	
	local series = 'basiclatin'
	local alphabet = ''
	
	ibArgs.headerstyle = 'background: lightblue;'
		
	ibArgs.label10 = 'Phonetic usage'
	ibArgs.data10 = '{{{phonemes}}}'
	
	if series == 'basiclatin' then
		ibArgs.image = '[[File:Latin alphabet Aa.svg|x48px|alt=]]'
		ibArgs.imagestyle = 'padding-bottom: 12px; height: 48px;'
		ibArgs.header1 = 'Basic Latin script letter'
		
		ibArgs.label3 = '[[English alphabet#Letter names|Name in English]]'
		ibArgs.data3 = '{{{english name}}}'
		
		ibArgs.label51 = '[[NATO phonetic alphabet|NATO phonetic]]'
		ibArgs.data51 = 'Alfa'
		
		local morseArgs = {'A' .. ' morse code.ogg', frame:expandTemplate({title = 'morse', args = {'dot', 'dash'}})}
		ibArgs.label52 = '[[Morse code]]'
		ibArgs.data52 = frame:expandTemplate({title = 'audio', args = morseArgs})
		
		ibArgs.header50 = 'Other representations'
		
		local otherReps = '<table width=100%><tr>'
		
		otherReps = otherReps .. "<td style='text-align: center; padding-bottom: 8px;'>'''[[American manual alphabet|AMA]]/[[American Sign Language|ASL]]'''<br/>[[File:Sign_language_A.svg|x48px]]</td>"
		otherReps = otherReps .. "<td style='text-align: center;'>'''[[British manual alphabet|BANZSL]]'''<br/>[[File:BSL_letter_A.svg|x48px]]</td>"
		otherReps = otherReps .. "<td style='text-align: center;'>'''[[Flag semaphore]]'''<br/>[[File:Semaphore Alfa.svg|border|x48px]]</td>"
		
		otherReps = otherReps .. '</tr><tr>'
		
		--ibArgs.data55 = otherReps
		
		--local otherReps = '<table width=100%><tr>'
		
		otherReps = otherReps .. "<td colspan=2 style='text-align: center;'>'''[[Unified English Braille]]'''<br/>[[File:Braille_A1.svg|x48px]]</td>"
		otherReps = otherReps .. "<td style='text-align: center;'>'''[[International maritime signal flags|Signal flag]]'''<br/>[[File:ICS Alfa.svg|x48px]]</td>"
		
		otherReps = otherReps .. '</tr></table>'
		
		ibArgs.data56 = otherReps
		
	end
	
	if series then
		ibArgs.above = ''
		ibArgs.data2 = alphaNav(frame, abcd[series])
		
		ibArgs.label11 = 'Position'
		ibArgs.data11 = '{{{position}}}'
	end

	local root = mw.html.create('div'):wikitext(frame:expandTemplate({title = 'infobox', args = ibArgs}))

	return tostring(root)
end
return p