Module:sl-common

Definition from Wiktionary, the free dictionary
Jump to: navigation, search
The following documentation is located at Module:sl-common/documentation. [edit]

local export = {}
 
function export.has_accents(word)
	if mw.ustring.find(mw.ustring.lower(word), "[áéíóúŕàèìòùêô]") then
		return true
	else
		return false
	end
end
 
function export.remove_accents(text)
	local m_languages = mw.loadData("Module:languages")
	local langinfo = m_languages["sl"]
 
	for i, from in ipairs(langinfo.entry_name.from) do
		local to = langinfo.entry_name.to[i] or ""
		text = gsub(text, from, to)
	end
 
	return text
end
 
function export.is_soft(stem)
	if mw.ustring.find(stem, "[cjčšž]$") then
		return true
	else
		return false
	end
end
 
function export.first_palat(stem)
    if stem:sub(-2) == "k" then return stem:sub(1, -2) .. "č"
    elseif stem:sub(-2) == "g" then return stem:sub(1, -2) .. "ž"
    elseif stem:sub(-3) == "sk" then return stem:sub(1, -3) .. "šč"
    else return stem
    end
end
 
function export.second_palat(stem)
    if stem:sub(-2) == "k" then return stem:sub(1, -2) .. "c"
    elseif stem:sub(-2) == "g" then return stem:sub(1, -2) .. "z"
    else return stem
    end
end
 
function export.iotation(stem)
    if stem:sub(-2) == "t" or stem:sub(-2) == "k" or stem:sub(-2) =="c" then return stem:sub(1, -2) .. "č"
    elseif stem:sub(-2) == "g" or stem:sub(-2) == "z" then return stem:sub(1, -2) .. "ž"
    elseif stem:sub(-3) == "sk" then return stem:sub(1, -3) .. "sk"
    elseif stem:sub(-2) == "s" then return stem:sub(1, -2) .. "s"
    elseif stem:sub(-2) == "d" then return stem:sub(1, -2) .. "j"
    elseif stem:sub(-2) == "m" then return stem:sub(1, -2) .. "mlj"
    elseif stem:sub(-2) == "p" then return stem:sub(1, -2) .. "plj"
    elseif stem:sub(-2) == "b" then return stem:sub(1, -2) .. "blj"
    elseif stem:sub(-2) == "v" then return stem:sub(1, -2) .. "vlj"
    elseif stem:sub(-3) == "sl" then return stem:sub(1, -3) .. "šlj"
    else return stem
    end
end
 
return export