Module:Colon

Documentation for this module may be created at Module:Colon/doc

require('strict')

local getArgs = require('Module:Arguments').getArgs
local langSwitch = require('Module:LangSwitch')._langSwitch

local p = {}

function p._colon(args)
	local lang = args.lang or mw.getCurrentFrame():preprocess("{{Int:Lang}}")
	
	-- Please keep the ASCII colon returned as HTML-encoded everywhere, as it MUST NOT be parsed as wiki markup
	local colons = {
		-- Colon with no space before and space after
		-- ": ""
		['ger'] = ': ',
		
		-- Colon with narrow space before and space after
		-- " : "
		['fr'] = ' : ',
		
		--[=[ Colon with non-breaking space before and space after, avoiding confusion with:
			several Arabic diacritics,
			U+0589 Armenian punctuation Full stop,
			U+05C3 Hebrew punctuation sign Sof Pasuk,
			U+0983 Bengali combining sign Visarga,
			U+0903 Devanagari combining sign Visarga,
			U+0A03 Gurmukhi combining sign Visarga,
			U+0A83 Gujarati combining sign Visarga,
			U+0B03 Oryia combining sign Visarga,
			U+0B83 Tamil combining sign Visarga,
			Telugu combining sign Visarga,
			Kannada combining sign Visarga,
			U+0D03 Malayalam combining sign Visarga,
			U+0D83 Sinhalese combining sign Visarga,
			U+0F7F Tibetan combining sign Rnam Bcad (Nam Che),
			U+17C7 / U+17C8 Khmer combining signs Reahmuk / Yukaleakpintu,
			U+2D53 Tifinagh letter Yu (Touareg Yaw)
		]=]
		-- " : "
		['sp'] = ' : ',
		
		--[=[ Myanmar:
			do not use the ASCII colon
			(too confusable with a Myanmar letter in many fonts, notably at small sizes);
			use an en-dash instead
		]=]
		-- " – "
		['my'] = ' – ',
		
		-- No spacing
		-- ":"
		['no'] = ':',
		
		-- Ethiopic punctuation sign colon
		-- "፥ "
		['eth'] = '፥ ',
		
		-- Mongolian/Mandchu punctuation sign colon
		-- "᠄"
		['mong'] = '᠄',
		
		--[=[ CJK punctuation fullwidth colon
			(rotated if vertical layout)
			for Indo-Sinitic scripts used along with Chinese
		]=]
		-- ":"
		['cjk'] = ':'
	}
	
	local text_args = {
		['default'] =				colons['ger'],
		['af'] =					colons['ger'],
		['am'] =					colons['eth'],
		['ar'] =					colons['sp'],
		['Arab'] =					colons['sp'],
		['Armn'] =					colons['sp'],
		['arz'] =					colons['sp'],
		['bar'] =					colons['ger'],
		['be-tarask'] =				colons['ger'],
		['be'] =					colons['ger'],
		['Beng'] =					colons['sp'],
		['ber'] =					colons['sp'],
		['bg'] =					colons['ger'],
		['bn'] =					colons['sp'],
		['bo'] =					colons['sp'],
		['Bpmf'] =					colons['cjk'],
		['br'] =					colons['fr'],
		['bs'] =					colons['ger'],
		['ca'] =					colons['ger'],
		['co'] =					colons['ger'],
		['cs'] =					colons['ger'],
		['Cyrl'] =					colons['ger'],
		['de'] =					colons['ger'],
		['Deva'] =					colons['sp'],
		['el'] =					colons['ger'],
		['eml'] =					colons['ger'],
		['en'] =					colons['ger'],
		['es'] =					colons['ger'],
		['Ethi'] =					colons['eth'],
		['ext'] =					colons['ger'],
		['fa'] =					colons['sp'],
		['fr-be'] =					colons['fr'],
		['fr-ca'] =					colons['fr'],
		['fr-ch'] =					colons['fr'],
		['fr-lb'] =					colons['fr'],
		['fr'] =					colons['fr'],
		['gl'] =					colons['ger'],
		['glk'] =					colons['sp'],
		['Grek'] =					colons['ger'],
		['gsw'] =					colons['gsw'],
		['gu'] =					colons['sp'],
		['Gujr'] =					colons['sp'],
		['Guru'] =					colons['sp'],
		['Hang'] =					colons['cjk'],
		['Hani'] =					colons['cjk'],
		['Hans'] =					colons['cjk'],
		['Hant'] =					colons['cjk'],
		['he'] =					colons['sp'],
		['Hebr'] =					colons['sp'],
		['hi'] =					colons['sp'],
		['hr'] =					colons['ger'],
		['hu'] =					colons['ger'],
		['hy'] =					colons['sp'],
		['ii'] =					colons['cjk'],
		['it'] =					colons['ger'],
		['ja'] =					colons['cjk'],
		['Jpan'] =					colons['cjk'],
		['Khmr'] =					colons['sp'],
		['km'] =					colons['sp'],
		['kn'] =					colons['sp'],
		['Knda'] =					colons['sp'],
		['ko-kp'] =					colons['ger'],
		['ko'] =					colons['ger'],
		['la'] =					colons['ger'],
		['lb'] =					colons['ger'],
		['li'] =					colons['ger'],
		['lzh'] =					colons['cjk'],
		['mk'] =					colons['ger'],
		['ml'] =					colons['sp'],
		['Mlym'] =					colons['sp'],
		['mn-Mong'] =				colons['mong'],
		['Mong'] =					colons['mong'],
		['my'] =					colons['my'],
		['Mymr'] =					colons['my'],
		['nap'] =					colons['ger'],
		['nds-nl'] =				colons['ger'],
		['nds'] =					colons['ger'],
		['ne'] =					colons['sp'],
		['nl'] =					colons['ger'],
		['oc'] =					colons['fr'],
		['or'] =					colons['sp'],
		['Orya'] =					colons['sp'],
		['pa'] =					colons['sp'],
		['Phpa'] =					colons['cjk'],
		['pnt'] =					colons['ger'],
		['prd'] =					colons['sp'],
		['ps'] =					colons['sp'],
		['pt-br'] =					colons['ger'],
		['pt'] =					colons['ger'],
		['rgn'] =					colons['ger'],
		['rm'] =					colons['ger'],
		['ro'] =					colons['ger'],
		['ru'] =					colons['ger'],
		['scn'] =					colons['ger'],
		['shy'] =					colons['sp'],
		['si'] =					colons['sp'],
		['Sinh'] =					colons['sp'],
		['sk'] =					colons['ger'],
		['sl'] =					colons['ger'],
		['sr-ec'] =					colons['ger'],
		['sr-el'] =					colons['ger'],
		['sr-Latn'] =				colons['ger'],
		['sr'] =					colons['ger'],
		['ta'] =					colons['sp'],
		['Tale'] =					colons['cjk'],
		['Talu'] =					colons['cjk'],
		['Taml'] =					colons['sp'],
		['te'] =					colons['sp'],
		['Telu'] =					colons['sp'],
		['Tfng'] =					colons['sp'],
		['th'] =					colons['no'],
		['Thai'] =					colons['no'],
		['ti'] =					colons['eth'],
		['Tibt'] =					colons['sp'],
		['tzm'] =					colons['sp'],
		['ug'] =					colons['sp'],
		['ur'] =					colons['sp'],
		['vec'] =					colons['ger'],
		['vls'] =					colons['ger'],
		['wa'] =					colons['fr'],
		['wuu'] =					colons['cjk'],
		['ydd'] =					colons['sp'],
		['yi'] =					colons['sp'],
		['Yiii'] =					colons['cjk'],
		['yue'] =					colons['cjk'],
		['zh-Hans'] =				colons['cjk'],
		['zh-Hant'] =				colons['cjk'],
		['zh'] =					colons['cjk'],
		['Zinh-nbsp-Po-space'] =	colons['sp'],
		['Zinh-nnbsp-Po-space'] =	colons['fr'],
		['Zinh-Po-space'] =			colons['ger'],
		['Zinh-Po'] =				colons['no']
	}
	
	return langSwitch(text_args, lang)
end

function p.colon(frame)
	return p._colon(getArgs(frame))
end

return p