Modul:Mors

Vikilug‘atdan olingan

Ushbu modul kabi Andoza:mul-mors harf, deb Mors kodi yozuvlari ishlatiladigan kabi modda boshi soʻz andozalari, dasturiy mantigʻini beradi


local export = {}

local lang = require("Module:tili").getByCode("mul")
local Imag = require("Module:scripts").getByCode("Imag")

local submap = {
	["."] = "[[Fayl:Morse code dot.svg|link=]]",
	["-"] = "[[Fayl:Morse code dash.svg|link=]]",
	[" "] = "[[Fayl:60x15transparent spacer.svg|27px|link=]]",
}

function export.textToImages(text)
	return mw.ustring.gsub(text, "[-. ]", submap)
end

local types = {
	["letter"] = "letters in Morse code",
	["number"] = "numbers in Morse code",
	["punctuation mark"] = "punctuation marks in Morse code",
	["symbol"] = "symbols in Morse code",
	["interjection"] = "interjections",
}

function export.headword(rama)
	local m_bosh = require("Module:headword")

	-- These parameters are going to be used below.
	local type = rama.args["1"] ~= "" and frame.args["1"]
	local bosh = rama:getParent().args["bosh"]
	if not bosh or bosh == "" then
		bosh = mw.title.getCurrentTitle().subpageText
	end

	local display = '<span style="display:inline-block;vertical-align:middle">' .. export.textToImages(bosh) .. '</span>'

	local turkumlar = {}
	if types[type] then
		table.insert(turkumlar, tili:getCanonicalName() .. " " .. types[type])
	end

	return m_bosh.full_headword(tili, Imag, {display}, nil, nil, nil, turkumlar, bosh)
end

return export