Module:eo-spel

From Wiktionary, the free dictionary
Jump to navigation Jump to search

This module needs documentation.
Please document this module by describing its purpose and usage on the documentation page.

local u = require("Module:string/char")

local export = {}

local lang = require("Module:languages").getByCode("eo")
local hat = u(0x302)
local breve = u(0x306)

function export.convert(word)
	if word:match("[xX]") then
		return word
			:gsub("([cghjsCGHJS])[xX]", "%1" .. hat)
			:gsub("([uU])[xX]", "%1" .. breve)
	else
		return word
			:gsub("([cghjsCGHJS])[hH]", "%1" .. hat)
			:gsub("([aeoAEO][uU])", "%1" .. breve)
	end
end

function export.spelling(frame)
	return frame:expandTemplate{ title = "spelling of",
		args = {[1] = "eo", [2] = (mw.title.getCurrentTitle().text:match("[xX]") and "X" or "H") .. "-system", [3] = frame:getParent() and frame:getParent().args[1] or export.convert(mw.title.getCurrentTitle().text)}}
end

return export