Documentation icon Τεκμηρίωση module[δημιουργία]
-- Convert numerical digits to braille, morse, sign lang, and any other stuff that is based on simple substitution, nice and clean with no extra fluff. Does not handle negative numbers (treated as positive) or decimals and fractions.
-- Gts@el wiki, Aug. 2017

local p = {}

-- Greek braille symbols
local braille = {
	[1] = '⠁', 
	[2] = '⠃', 
	[3] = '⠉', 
	[4] = '⠙', 
	[5] = '⠑', 
	[6] = '⠓', 
	[7] = '⠛', 
	[8] = '⠓', 
	[9] = '⠊', 
	[0] = '⠚',
}

-- international morse
local morse = {
	[1] = '·−−−−', 
	[2] = '··−−−', 
	[3] = '···−−', 
	[4] = '····−', 
	[5] = '·····', 
	[6] = '−····', 
	[7] = '−−···', 
	[8] = '−−−··', 
	[9] = '−−−−·', 
	[0] = '−−−−−',
}


local function substitute_numeral(numeral, table, spacing)
	  local result     = ''
	  
	  if type(tonumber(numeral)) == 'number' and tonumber(numeral) <= 99999999999999 then 
	      local numeral = tostring(math.abs(math.floor(numeral)))
	      
		  for digit in numeral:gmatch"." do
		  	
		  	  -- convention based on images for sign language
	          if table == 'sign' then
	          	result = result .. '[[Αρχείο:Greek sign language No' .. digit .. '.jpg|40px]]'
	          else	
	            result = result .. spacing .. table[tonumber(digit)]
	          end  
	      end
	   end 
	
	  return result
end

function p.to_braille(frame)
	 local prefix = '⠼'
	 
	 result = substitute_numeral(frame.args[1], braille, '')
	 if result ~= '' then result = prefix .. result end
	 	
	 return result
end	

function p.to_morse(frame)
	 result = substitute_numeral(frame.args[1], morse, ' ')
	 
	 return result
end	

function p.to_sign(frame)
	return substitute_numeral(frame.args[1], 'sign', '')
end	

return p

-- =p.to_sign{args={3454}}