Module:category tree/fam/jpx/what-categorizes-msg

From Linguifex
Jump to navigation Jump to search

Documentation for this module may be created at Module:category tree/fam/jpx/what-categorizes-msg/doc

local export = {}

local m_str_utils = require("Module:string utilities")
local d_range = mw.loadData("Module:ja/data/range")

-- Handles the "Terms are placed in this category..." text in Japanese affix categories
-- Used in
-- [[Module:category tree/affixes and compounds]]
-- [[Module:category tree/fam/jpx]]
function export.get_what_categorizes_msg(affix, affix_reading, affix_type)
	if not affix_reading then
		if m_str_utils.find(affix, "[" .. d_range.kanji .. "々〻]") then
			--Category has kanji but no reading "read as"
			return nil
		end
		affix_reading = affix
	end
	
	local tl
	if affix_type == "suffix" then
		tl = "{{tl|ja-compound|<var>|...|</var>|" .. affix .. "|-" .. affix_reading .. "}}"
	elseif affix_type == "prefix" then
		tl = "{{tl|ja-compound|" .. affix .. "|" .. affix_reading .. "-|<var>|...|</var>}}"
	elseif affix_type == "infix" then
		tl = "{{tl|ja-compound|<var>|...|</var>|" .. affix .. "|-" .. affix_reading .. "-|<var>|...|</var>}}"
	end
	
	if tl then
		tl = "Terms are placed in this category using " .. tl .. "."
	end
	
	return tl
end

return export