跳转到内容

模組:Category tree/poscatboiler/data/terms by etymology

維基詞典,自由的多語言詞典

子頁面


local labels = {}
local raw_categories = {}
local handlers = {}
local raw_handlers = {}



-----------------------------------------------------------------------------
--                                                                         --
--                                  LABELS                                 --
--                                                                         --
-----------------------------------------------------------------------------


labels["詞源"] = {
	description = "{{{langname}}}詞彙,依其起源分類。",
	umbrella_parents = "分類",
	parents = {{name = "{{{langcat}}}", raw = true}},
}

labels["重疊詞"] = {
	description = "{{{langname}}}用詞中完全重疊(AABB)的[[疊詞]]。",
	parents = {"疊詞"},
}

labels["頭韻複合詞"] = {
	description = "{{{langname}}} noun phrases composed of two or more stems that alliterate.",
	umbrella_parents = "複合詞種類",
	parents = {"複合詞", "頭韻短語"},
}

labels["反義複詞"] = {
	description = "其中一部分與另一部分互為反義詞的{{{langname}}}複合詞。",
	parents = {"並列複合詞"},
}

labels["逆構詞"] = {
	description = "假定某詞的規則形式並移除原詞的一部分而得到的{{{langname}}}詞彙。",
	parents = {"詞源"},
}

labels["所有複合詞"] = {
	description = "{{{langname}}} compounds in which the first part (A) modifies the second (B), and whose meaning follows a [[metonymic]] pattern: “<person> having a B that is A.”",
	umbrella_parents = "複合詞種類",
	parents = {"複合詞", "exocentric compounds"},
}

labels["混成詞"] = {
	description = "其他詞合併而得來的{{{langname}}}詞彙。",
	parents = {"詞源"},
}

labels["借詞"] = {
	description = "{{{langname}}}中借自其他語言的詞彙。",
	parents = {"詞源"},
}

labels["仿譯詞"] = {
	description = "逐詞翻譯自另一語言的表達方式的{{{langname}}}詞彙。",
	parents = {"詞源"},
}

labels["catachreses"] = {
	description = "{{{langname}}} terms derived from misuses or misapplications of other terms.",
	parents = {"詞源"},
}

labels["新創詞"] = {
	description = "{{{langname}}} terms coined by an identifiable person, organization or other such entity.",
	parents = {"依出處分類的詞"},
	umbrella_parents = {name = "依出處分類的詞", is_label = true, sort = " "},
}

-- Add "compound POS" categories for various parts of speech.

local compound_poses = {
	"形容詞",
	"副詞",
	"連詞",
	"限定詞",
	"感嘆詞",
	"名詞",
	"數詞",
	"助詞",
	"後置詞",
	"前綴",
	"介詞",
	"代詞",
	"專有名詞",
	"後綴",
	"動詞",
}

for _, pos in ipairs(compound_poses) do
	labels["複合" .. pos] = {
		description = "含有兩個或多個詞幹的{{{langname}}}" .. pos .. "。",
		umbrella_parents = "複合詞種類",
		parents = {{name = "複合詞", sort = " "}, pos},
	}
end

labels["compound determinatives"] = {
	description = "{{{langname}}} determinatives composed of two or more stems.",
	parents = {"複合詞", "determiners"},
}

labels["複合詞"] = {
	description = "{{{langname}}}中由兩個或以上詞幹組成的詞彙。",
	parents = {"詞源"},
}

labels["coordinated pairs"] = {
	description = "Terms in {{{langname}}} consisting of a pair of terms joined by a [[coordinating conjunction]].",
	parents = {"詞源"},
}

labels["coordinated triples"] = {
	-- Avoid saying "a coordinating conjunction" or "coordinating conjunctions"
	-- because there can be either one or two conjunctions.
	description = "Terms in {{{langname}}} consisting of three terms joined by [[coordinating conjunction]].",
	parents = {"詞源"},
}

labels["名詞派生詞"] = {
	description = "{{{langname}}}中派生自名詞的詞。",
	parents = {"詞源"},
}

labels["動詞派生詞"] = {
	description = "{{{langname}}}中派生自動詞的詞。",
	parents = {"詞源"},
}

labels["同源對似詞"] = {
	description = "{{{langname}}}中由同一個詞最後派生出來的,在詞形或詞義上相似但不同的詞語。",
	parents = {"詞源"},
}

labels["並列複合詞"] = {
	description = "{{{langname}}} words composed of two or more stems whose stems could be connected by an 'and'.",
	umbrella_parents = "複合詞種類",
	parents = {"複合詞"},
}

labels["elongated forms"] = {
	description = "{{{langname}}} terms where one or more letters or sounds is repeated for emphasis or effect.",
	parents = {"詞源"},
}

labels["endocentric compounds"] = {
	description = "{{{langname}}} words composed of two or more stems, one of which is the [[w:head (linguistics)|head]] of that compound.",
	umbrella_parents = "複合詞種類",
	parents = {"複合詞"},
}

labels["endocentric noun-noun compounds"] = {
	description = "{{{langname}}} words composed of two or more stems, one of which is the [[w:head (linguistics)|head]] of that compound.",
	umbrella_parents = "複合詞種類",
	parents = {"endocentric compounds", "複合詞"},
}

labels["endocentric verb-noun compounds"] = {
	description = "{{{langname}}} compounds in which the first element is a verbal stem, the second a nominal stem and the head of the compound.",
	umbrella_parents = "複合詞種類",
	parents = {"endocentric compounds", "verb-noun compounds"},
}

labels["名祖"] = {
	description = "由真實或虛構人物的名字派生出來的{{{langname}}}詞彙。", -- eponyms
	parents = {"詞源"},
}

labels["exocentric compounds"] = {
	description = "{{{langname}}} words composed of two or more stems, none of which is the [[w:head (linguistics)|head]] of that compound.",
	umbrella_parents = "複合詞種類",
	parents = {"複合詞"},
}

labels["exocentric verb-noun compounds"] = {
	description = "{{{langname}}} compounds in which the first element is a transitive verb, the second a noun functioning as its direct object, and whose referent is the person or thing doing the action.",
	umbrella_parents = "複合詞種類",
	parents = {"exocentric compounds", "verb-noun compounds"},
}

labels["genericized trademarks"] = {
	description = "{{{langname}}} terms that originate from [[trademark]]s, [[brand]]s and company names which have become [[genericized]]; that is, fallen into common usage in the target market's [[vernacular]], even when referring to other competing brands.",
	parents = {"詞源"},
}

labels["ghost words"] = {
	description = "{{{langname}}} terms that were originally erroneous or fictitious, published in a reference work as if they were genuine as a result of typographical error, misreading, or misinterpretation, or as [[:w:Fictitious entry|fictitious entries]], jokes, or hoaxes.",
	parents = {"詞源"},
}

labels["同格限定複合詞"] = {
	description = "{{{langname}}} words composed of two or more stems in which the main stem determines the case endings.",
	umbrella_parents = "複合詞種類",
	parents = {"格限定複合詞"},
}

labels["haplological forms"] = {
	description = "{{{langname}}} terms that underwent [[haplology]]: thus, their origin involved a loss or omission of a repeated sequence of sounds.",
	parents = {"詞源"},
}

labels["homophonic translations"] = {
	description = "{{{langname}}} terms that were borrowed by matching the etymon phonetically, without regard for the sense; compare [[phono-semantic matching]] and [[Hobson-Jobson]].",
	parents = {"詞源"}
}

labels["hybridisms"] = {
	description = "{{{langname}}} words formed by elements of different linguistic origins.",
	parents = {"詞源"},
}

labels["國際詞"] = {
	description = "也出現於大量其他語言,且詞源均相似的{{{langname}}}借詞。",
	additional = "收錄於本分類中的詞語最好屬於直接詞源無法確定的詞。收錄於本分類的詞使用[[Template:internationalism]],詳情參見該模板。",
	parents = {"詞源"},
}

labels["繼承詞"] = {
	description = "{{{langname}}}中繼承自本語言更早期形式的詞彙。",
	parents = {"詞源"},
}

labels["itaretara dvandva compounds"] = {
	description = "{{{langname}}} words composed of two or more stems whose stems could be connected by an 'and'.",
	umbrella_parents = "複合詞種類",
	parents = {"並列複合詞"},
}

labels["古典借詞"] = {
	description = "{{{langname}}}中二次舶來的借詞,即直接從另一語言中整合過來,而非經過一般的語言接觸直接借來的詞。",
	parents = {"借詞"},
}

labels["legal doublets"] = {
	description = "{{{langname}}} legal [[doublet]]s &ndash; a legal doublet is a standardized phrase commonly use in legal documents, proceedings etc which includes two words that are near synonyms.",
	parents = {"coordinated pairs"},
}

labels["legal triplets"] = {
	description = "{{{langname}}} legal [[triplet]]s &ndash; a legal triplet is a standardized phrase commonly use in legal documents, proceedings etc which includes three words that are near synonyms.",
	parents = {"coordinated triples"},
}

labels["merisms"] = {
	description = "{{{langname}}} [[merism]]s &ndash; terms that are [[coordinate]]s that, combined, are a synonym for a totality.",
	parents = {"coordinated pairs"},
}

labels["轉喻"] = {
	description = "{{{langname}}} terms whose origin involves calling a thing or concept not by its own name, but by the name of something intimately associated with that thing or concept.",
	parents = {"詞源"},
}

labels["新詞"] = {
	description = "最近才開始興起的{{{langname}}}詞。",
	parents = {"詞源"},
}

labels["nonce terms"] = {
	description = "{{{langname}}} terms that have been invented for a single occasion.",
	parents = {"詞源"},
}

labels["numeronyms"] = {
	description = "{{{langname}}} terms that serve as number-based names.",
	parents = {"詞源"},
}

labels["擬聲詞"] = {
	description = "發音似其所指代的事物的{{{langname}}}詞。",
	parents = {"詞源"},
}

labels["形譯詞"] = {
	description = "{{{langname}}}的形譯詞,即所借用的是其書體而非其發音的詞。",
	parents = {"借詞"},
}

labels["部分仿譯詞"] = {
	description = "{{{langname}}}的部分仿譯詞,這些詞的詞形部分由逐詞翻譯得來,部分直接借來。",
	parents = {"詞源"},
}

labels["音義兼譯詞"] = {
	description = "{{{langname}}}中在音譯的同時照顧到詞義的詞語。",
	parents = {"借詞"},
}

labels["piecewise doublets"] = {
	description = "{{{langname}}} terms that are [[Appendix:Glossary#piecewise doublet|piecewise doublets]].",
	parents = {"詞源"},
}

labels["偽借詞"] = {
	description = "{{{langname}}} terms that are [[pseudo-loan]]s.",
	parents = {"詞源"},
}

labels["異分析"] = {
	description = "{{{langname}}} terms that have interacted with another word in such a way that the boundary between the words has been modified.",
	parents = {"詞源"}
}

labels["重構詞語"] = {
	description = "{{{langname}}} terms that are not directly attested, but have been reconstructed through other evidence.",
	parents = {"詞源"}
}

labels["reduplicated coordinated pairs"] = {
	description = "{{{langname}}} reduplicated coordinated pairs.",
	parents = {"coordinated pairs", "疊詞"},
}

labels["reduplicated coordinated triples"] = {
	description = "{{{langname}}} reduplicated coordinated triples.",
	parents = {"coordinated triples", "疊詞"},
}

labels["疊詞"] = {
	description = "{{{langname}}}中通過詞根或詞幹的重複構造出的詞彙。",
	parents = {"詞源"},
}

labels["返璞詞"] = {
	description = "{{{langname}}} terms that serve as new unique names for older objects or concepts whose previous names became ambiguous.",
	parents = {"詞源"},
}

labels["押韻複合詞"] = {
	description = "含有兩個或多個押韻詞根的{{{langname}}}名詞短語。",
	umbrella_parents = "複合詞種類",
	parents = {"複合詞", "rhyming phrases"},
}

labels["詞根"] = {
	description = "Basic morphemes from which {{{langname}}} words are formed.",
	parents = {"詞素"},
}

labels["roots by shape"] = {
	description = "{{{langname}}} roots categorized by their shape.",
	parents = {{name = "roots", sort = "shape"}},
}

labels["Sanskritic compounds"] = {
	description = "{{{langname}}} compounds made of [[tatsama|tatsamas]].",
	umbrella_parents = "複合詞種類",
	parents = {"複合詞", "terms derived from Sanskrit"},
}

labels["samahara dvandva compounds"] = {
	description = "{{{langname}}} words composed of two or more stems whose stems could be connected by an 'and'.",
	umbrella_parents = "複合詞種類",
	parents = {"並列複合詞"},
}

labels["意譯詞"] = {
	description = "{{{langname}}}中意譯自其他語言的詞。",
	parents = {"詞源"},
}

labels["半接觸借詞"] = {
	description = "{{{langname}}}的半接觸借詞。這些詞從古典語言借入現代語言,並根據發音變化或與其他繼承詞類比調整了詞形。",
	parents = {"借詞"},
}

labels["sound-symbolic terms"] = {
	description = "{{{langname}}} terms that use {{w|sound symbolism}} to express ideas but which are not necessarily strictly speaking [[onomatopoeic]].",
	parents = {"詞源"},
}

labels["spelled-out initialisms"] = {
	description = "{{{langname}}} initialisms in which the letter names are spelled out.",
	parents = {"詞源"},
}

labels["spelling pronunciations"] = {
	description = "{{{langname}}} terms whose pronunciation was historically or presently affected by their spelling.",
	parents = {"詞源"},
}

labels["spoonerisms"] = {
	description = "{{{langname}}} terms in which the initial sounds of component parts have been exchanged, as in \"crook and nanny\" for \"nook and cranny\".",
	parents = {"詞源"},
}

labels["同義複詞"] = {
	description = "{{{langname}}} compounds in which one part is a synonym of the other.",
	umbrella_parents = "複合詞種類",
	parents = {"並列複合詞", sort = "synonym"},
}

labels["格限定複合詞"] = {
	description = "{{{langname}}} words composed of two or more stems",
	umbrella_parents = "複合詞種類",
	parents = {"複合詞"},
}

labels["依出處分類的詞"] = {
	description = "{{{langname}}}中出自某部著作或某人作品中新創造的詞。",
	parents = {"詞源"},
}

labels["terms derived from area codes"] = {
	description = "{{{langname}}} terms derived from [[area code]]s.",
	parents = {"詞源"},
}

labels["terms derived from the shape of letters"] = {
	description = "{{{langname}}} terms derived from the shape of letters. This can include terms derived from the shape of any letter in any alphabet.",
	parents = {"詞源"},
}

labels["terms by Proto-Indo-European word"] = {
	description = "{{{langname}}} terms categorized by the [[w:Proto-Indo-European language|Proto-Indo-European]] word they originate from.",
	parents = {"詞源", "terms derived from Proto-Indo-European"},
}

labels["依詞根分類的詞"] = {
	description = "{{{langname}}}詞彙,依其起源的詞根分類。",
	parents = {"詞源", {name = "詞根", sort = " "}},
}

labels["出自虛構作品的詞"] = {
	description = "源自虛構作品的{{{langname}}}詞彙。",
	parents = {"依出處分類的詞"},
}

for _, source_and_desc in ipairs({
	{"DC漫畫", "[[w:DC漫畫|DC漫畫]]"},
	{"Duckburg and Mouseton", "[[w:The Walt Disney Company|Disney]]'s ''[[w:Duck universe|Duckburg]] and [[w:Mickey Mouse universe|Mouseton]]'' universe"},
	{"《哈利波特》", "英國作家[[w:J·K·罗琳|J·K·羅琳]]虛構作品《[[w:哈利·波特|-{zh-hans:哈利·波特; zh-hant:哈利波特}-》"},
	{"《一九八四》", "英國作家[[w:乔治·奥威尔|-{zh-hans:乔治·奥威尔; zh-hant:喬治·歐威爾}-]]虛構作品《[[w:一九八四|一九八四]]》"},
	{"《星際爭霸戰》", "美國電視影集《[[w:星際爭霸戰|-{zh-hans:星际旅行:原初系列; zh-hant:星際爭霸戰}-]]》"},
	{"《星際大戰》", "美國系列電影《[[w:星際大戰|-{zh-hans:星球大战; zh-hant:星際大戰}-]]》"},
	{"《辛普森家庭》", "美國動畫《[[w:辛普森一家|-{zh-hans:辛普森一家; zh-hant:辛普森家庭}-]]》"},
	{"托爾金虛構作品", "英國作家[[w:J·R·R·托爾金|J·R·R·托爾金]]所著古典奇幻作品"},
}) do
	local source, desc = unpack(source_and_desc)
	labels["出自" .. source .. "的詞"] = {
		description = "{{{langname}}}中出自" .. desc .. "的詞語。",
		parents = {"出自虛構作品的詞"},
	}
end

labels["terms derived from Greek mythology"] = {
	description = "{{{langname}}} terms derived from Greek mythology which have acquired an idiomatic meaning.",
	parents = {"依出處分類的詞"},
}

labels["派生自職業的詞"] = {
	description = "{{{langname}}}中派生自職業名稱的詞彙。",
	parents = {"詞源"},
}

labels["派生詞"] = {
	description = "{{{langname}}}中派生自其他語言的詞彙。",
	parents = {"詞源"},
}

labels["出自《聖經》的詞"] = {
	description = "{{{langname}}}中出自《[[聖經]]》的詞語。",
	parents = {"依出處分類的詞"},
}

labels["派生自地名的詞"] = {
	description = "{{{langname}}}中出自真實或虛構地名的詞語。",
	parents = {"詞源"},
}

labels["依字型產生的詞"] = {
	description = "{{{langname}}} terms making reference to character shapes.",
	parents = {"詞源"},
}

labels["terms with Indo-Aryan extensions"] = {
	description = "{{{langname}}} terms extended with particular [[Indo-Aryan]] [[pleonastic]] affixes.",
	parents = {"詞源"},
}

labels["terms with lemma and non-lemma form etymologies"] = {
	description = "{{{langname}}} terms consisting of both a lemma and non-lemma form, of different origins.",
	breadcrumb = "lemma and non-lemma form",
	parents = {"terms with multiple etymologies"},
}

labels["有多個詞源的詞"] = {
	description = "起源於多個源頭的{{{langname}}}詞語。",
	parents = {"詞源"},
}

labels["terms with multiple lemma etymologies"] = {
	description = "{{{langname}}} lemmas that are derived from multiple origins.",
	breadcrumb = "multiple lemmas",
	parents = {"terms with multiple etymologies"},
}

labels["terms with multiple non-lemma form etymologies"] = {
	description = "{{{langname}}} non-lemma forms that are derived from multiple origins.",
	breadcrumb = "multiple non-lemma forms",
	parents = {"terms with multiple etymologies"},
}

labels["詞源不明的詞"] = {
	description = "{{{langname}}} terms whose etymologies have not yet been established.",
	parents = {{name = "詞源", sort = "unknown etymology"}},
}

labels["回借詞"] = {
	description = "{{{langname}}}中借自其他語言中某個借自{{{langname}}}的詞的詞。",
	parents = {"詞源", "借詞"},
}

labels["非同化借詞"] = {
	description = "{{{langname}}}中不符合本語言詞法、句法、音系和/或語音組合規則的借詞。",
	parents = {"借詞"},
}

labels["univerbations"] = {
	description = "{{{langname}}} terms that result from the agglutination of two or more words.",
	parents = {"詞源"},
}

labels["verb-noun compounds"] = {
	description = "{{{langname}}} compounds in which the first element is a transitive verb, the second a noun functioning as its direct object, and whose referent is the person or thing doing the action.",
	umbrella_parents = "複合詞種類",
	parents = {"compound nouns"},
}

labels["vrddhi derivatives"] = {
	description = "{{{langname}}} terms derived from a Proto-Indo-European root by the process of [[w:vṛddhi|vṛddhi]] derivation.",
	umbrella_parents = "複合詞種類",
	parents = {"詞源"},
}

labels["vrddhi gerundives"] = {
	description = "{{{langname}}} [[gerundive]]s derived from a Proto-Indo-European root by the process of [[w:vṛddhi|vṛddhi]] derivation.",
	umbrella_parents = "複合詞種類",
	parents = {"vrddhi derivatives"},
}

labels["vyadhikarana compounds"] = {
	description = "{{{langname}}} words composed of two or more stems in which the non-main stem determines the case endings.",
	umbrella_parents = "複合詞種類",
	parents = {"格限定複合詞"},
}

labels["words derived through metathesis"] = {
	description = "{{{langname}}} words that were created through [[metathesis]] from another word.",
	parents = {{name = "詞源", sort = "metathesis"}},
}

for _, fixtype in ipairs({"環綴", "中綴", "間綴", "前綴", "後綴",}) do
	labels["依" .. fixtype .. "分類的詞"] = {
		description = "依" .. fixtype .. "分類的{{{langname}}}詞彙。",
		parents = {{name = "詞源", sort = fixtype}, fixtype},
	}
end

-- Add 'umbrella_parents' key if not already present.
for key, data in pairs(labels) do
	if not data.umbrella_parents then
		data.umbrella_parents = "詞源子分類"
	end
end



-----------------------------------------------------------------------------
--                                                                         --
--                              RAW CATEGORIES                             --
--                                                                         --
-----------------------------------------------------------------------------


raw_categories["詞源子分類"] = {
	description = "Umbrella categories covering topics related to terms categorized by their etymologies, such as types of compounds or borrowings.",
	additional = "{{{umbrella_meta_msg}}}",
	parents = {
		"綜合元分類",
		{name = "詞源", is_label = true, sort = " "},
	},
}

raw_categories["借詞子分類"] = {
	description = "Umbrella categories covering topics related to borrowed terms.",
	additional = "{{{umbrella_meta_msg}}}",
	parents = {
		"綜合元分類",
		{name = "借詞", is_label = true, sort = " "},
		{name = "詞源子分類", sort = " "},
	},
}

raw_categories["繼承詞子分類"] = {
	description = "Umbrella categories covering topics related to inherited terms.",
	additional = "{{{umbrella_meta_msg}}}",
	parents = {
		"綜合元分類",
		{name = "繼承詞", is_label = true, sort = " "},
		{name = "詞源子分類", sort = " "},
	},
}

raw_categories["Indo-Aryan extensions"] = {
	description = "Umbrella categories covering terms extended with particular [[Indo-Aryan]] [[pleonastic]] affixes.",
	additional = "{{{umbrella_meta_msg}}}",
	parents = {
		"綜合元分類",
		{name = "Terms by etymology subcategories by language", sort = " "},
	},
}

raw_categories["Multiple etymology subcategories by language"] = {
	description = "Umbrella categories covering topics related to terms with multiple etymologies.",
	additional = "{{{umbrella_meta_msg}}}",
	parents = {
		"綜合元分類",
		{name = "Terms by etymology subcategories by language", sort = " "},
	},
}

raw_categories["Sanskritic compounds by language"] = {
	description = "Categories with terms made of [[tatsama|tatsamas]].",
	additional = "{{{umbrella_msg}}}",
	parents = {
		"Terms by etymology subcategories by language",
	},
}

raw_categories["複合詞種類"] = {
	description = "Umbrella categories covering topics related to types of compound words.",
	additional = "{{{umbrella_meta_msg}}}",
	parents = {
		"綜合元分類",
		{name = "複合詞", is_label = true, sort = " "},
		{name = "詞源子分類", sort = " "},
	},
}


-----------------------------------------------------------------------------
--                                                                         --
--                                 HANDLERS                                --
--                                                                         --
-----------------------------------------------------------------------------


-----------------------------------------------------------------------------
------------------------------- Root handlers -------------------------------
-----------------------------------------------------------------------------

-- Handlers for 'terms derived from the SOURCE root ROOT' must go *BEFORE* the
-- more general 'terms derived from SOURCE' handler.

local function get_source_and_type_desc(source, term_type)
	if source:getCode() == "ine-pro" and term_type:find("^詞根$") then
		return "[[w:原始印歐語詞根|原始印歐語" .. term_type .. "]]"
	else
		return "[[w:" .. source:getWikipediaArticle() .. "|" .. source:getCanonicalName() .. "]]" .. term_type
	end
end

-- Handler for e.g. [[:Category:Yola terms derived from the Proto-Indo-European root *h₂el- (grow)]] and
-- [[:Category:Russian terms derived from the Proto-Indo-European word *swé]], and corresponding umbrella
-- categories [[:Category:Terms derived from the Proto-Indo-European root *h₂el- (grow)]] and
-- [[:Category:Terms derived from the Proto-Indo-European word *swé]]. Replaces the former
-- [[Module:category tree/PIE root cat]], [[Module:category tree/root cat]] and [[Template:PIE word cat]].
table.insert(handlers, function(data)
	local source_name, term_type, term_and_id = data.label:match("^來自(.+)(詞根)(.+)的(.+)$")
	if not source_name then
		source_name, term_type, term_and_id = data.label:match("^來自(.+)(詞語)(.+)的(.+)$")
	end

	if source_name then
		local term, id = term_and_id:match("^(.+) %((.-)%)$")
		term = term or term_and_id
		local source = require("Module:languages").getByCanonicalName(source_name, true, "allow etym langs")

		local parents = {
			{ name = "依" .. source_name  .. term_type .. "分類的詞", sort = source:makeSortKey(term) }
		}
		local umbrella_parents = {
			{ name = source_name .. term_type .. "詞源", sort = source:makeSortKey(term) }
		}
		if id then
			table.insert(parents, { name = "來自" .. source_name .. term_type .. term .. "的詞", sort = " "})
			table.insert(umbrella_parents, { name = "來自" .. source_name .. term_type .. term .. "的詞", is_label = true, sort = " "})
		end
		-- Italicize the root/word in the title.
		local function displaytitle(title, lang)
			return require("Module:string").plain_gsub(title, term, require("Module:script utilities").tag_text(term, source, nil, "term"))
		end
		local breadcrumb = require("Module:script utilities").tag_text(term, source, nil, "term") .. (id and " (" .. id .. ")" or "")
		return {
			description = "起源於" .. get_source_and_type_desc(source, term_type) ..
				require("Module:links").full_link({ term = term, lang = source, gloss = id, id = id }, "term") .. "的{{{langname}}}詞。",
			displaytitle = displaytitle,
			breadcrumb = breadcrumb,
			parents = parents,
			umbrella = {
				no_by_language = true,
				displaytitle = displaytitle,
				breadcrumb = breadcrumb,
				parents = umbrella_parents,
			}
		}
	end
end)

table.insert(handlers, function(data)
	local source_name = data.label:match("^依(.+)詞分類的詞$")
	if source_name then
		local source = require("Module:languages").getByCanonicalName(source_name, true, "allow etym langs")
		local parents = {"詞源"}
		-- In [[:Category:Proto-Indo-Iranian terms by Proto-Indo-Iranian word]],
		-- don't add parent [[:Category:Proto-Indo-Iranian terms derived from Proto-Indo-Iranian]].
		if not data.lang or data.lang:getCode() ~= source:getCode() then
			table.insert(parents, "派生自" .. source_name .. "的詞")
		end
		return {
			description = "{{{langname}}} terms categorized by the " .. get_source_and_type_desc(source, "word") .. " they originate from.",
			parents = parents,
			umbrella_parents = "Terms by etymology subcategories by language",
		}
	end
end)

table.insert(handlers, function(data)
	local root_and_id = data.label:match("^詞根為(.+)的詞$")
	if root_and_id then
		local root, id = root_and_id:match("^(.+) %((.-)%)$")
		root = root or root_and_id

		-- See if the language is Semitic.
		local fam = data.lang
		local is_semitic = false
		while true do
			if not fam then
				break
			end
			if fam:getCode() == "qfa-not" then
				-- qfa-not is "not a family" and is its own parent
				break
			end
			if fam:getCode() == "sem" then
				is_semitic = true
				break
			end
			fam = fam:getFamily()
		end
		local root_desc = is_semitic and "[[w:en:Semitic root|詞根]]" or "詞根"
		local parents = {{name = "依詞根分類的詞", sort = root_and_id}}
		local separators = "־ %-"
		local separator_c = "[" .. separators .. "]"
		local not_separator_c = "[^" .. separators .. "]"
		-- remove any leading or trailing separators (e.g. in PIE-style roots)
		local root_no_prefix_suffix =
			mw.ustring.gsub(mw.ustring.gsub(root, separator_c .. "$", ""), "^" .. separator_c, "")
		local num_sep = mw.ustring.len(mw.ustring.gsub(root_no_prefix_suffix, not_separator_c, ""))
		local linked_root = data.lang and require("Module:links").full_link({ term = root, lang = data.lang, gloss = id, id = id }, "term") or root
		if num_sep > 0 then
			table.insert(parents, {name = "" .. (num_sep + 1) .. "字母詞根", sort = root_and_id})
		end
		local breadcrumb = require("Module:script utilities").tag_text(root, data.lang, nil, "term") .. (id and " (" .. id .. ")" or "")
		return {
			description = "本分類列出由" .. root_desc .. linked_root .. "構成的{{{langname}}}詞彙。",
			displaytitle = "詞根為" .. require("Module:script utilities").tag_text(root, data.lang, nil, "term") .. "的{{{langname}}}詞",
			breadcrumb = breadcrumb,
			parents = parents,
			umbrella = false,
		}
	end
end)

table.insert(handlers, function(data)
	local num_letters = data.label:match("^([0-9]+)字母詞根$")
	if num_letters then
		return {
			description = "有" .. num_letters .. "個字母的{{{langname}}}詞根。",
			parents = {{name = "詞根", sort = "#" .. num_letters}},
			umbrella_parents = "詞源子分類",
		}
	end
end)

table.insert(handlers, function(data)
	local source_name = data.label:match("^依(.+)詞根分類的.+$")
	if source_name then
		local source = require("Module:languages").getByCanonicalName(source_name, true, "allow etym langs")
		local parents = {"詞源"}
		-- In [[:Category:Proto-Indo-Iranian terms by Proto-Indo-Iranian root]],
		-- don't add parent [[:Category:Proto-Indo-Iranian terms derived from Proto-Indo-Iranian]].
		if not data.lang or data.lang:getCode() ~= source:getCode() then
			table.insert(parents, "派生自" .. source_name .. "的詞")
		end
		return {
			description = "{{{langname}}}詞彙,依其起源的" .. get_source_and_type_desc(source, "詞根") .. "分類。",
			parents = parents,
			umbrella_parents = "詞源子分類",
		}
	end
end)

table.insert(handlers, function(data)
	local root_shape = data.label:match("^(.+)-shape roots$")
	if root_shape then
		local description = "{{{langname}}} roots with the shape ''" .. root_shape .. "''."
		local additional
		if data.lang and data.lang:getCode() == "ine-pro" then
			additional = [=[
* '''e''' stands for the vowel of the root.
* '''C''' stands for any stop or ''s''.
* '''R''' stands for any resonant.
* '''H''' stands for any laryngeal.
* '''M''' stands for ''m'' or ''w'', when followed by a resonant.
* '''s''' stands for ''s'', when next to a stop.]=]
		end
		return {
			description = description,
			additional = additional,
			breadcrumb = root_shape,
			parents = {{name = "roots by shape", sort = root_shape}},
			umbrella = false,
		}
	end
end)


-----------------------------------------------------------------------------
-------------------- Derived/inherited/borrowed handlers --------------------
-----------------------------------------------------------------------------

-- Handler for categories of the form "派生自SOURCE的LANG詞", where SOURCE is a language, etymology language
-- or family (e.g. "Indo-European languages"), along with corresponding umbrella categories of the form
-- "派生自SOURCE的詞".
table.insert(handlers, function(data)
	local source_name = data.label:match("^派生自(.+)的詞$")
	if source_name then
		-- FIXME, should we allow 'terms derived from taxonomic names' when mul-tax has canonical name
		-- 'taxonomic name'? This is equivalent to what [[Module:category tree/derived cat]] did.
		-- Maybe fix mul-tax instead.
		local source = require("Module:languages").getByCanonicalName(source_name, true,
			"allow etym langs", "allow families")
		if not source then return nil end
		local source_desc = source:makeCategoryLink()

		-- Compute description.
		local desc = "起源於" .. source_desc .. "的{{{langname}}}詞彙。"
		local additional
		if source:hasType("family") then
			additional = "理想情況下,本分類應僅含有其他分類。如果詞條歸屬的子分類不明確,也可將之歸類於此。" ..
				"如果您知道本分類内的詞條派生自何種語言,請直接編輯相應的詞條。"
		end
		
		-- Compute parents.
		local derived_from_subvariety_of_self = false
		local parent
		local sortkey = source:getDisplayForm()
		if source:hasType("etymology-only") then
			-- By default, `parent` is the source's parent.
			parent = source:getParent()
			-- Check if the source is a variety (or subvariety) of the language.
			if data.lang and source:hasParent(data.lang) then
				derived_from_variety_of_self = true
			end
			-- If the language is the direct parent of the source or the parent is "und", then we use the family of the source as `parent` instead.
			if data.lang and (parent:getCode() == data.lang:getCode() or parent:getCode() == "und") then
				parent = source:getFamily()
			end
		-- Regular language or family.
		else
			local fam = source:getFamily()
			if fam then
				parent = fam
			end
		end
		-- If `parent` does not exist, is the same as `source`, or would be "isolate languages" or "not a family", then we discard it.
		if (not parent) or parent:getCode() == source:getCode() or parent:getCode() == "qfa-iso" or parent:getCode() == "qfa-not" then
			parent = nil
			derived_from_variety_of_self = false
		-- Otherwise, get the display form.
		else
			parent = parent:getDisplayForm()
		end
		parent = parent and "派生自" .. parent .. "的詞" or "派生詞"
		local parents = {{name = parent, sort = sortkey}}
		if derived_from_subvariety_of_self then
			table.insert(parents, "Category:Categories for terms in a language derived from a term in a subvariety of that language")
		end

		-- Compute umbrella parents.
		local umbrella_parents = {
			source:hasType("family") and {name = source:getCategoryName(), raw = true, sort = " "} or
			source:hasType("etymology-only") and {name = "Category:" .. source:getCategoryName(), sort = "派生自"} or
			{name = source:getCategoryName(), raw = true, sort = "派生自"}
		}

		return {
			description = desc,
			additional = additional,
			breadcrumb = source_name,
			parents = parents,
			umbrella = {
				no_by_language = true,
				description = "收錄起源於" .. source_desc .. "的詞語的分類。",
				parents = umbrella_parents,
			},
		}
	end
end)


-- Handler for e.g. [[:Category:Yola terms derived from the Proto-Indo-European word *h₂el- (grow)]] and
-- [[:Category:Russian terms derived from the Proto-Indo-European word *swé]], and corresponding umbrella
-- categories [[:Category:Terms derived from the Proto-Indo-European word *h₂el- (grow)]] and
-- [[:Category:Terms derived from the Proto-Indo-European word *swé]]. Replaces the former
-- [[Module:category tree/PIE word cat]], [[Module:category tree/word cat]] and [[Template:PIE word cat]].
table.insert(handlers, function(data)
	local source_name, term_type, term_and_id = data.label:match("^派生自(.+)(詞)(.+)的詞$")

	if source_name then
		local term, id = term_and_id:match("^(.+) %((.-)%)$")
		term = term or term_and_id
		local source = require("Module:languages").getByCanonicalName(source_name, true, "allow etym langs")

		local parents = {
			{ name = "依" .. source_name .. term_type .. "分類的詞", sort = source:makeSortKey(term) }
		}
		local umbrella_parents = {
			{ name = "派生自" .. source_name .. term_type .. "的詞", sort = source:makeSortKey(term) }
		}
		if id then
			table.insert(parents, { name = "派生自" .. source_name .. term_type .. term .. "的詞", sort = " "})
			table.insert(umbrella_parents, { name = "派生自" .. source_name .. term_type .. term .. "的詞", is_label = true, sort = " "})
		end
		-- Italicize the word/word in the title.
		local function displaytitle(title, lang)
			return require("Module:string").plain_gsub(title, term, require("Module:script utilities").tag_text(term, source, nil, "term"))
		end
		local breadcrumb = require("Module:script utilities").tag_text(term, source, nil, "term") .. (id and " (" .. id .. ")" or "")
		return {
			description = "{{{langname}}}中最終源自" .. get_source_and_type_desc(source, term_type) .. " " ..
				require("Module:links").full_link({ term = term, lang = source, gloss = id, id = id }, "term") .. "的詞彙。",
			displaytitle = displaytitle,
			breadcrumb = breadcrumb,
			parents = parents,
			umbrella = {
				no_by_language = true,
				displaytitle = displaytitle,
				breadcrumb = breadcrumb,
				parents = umbrella_parents,
			}
		}
	end
end)

local function get_source_and_source_desc(source_name)
	local source = require("Module:languages").getByCanonicalName(source_name, true, "allow etym langs", "allow families")
	local source_desc = source:makeCategoryLink()
	if source:hasType("family") then
		source_desc = "unknown " .. source_desc
	end
	return source, source_desc
end


-- Handler for categories of the form "借/繼承自SOURCE的LANG詞", where SOURCE is a language,
-- etymology language or family (e.g. "Indo-European languages"). Also handles umbrella categories of the form
-- "借/繼承自SOURCE的詞".
local function inherited_borrowed_handler(etymtype)
	return function(data)
		local source_name = data.label:match("^源自(.+)的" .. etymtype .. "$")
		if source_name then
			local source, source_desc = get_source_and_source_desc(source_name)
			return {
				description = "{{{langname}}}中源自" .. source_desc .. "的" .. etymtype .. "。",
				breadcrumb = source_name,
				parents = {
					{ name = etymtype, sort = source_name },
					{ name = "派生自" .. source_name .. "的詞", sort = " "},
				},
				umbrella = {
					no_by_language = true,
					parents = {
						{ name = "派生自" .. source_name .. "的詞", is_label = true, sort = " " },
						etymtype == "繼承詞" and
							{ name = "繼承詞子分類", sort = source_name }
						-- There are several types of borrowings mixed into the following holding category,
						-- so keep these ones sorted under '借自SOURCE_NAME的詞' instead of just
						-- 'SOURCE_NAME'.
						or "借詞子分類",
					}
				},
			}
		end
	end
end

table.insert(handlers, inherited_borrowed_handler("借詞"))
table.insert(handlers, inherited_borrowed_handler("繼承詞"))


-----------------------------------------------------------------------------
------------------------ Borrowing subtype handlers -------------------------
-----------------------------------------------------------------------------

local function borrowing_subtype_handler(source_name, parent_cat, desc, no_by_language)
	local source, source_desc = get_source_and_source_desc(source_name)
	return {
		description = "{{{langname}}}中" .. desc:gsub("SOURCE", source_desc),
		breadcrumb = source_name,
		parents = {
			{ name = parent_cat, sort = source_name },
			{ name = "源自" .. source_name .. "的借詞", sort = " " },
		},
		umbrella = {
			no_by_language = no_by_language,
			parents = {
				{ name = "源自" .. source_name .. "的借詞", is_label = true, sort = " " },
				"借詞子分類",
			}
		},
	}
end

local borrowing_descriptions = {
	["古典借詞"] =
		"terms that are learned [[loanword]]s from SOURCE, that is, words that were directly incorporated from SOURCE instead of through normal language contact.",
	["半接觸借詞"] =
		"terms that are [[semi-learned borrowing|semi-learned]] [[loanword]]s from SOURCE, that is, words borrowed from SOURCE (a [[classical language]]) into the target language (a modern language) and partly reshaped based on later [[sound change]]s or by analogy with [[inherit]]ed words in the language.",
	["形譯詞"]	=
		"terms that are orthographic loans from SOURCE, i.e. words that were borrowed from SOURCE in their script forms, not their pronunciations.",
	["非同化借詞"] =
		"[[loanword]]s from SOURCE that have not been conformed to the morpho-syntactic, phonological and/or phonotactical rules of the target language.",
}

table.insert(handlers, function(data)
	local source_name, borrowing_type = data.label:match("^源自(.+)的(.+詞)$")
	if borrowing_type and borrowing_descriptions[borrowing_type] then
		return borrowing_subtype_handler(source_name, borrowing_type, borrowing_descriptions[borrowing_type])
	end
end)

table.insert(handlers, function(data)
	local source_name = data.label:match("^源自(.+)的意譯詞$")
	if source_name then
		return borrowing_subtype_handler(source_name, "意譯詞",
			"[[Appendix:術語表#意譯|意譯]]自SOURCE的詞語。",
			"no by language")
	end
end)

table.insert(handlers, function(data)
	local source_name = data.label:match("^源自(.+)的部分仿譯詞$")
	if source_name then
		return borrowing_subtype_handler(source_name, "部分仿譯詞",
			"源自SOURCE的[[Appendix:術語表#部分仿譯|部分仿譯]]詞。",
			"no by language")
	end
end)

table.insert(handlers, function(data)
	local source_name = data.label:match("^源自(.+)的仿譯詞$")
	if source_name then
		return borrowing_subtype_handler(source_name, "仿譯詞",
			"源自SOURCE的[[Appendix:術語表#仿譯|仿譯]]詞。",
			"no by language")
	end
end)

table.insert(handlers, function(data)
	local source_name = data.label:match("^源自(.+)的音義兼譯詞$")
	if source_name then
		return borrowing_subtype_handler(source_name, "音義兼譯詞",
			"源自SOURCE的[[w:en:Phono-semantic matching|音義兼譯]]詞。",
			"no by language")
	end
end)

table.insert(handlers, function(data)
	local source_name = data.label:match("^源自(.+)的偽借詞$")
	if source_name then
		return borrowing_subtype_handler(source_name, "偽借詞",
			"源自SOURCE的[[w:en:pseudo-loan|偽借詞]]。",
			"no by language")
	end
end)

table.insert(handlers, function(data)
	local source_name = data.label:match("^源自(.+)的古典借詞$")
	if source_name then
		return borrowing_subtype_handler(source_name, "古典借詞",
			"源自SOURCE的古典借詞。",
			"no by language")
	end
end)

table.insert(handlers, function(data)
	local source_name = data.label:match("^源自(.+)的半接觸借詞$")
	if source_name then
		return borrowing_subtype_handler(source_name, "半接觸借詞",
			"源自SOURCE的半接觸借詞。",
			"no by language")
	end
end)

table.insert(handlers, function(data)
	local source_name = data.label:match("^源自(.+)的非同化借詞$")
	if source_name then
		return borrowing_subtype_handler(source_name, "非同化借詞",
			"源自SOURCE的非同化借詞。",
			"no by language")
	end
end)

table.insert(handlers, function(data)
	local source_name = data.label:match("^源自(.+)的形譯詞$")
	if source_name then
		return borrowing_subtype_handler(source_name, "形譯詞",
			"源自SOURCE的形譯詞。",
			"no by language")
	end
end)

-----------------------------------------------------------------------------
------------------------------ Affix handlers -------------------------------
-----------------------------------------------------------------------------

table.insert(handlers, function(data)
	local affixtype, term_and_id, pos = mw.ustring.match(data.label, "^含有(..?綴)(.+)的(.+)$")
	if affixtype then
		local term, id = term_and_id:match("^(.+) %(([^()]+)%)$")
		term = term or term_and_id

		-- Convert term/alt into affixes if needed
		local desc = {
			["前綴"]	= "含有前綴",	--Prefix
			["後綴"]	= "含有後綴",	--Suffix
			["環綴"]	= "含有環綴",	--Circumfix
			["複綴"]	= "含有複綴",	--Duplifix
			["中綴"]	= "含有中綴",	--Infix
			["間綴"]	= "含有間綴",	--Interfix
			["插綴"]	= "含有插綴",	--Transfix
			["同綴"]	= "含有同綴",	--Simulfix
			["超音綴"]	= "含有超音綴",	--Suprafix
			["減綴"]	= "含有減綴",	--Disfix
		}
		if not desc[affixtype] then
			return nil
		end

		local params = {
			["alt"] = {},
			["sc"] = {},
			["sort"] = {},
			["tr"] = {},
		}
		local english = {
			["前綴"] = "prefix",
			["後綴"] = "suffix",
			["環綴"] = "circumfix",
			["中綴"] = "infix",
			["間綴"] = "interfix",
			["插綴"] = "transfix",
		}
		local args = require("Module:parameters").process(data.args, params)
		local sc = data.sc or args.sc and require("Module:scripts").getByCode(args.sc, "sc") or nil
		local m_compound = require("Module:compound")
		term = m_compound.make_affix(term, data.lang, sc, english[affixtype])
		alt = m_compound.make_affix(args.alt, data.lang, sc, english[affixtype])
		local tr = m_compound.make_affix(args.tr, data.lang, require("Module:scripts").getByCode("Latn"), english[affixtype])
		local m_script_utilities = require("Module:script utilities")
		local id_text = id and " (" .. id .. ")" or ""

		-- Compute parents.
		local parents = {}
		if id then
			if pos ~= "詞" then
				table.insert(parents, {name = "含有" .. affixtype .. term_and_id .."的詞", sort = id .. ", " .. pos, args = args})
			end
		elseif pos ~= "詞" then
			table.insert(parents, {name = "含有" .. affixtype .. term_and_id .."的詞", sort = pos, args = args})
		end
		table.insert(parents, {name = "依" .. affixtype .. "分類的詞", sort = data.lang:makeSortKey(data.lang:makeEntryName(args.sort or term))})

		local kanji = '㐀-䶵一-鿌豈-龎𠀀-𯨟' -- [[Module:Ja]].script(f)
		return {
			description = "{{{langname}}}中" .. desc[affixtype] .. require("Module:links").full_link({
				lang = data.lang, term = term, alt = alt, sc = sc, id = id, tr = tr}, "term") .. "的" .. pos .. "。",
			breadcrumb = pos == "詞" and m_script_utilities.tag_text(alt or term, data.lang, sc, "term") .. id_text or pos,
			displaytitle = "含有" .. affixtype ..  mw.text.encode(m_script_utilities.tag_text(term, data.lang, sc, "term"), kanji) .. id_text .. "的{{{langname}}}" .. pos,
			parents = parents,
			umbrella = false,
		}, true -- true = args handled
	end
end)


-----------------------------------------------------------------------------
---------------------------- Coined-by handlers -----------------------------
-----------------------------------------------------------------------------

table.insert(handlers, function(data)
	local coiner = data.label:match("^由(.+)所創造的新詞$")
	if coiner then
		return {
			description = "{{{langname}}}中由" .. coiner .. "所創造的新詞。",
			breadcrumb = coiner,
			parents = {{
				name = "新創詞",
				sort = coiner,
			}},
			umbrella = false,
		}
	end
end)


-----------------------------------------------------------------------------
--                                                                         --
--                                RAW HANDLERS                             --
--                                                                         --
-----------------------------------------------------------------------------


-- Handler for umbrella metacategories of the form e.g. [[:Category:Terms derived from Proto-Indo-Iranian roots]]
-- and [[:Category:Terms derived from Proto-Indo-European words]]. Replaces the former
-- [[Module:category tree/PIE root cat]], [[Module:category tree/root cat]] and [[Template:PIE word cat]].
table.insert(raw_handlers, function(data)
	local source_name, terms_type = data.category:match("^(.+)(詞根)詞源$")
	if not source_name then
		source_name, terms_type = data.category:match("^(.+)(詞語)詞源$")
	end
	if not source_name then
		source_name, terms_type = data.category:match("^(.+)(詞語)詞源$")
	end
	if source_name then
		local source = require("Module:etymology languages").getByCanonicalName(source_name) or
			require("Module:languages").getByCanonicalName(source_name)

		return {
			description = "Umbrella categories covering terms derived from particular " .. get_source_and_type_desc(source, terms_type) .. ".",
			additional = "{{{umbrella_meta_msg}}}",
			parents = {
				"綜合元分類",
				{ name = terms_type == "詞根" and "詞根" or "詞元", is_label = true, lang = source:getCode(), sort = " " },
				{ name = "派生自" .. source_name .. "的詞", is_label = true, sort = " " .. terms_type },
			},
		}
	end
end)

return {LABELS = labels, RAW_CATEGORIES = raw_categories, HANDLERS = handlers, RAW_HANDLERS = raw_handlers}