(Translated by https://www.hiragana.jp/)
模組:Category tree/poscatboiler/data/names - 维基词典,自由的多语言词典 とべ转到内容ないよう

ぐみ:Category tree/poscatboiler/data/names

維基てん自由じゆうてきげんてん

ぺーじめん


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


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


labels["名字みょうじ"] = {
	description = "よう於指だい特定とくてい個人こじんあるぐんたいてき{{{langname}}}。",
	umbrella_parents = {name = "語義ごぎ分類ぶんるいてき", is_label = true, sort = " "},
	parents = {"語義ごぎ分類ぶんるいてき", "專有せんゆう名詞めいし"},
}

labels["女性じょせい名字みょうじゆびだい"] = {
	description = "きゅう女性じょせい個體こたいてき{{{langname}}}ゆびだい名稱めいしょう。",
	breadcrumb = "ゆびだい",
	parents = {"女性じょせい名字みょうじ", "ゆびだい名詞めいし"},
}

labels["男性だんせい名字みょうじゆびだい"] = {
	description = "きゅう男性だんせい個體こたいてき{{{langname}}}ゆびだい名字みょうじ。",
	breadcrumb = "ゆびだい",
	parents = {"男性だんせい名字みょうじ", "ゆびだい名詞めいし"},
}

labels["中性ちゅうせい名字みょうじゆびだい"] = {
	description = "きゅう女性じょせいある男性だんせい個體こたいてき{{{langname}}}ゆびだい名字みょうじ。",
	breadcrumb = "ゆびだい",
	parents = {"中性ちゅうせい名字みょうじ", "ゆびだい名詞めいし"},
}

labels["通性つうせい姓氏せいし"] = {
	description = "男性だんせい女性じょせい家庭かてい成員せいいん共用きょうようてき{{{langname}}}名字みょうじ,而該げん區分くぶん男性だんせい女性じょせい姓氏せいし。",
	breadcrumb = "common-gender",
	parents = {"surnames"},
}

labels["女性じょせい名字みょうじゆびしょう"] = {
	description = "女性じょせい個體こたいてき{{{langname}}}ゆびしょう。",
	breadcrumb = "ゆびしょう",
	parents = {"女性じょせい名字みょうじ", "ゆびしょう名詞めいし"},
}

labels["男性だんせい名字みょうじゆびしょう"] = {
	description = "男性だんせい個體こたいてき{{{langname}}}ゆびしょう。",
	breadcrumb = "ゆびしょう",
	parents = {"男性だんせい名字みょうじ", "ゆびしょう名詞めいし"},
}

labels["中性ちゅうせい名字みょうじゆびしょう"] = {
	description = "{女性じょせいある男性だんせい個體こたいてき{{{langname}}}ゆびしょう。",
	breadcrumb = "ゆびしょう",
	parents = {"中性ちゅうせい名字みょうじ", "ゆびしょう名詞めいし"},
}

labels["女性じょせい名字みょうじ"] = {
	description = "女性じょせい個體こたいてき{{{langname}}}名字みょうじ。",
	breadcrumb = "female",
	parents = {"人名じんめい"},
}

labels["female skin names"] = {
	description = "{{{langname}}} skin names given to female individuals.",
	breadcrumb = "female",
	parents = {"skin names"},
}

labels["女性じょせい姓氏せいし"] = {
	description = "{{{langname}}}ちゅう女性じょせい家庭かてい成員せいいん共用きょうようてき名稱めいしょう。",
	breadcrumb = "女性じょせい",
	parents = {"姓氏せいし"},
}

labels["人名じんめい"] = {
	description = "個體こたいてき{{{langname}}}名字みょうじ。",
	parents = {"名字みょうじ"},
}

labels["男性だんせい名字みょうじ"] = {
	description = "男性だんせい個體こたいてき{{{langname}}}名字みょうじ。",
	breadcrumb = "男性だんせい",
	parents = {"人名じんめい"},
}

labels["male skin names"] = {
	description = "{{{langname}}} skin names given to male individuals.",
	breadcrumb = "male",
	parents = {"skin names"},
}

labels["男性だんせい姓氏せいし"] = {
	description = "{{{langname}}}ちゅう男性だんせい家庭かてい成員せいいん共用きょうようてき名稱めいしょう。",
	breadcrumb = "男性だんせい",
	parents = {"姓氏せいし"},
}

labels["ははめい"] = {
	description = "表明ひょうめいいち個人こじんてき母親ははおや祖母そぼある較早てき女性じょせい祖先そせんてき{{{langname}}}名字みょうじ。",
	parents = {"名字みょうじ"},
}

labels["nomina gentilia"] = {
	description = "A Roman [[nomen gentile]] was the \"[[family name]]\" in the [[w:Roman naming convention|convential Roman name]].",
	parents = {"名字みょうじ"},
}

labels["ちちめい"] = {
	description = "表明ひょうめいいち個人こじんてき父親ちちおや祖父そふある較早てき男性だんせい祖先そせんてき{{{langname}}}名字みょうじ。",
	parents = {"名字みょうじ"},
}

labels["skin names"] = {
	description = "{{{langname}}} terms given at birth that are used to refer to individuals from specific marital classes.",
	parents = {"proper nouns", "names"},
}

labels["姓氏せいし"] = {
	description = "よう表示ひょうじいち個人こじんてき家族かぞく血緣けつえん關係かんけいてき{{{langname}}}しるべ符號ふごう。",
	parents = {"名字みょうじ"},
}

labels["中性ちゅうせい名字みょうじ"] = {
	description = "男性だんせいある女性じょせい個體こたいてき{{{langname}}}名字みょうじ。",
	breadcrumb = "中性ちゅうせい",
	parents = {"人名じんめい"},
}

labels["unisex skin names"] = {
	description = "{{{langname}}} skin names given either to male or to female individuals.",
	breadcrumb = "unisex",
	parents = {"skin names"},
}

labels["そとめい"] = {
	description = "{{{langname}}}そとめいある他稱たしょうそく{{{langname}}}名稱めいしょうあずからいみなもとげん名稱めいしょう不同ふどうてき地名ちめい。",
	parents = {"名字みょうじ"},
}

labels["renderings of foreign personal names"] = {
	description = "{{{langname}}} transliterations, respellings or other renderings of foreign personal names.",
	parents = {"names"},
}

labels["氏族しぞくめい"] = {
	description = "{{{langname}}}ちゅう氏族しぞくてき名稱めいしょう。",
	parents = {"名字みょうじ"},
}

labels["家名かめい"] = {
	description = "{{{langname}}}ちゅう家屋かおくてき名稱めいしょう。",
	parents = {"名字みょうじ"},
}

labels["地名ちめい"] = {
	description = "{{{langname}}}ちゅうぼうてき名字みょうじ。",
	parents = {"名字みょうじ"},
}

-- 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 = "涵蓋あずか名字みょうじ相關そうかん主題しゅだいてき綜合そうごう分類ぶんるい。",
	additional = "{{{umbrella_meta_msg}}}",
	parents = {
		"綜合そうごうもと分類ぶんるい",
		{name = "名字みょうじ", is_label = true, sort = " "},
	},
}


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


local function source_name_to_source(nametype, source_name)
	local special_sources
	if nametype:find("人名じんめい") then
		special_sources = require("Module:table").listToSet {
			"姓氏せいし", "地名ちめい", "しん", "せいけい", "つき份名"
		}
	elseif nametype:find("姓氏せいし") then
		special_sources = require("Module:table").listToSet {
			"名字みょうじ", "地名ちめい", "職業しょくぎょう", "ちちめい", "ははめい",
			"つうめい", "暱稱", "民族みんぞくめい"
		}
	else
		special_sources = {}
	end
	if special_sources[source_name] then
		return source_name
	else
		return require("Module:languages").getByCanonicalName(source_name, nil,
			"allow etym langs", "allow families")
	end
end

local function get_source_text(source)
	if type(source) == "table" then
		return source:getDisplayForm()
	else
		return source
	end
end

local function get_description(lang, nametype, source)
	local origintext, addltext
	if source == "姓氏せいし" then
		origintext = "姓氏せいし"
	elseif source == "人名じんめい" then
		origintext = "人名じんめい"
	elseif source == "昵稱" then
		origintext = "昵稱"
	elseif source == "地名ちめい" then
		origintext = "地名ちめい"
		addltext = " たい於亦さくせいようてき地名ちめい,請參" .. (
			lang and "[[:Category:姓氏せいしてき{{{langname}}} " .. nametype .. "]]" or
			"[[:Category:姓氏せいしてき" .. nametype .. "]]"
		) .. "。"
	elseif source == "つうめい" then
		origintext = "つうめい"
	elseif source == "しん" then
		origintext = "起源きげん於人づくりしん"
		addltext = "包括ほうかつ人造じんぞう名字みょうじもと虛構きょこう人物じんぶつてき名字みょうじ兩個りゃんこたんある名字みょうじてき組合くみあいたい於來げん不明ふめいてき名字みょうじ,如果強烈きょうれつ懷疑かいぎ它們しん,也可以收錄しゅうろくざいほん分類ぶんるいちゅう。"
	elseif source == "職業しょくぎょう" then
		origintext = "起源きげん於職ぎょう"
	elseif source == "ちちめい" then
		origintext = "起源きげん於父めい"
	elseif source == "せいけい" then
		-- Hack esp. for Hawaiian names. We should consider changing them to
		-- have the source as Biblical Hebrew and mention the derivation from
		-- the Bible some other way.
		origintext = "起源きげん於聖けい"
	elseif type(source) == "string" then
		error("內部錯誤さくご無法むほう識別しきべつてきらいげん\"" .. source .. "\"ただのうはまうつし特定とくていてきいくしゅ")
	else
		local catname = source:getCategoryName()
		origintext = "みなもと[[:Category:" .. catname .. "|" .. catname .. "]]"
		if lang and source:getCode() == lang:getCode() then
			addltext = "這些名字みょうじらいげん於普どおりてき名詞めいし當地とうちてき神話しんわとう。"
		end
	end
	local introtext
	if lang then
		introtext = "{{{langname}}}"
	else
		introtext = "ほん分類ぶんるい收錄しゅうろく"
	end
	return introtext .. nametype .. origintext ..
		"。(包括ほうかつざい該語げんてき較早階段かいだん派生はせいてき名字みょうじ。)" .. (addltext or "")
end

-- If one of the following families occurs in any of the ancestral families
-- of a given language, use it instead of the three-letter parent
-- (or immediate parent if no three-letter parent).
local high_level_families = require("Module:table").listToSet {
	-- Indo-European
	"gem", -- Germanic (for gme, gmq, gmw)
	"inc", -- Indic (for e.g. pra = Prakrit)
	"ine-ana", -- Anatolian (don't keep going to ine)
	"ine-toc", -- Tocharian (don't keep going to ine)
	"ira", -- Iranian (for e.g. xme = Median, xsc = Scythian)
	"sla", -- Slavic (for zle, zls, zlw)
	-- Other
	"ath", -- Athabaskan (for e.g. apa = Apachean)
	"poz", -- Malayo-Polynesian (for e.g. pqe = Eastern Malayo-Polynesian)
	"cau-nwc", -- Northwest Caucasian
	"cau-nec", -- Northeast Caucasian
}

local function find_high_level_family(lang)
	local family = lang:getFamily()
	-- (1) If no family, return nil (e.g. for Pictish).
	if not family then
		return nil
	end
	-- (2) See if any ancestor family is in `high_level_families`.
	-- if so, return it.
	local high_level_family = family
	while high_level_family do
		local high_level_code = high_level_family:getCode()
		if high_level_code == "qfa-not" then
			-- "not a family"; its own parent, causing an infinite loop.
			-- Break rather than return so we get categories like
			-- [[Category:English female given names from sign languages]] and
			-- [[Category:English female given names from constructed languages]].
			break
		end
		if high_level_families[high_level_code] then
			return high_level_family
		end
		high_level_family = high_level_family:getFamily()
	end
	-- (3) If the family is of the form 'FOO-BAR', see if 'FOO' is a family.
	-- If so, return it.
	local basic_family = family:getCode():match("^(.-)%-.*$")
	if basic_family then
		basic_family = require("Module:families").getByCode(basic_family)
		if basic_family then
			return basic_family
		end
	end
	-- (4) Fall back to just the family itself.
	return family
end

local function match_gendered_nametype(nametype)
	local gender, label = nametype:match("^([男女だんじょちゅう]せい)(名字みょうじ)$")
	if gender then
		return gender, label
	end
end

local function get_parents(lang, nametype, source)
	local parents = {}

	if lang then
		table.insert(parents, {name = nametype, sort = get_source_text(source)})
		if type(source) == "table" then
			table.insert(parents, {name = "派生はせい" .. source:getDisplayForm() .. "てき", sort = " "})
			-- If the source is a regular language, put it in a parent category for the high-level language family, e.g. for
			-- "Russian female given names from German", put it in a parent category "Russian female given names from Germanic languages"
			-- (skipping over West Germanic languages).
			--
			-- If the source is an etymology language, put it in a parent category for the parent non-etymology language, e.g. for
			-- "French male given names from Gascon", put it in a parent category "French male given names from Occitan".
			--
			-- If the source is a family, put it in a parent category for the parent family.
			if source:hasType("family") then
				local parent_family = source:getFamily()
				if parent_family and parent_family:getCode() ~= "qfa-not" then
					table.insert(parents, {
						name = "" .. parent_family:getDisplayForm() .. "てき" .. nametype,
						sort = source:getCanonicalName()
					})
				end
			elseif source:hasType("etymology-only") then
				local source_parent = source:getFull()
				if source_parent and source_parent:getCode() ~= "und" then
					table.insert(parents, {
						name = "" ..source_parent:getDisplayForm() .. "てき" .. nametype,
						sort = source:getCanonicalName()
					})
				end
			else
				local high_level_family = find_high_level_family(source)
				if high_level_family then -- may not exist, e.g. for Pictish
					table.insert(parents,
						{name = "" .. high_level_family:getDisplayForm() .. "てき" .. nametype,
						sort = source:getCanonicalName()
					})
				end
			end
		end
	
		local gender, label = match_gendered_nametype(nametype)
		if gender then
			table.insert(parents, {name = "" .. get_source_text(source) .. "てき" .. label, sort = gender})
		end
	else
		local gender, label = match_gendered_nametype(nametype)
		if gender then
			table.insert(parents, {name = "" .. get_source_text(source) .. "てき" .. label, is_label = true, sort = " "})
		elseif type(source) == "table" then
			-- FIXME! This is duplicated in [[Module:category tree/poscatboiler/data/terms by etymology]] in the
			-- handler for umbrella categories 'Terms derived from SOURCE'.
			local first_umbrella_parent =
				source:hasType("family") and {name = source:getCategoryName(), raw = true, sort = " "} or
				source:hasType("etymology-only") and {name = "Category:" .. source:getCategoryName(), sort = nametype} or
				{name = source:getCategoryName(), raw = true, sort = nametype}
			table.insert(parents, first_umbrella_parent)
		end
		table.insert(parents, "名字みょうじ分類ぶんるい")
	end
	
	return parents
end

table.insert(handlers, function(data)
	local source_name, nametype = data.label:match("^(.+)てき(.*[稱名しょうみょう姓氏せいし])$")
	if nametype then
		local m_table = require("Module:table")
		local personal_name_types = m_table.listToSet(require("Module:names").personal_name_types)
		if not personal_name_types[nametype] then
			return nil
		end
		local source = source_name_to_source(nametype, source_name)
		if not source then
			return nil
		end
		return {
			description = get_description(data.lang, nametype, source),
			breadcrumb = "" .. get_source_text(source),
			parents = get_parents(data.lang, nametype, source),
			umbrella = {
				description = get_description(nil, nametype, source),
				parents = get_parents(nil, nametype, source),
			},
		}
	end
end)



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


-- Handler for e.g. 'en:Russian male given names'.
table.insert(raw_handlers, function(data)
	local langcode, label = data.category:match("^([a-z-]+):(.*)$")
	if langcode then
		local personal_name_types = require("Module:names").personal_name_types
		for _, nametype in ipairs(personal_name_types) do
			local sourcename = label:match("^(.+) " .. nametype .. "$")
			
			if sourcename then
				local source = require("Module:languages").getByCanonicalName(sourcename, nil, "allow etym")
				if source then
					return {
						description = "Transliterations of " .. source:makeCategoryLink() .. " " .. nametype .. " into {{{langlink}}}.",
						lang = langcode,
						breadcrumb = sourcename .. " " .. nametype,
						parents = {
							{ module = "topic cat", args = {code = "{{{langcode}}}", label = "Transliteration of personal names"}, sort = sourcename },
							{ name = nametype, is_label = true, lang = source:getCode(), sort = "{{{langname}}}" },
						},
					}
				end
			end
		end
	end
end)


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