Moduł:odmiana-przymiotnik-japoński

Moduł wykorzystywany przez szablon {{odmiana-przymiotnik-japoński}}.


require('strict')

local p = {}

local is_str_empty = function (str)
	return str == "" or str == nil
end

local error_message = {
	["missing_first_parameter"] = "Nie podano przymiotnika.\n",
	["missing_ending"] = "Podany przymiotnik nie kończy się na -い.\n",
}

p.get_i_adjective_stem = function(frame)
	local args = frame.args
	local adjective = args[1]
	local ending, stem, err

	if adjective == nil then
		return error(error_message["missing_first_parameter"])
	end

	ending = mw.ustring.sub(adjective, -1)
			
	stem = mw.ustring.sub(adjective, 1, mw.ustring.len(adjective) - 1)
	if ending ~= "い" then
		return error(error_message["missing_ending"])
	end

	return stem
end

return p