ข้ามไปเนื้อหา

มอดูล:sl-common

จาก วิกิพจนานุกรม พจนานุกรมเสรี

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)
	return require("Module:languages").getByCode("sl"):makeEntryName(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