Пређи на садржај

Модул:category tree/poscatboiler/data/lang-specific/ja-ryu

Документацију овог модула можете да направите на страници Модул:category tree/poscatboiler/data/lang-specific/ja-ryu/док

local export = {}

local Hira = require("Модул:scripts").getByCode("Hira")
local m_numeric = require("Модул:ConvertNumeric")
local rmatch = mw.ustring.match


function export.add_labels(labels, lang)
	labels["adnominals"] = {
		description = "{{{langname}}} {{m|ja|連体詞||[[adnominal]], attributive|tr=れんたいし, rentaishi|sc=Jpan}}. Modifies nouns, doesn’t conjugate, and doesn’t [[predicate#Verb|predicate]].",
		parents = {{name = "{{{langcat}}}", raw = true}},
	}

	labels["хирагана"] = {
		description = "The [[hiragana]] ([[平仮名]], [[ひらがな]]) form of " .. (lang:getCode() == "ryu" and "an" or "a") .. " {{{langname}}} word is a [[phonetic]] representation of that word. " ..
		"Wiktionary represents {{{langname}}}-language segments in three ways: in normal form (with [[kanji]], if appropriate), in [[hiragana]] " ..
		"form (this differs from kanji form only when the segment contains kanji), and in [[romaji]] form.",
		additional = (lang:getCode() == "ja" and "For more information, see [[Викиречник:Јапански језик]].\n\n" or "") .. "''See also'' [[:Категорија:{{{langname}}} катакана]]",
		toc_template = "categoryTOC-hiragana",
		parents = {
			{name = "{{{langcat}}}", raw = true},
			"Категорија:Хирагана текст карактери",
		}
	}

	labels["historical hiragana"] = {
		description = "{{{langname}}} historical [[hiragana]].",
		additional = "''Види и'' [[:Категорија:{{{langname}}} historical katakana]].",
		toc_template = "categoryTOC-hiragana",
		parents = {
			"hiragana",
			{name = "{{{langcat}}}", raw = true},
			"Категорија:Хирагана текст карактери",
		}
	}

	labels["катакана"] = {
		description = "{{{langname}}} words and terms with katakana forms, sorted by conventional katakana sequence. Katakana is used primarily for transliterations of foreign words, including old Chinese Hanzi not used in [[shinjitai]].",
		additional = "Entries in this category are made by {{{langname}}} POS templates, [[Шаблон:{{{langcode}}}-noun]], etc.",
		toc_template = "categoryTOC-katakana",
		parents = {
			{name = "{{{langcat}}}", raw = true},
			"Категорија:Катакана текст карактери",
		}
	}

	labels["историјска хирагана"] = {
		description = "{{{langname}}} историјска [[katakana]].",
		additional = "''Види и'' [[:Категорија:{{{langname}}} историјска хирагана]].",
		toc_template = "categoryTOC-katakana",
		parents = {
			"катакана",
			{name = "{{{langcat}}}", raw = true},
			"Категорија:Катакана текст карактери",
		}
	}

	labels["terms spelled with mixed kana"] = {
		description = "{{{langname}}} terms which combine [[hiragana]] and [[katakana]] characters, potentially with [[kanji]] too.",
		parents = {
			{name = "{{{langcat}}}", raw = true},
			"хирагана",
			"катакана",
		},
	}

	labels["honorifics"] = {
		intro = "{{wikipedia|Honorific speech in Japanese}}",
		description = "{{{langname}}} [[honorific]]s.",
		parents = {{name = "{{{langcat}}}", raw = true}},
	}

	labels["humble language"] = {
		description = "{{{langname}}} humble terms, or {{ja-r|謙譲語|けんじょうご}}, which is a type of honorific speech in {{{langname}}} that lowers the speaker in relation to the listener.",
		parents = "honorifics",
	}

	labels["respectful language"] = {
		description = "{{{langname}}} respectful terms, or {{ja-r|尊敬語|そんけいご}}, which is a type of honorific speech in {{{langname}}} that elevates the listener in relation to the speaker.",
		parents = "honorifics",
	}

	labels["канџи по читању"] = {
		description = "{{{langname}}} kanji categorized by reading.",
		parents = {{name = "Хан карактери", sort = "reading"}},
	}

	labels["термини по канџи читању"] = {
		description = "{{{langname}}} categories grouped with regard to the readings of the kanji with which they are spelled.",
		parents = {{name = "{{{langcat}}}", raw = true}},
	}

	labels["термини по чита pattern"] = {
		description = "{{{langname}}} categories with terms grouped by their reading patterns.",
		parents = {{name = "{{{langcat}}}", raw = true}},
	}

	for reading_pattern, link in pairs {
		["jukujikun"] = "{{ja-r|熟字訓|じゅくじくん}}",
		["jūbakoyomi"] = "{{ja-r|重%箱%読み|じゅう%ばこ%よみ}}, a reading pattern in {{{langname}}} compounds where kanji read with ''on'yomi'' are followed by kanji read with ''kun'yomi''",
		["kun'yomi"] = "{{ja-r|訓読み|くんよみ}}",
		["nanori"] = "{{ja-r|名乗り|なのり}}",
		["on'yomi"] = "{{ja-r|音%読み|おん%よみ}}",
		["yutōyomi"] = "{{ja-r|湯%桶%読み|ゆ%とう%よみ}}, a reading pattern in {{{langname}}} compounds where kanji read with ''kun'yomi'' are followed by kanji read with ''on'yomi''",
	} do
		labels["термини читани са " .. reading_pattern] = {
			description = "{{{langname}}} terms exhibiting " .. link .. ".",
			breadcrumb = reading_pattern,
			parents = {{name = "термини по чита pattern", sort = reading_pattern}},
		}
	end

	labels["термини по канџи типу читања"] = {
		description = "{{{langname}}} categories with terms grouped with regard to the types of readings of the kanji with which " ..
		"they are spelled, broadly those of Chinese origin (''on'' readings) and those of {{{langname}}} origin (''kun'' readings).",
		parents = {{name = "{{{langcat}}}", raw = true}},
	}

	local on_continuation = [=[


	Categories of terms with more specific types of ''on'' readings can be found in the following categories:
	* [[:Категорија:{{{langname}}} термини који се пишу са канџи са goon читањем]]
	* [[:Категорија:{{{langname}}} термини који се пишу са канџи са kan'yōon читањем]]
	* [[:Категорија:{{{langname}}} термини који се пишу са канџи са kan'on читањем]]
	* [[:Категорија:{{{langname}}} термини који се пишу са канџи са tōon читањем]]
	]=]

	local on_desc = ", which is a type of {{ja-r|音%読み|おん%よみ}} or {{ja-r|音|おん}} читањем"
	for reading_type, reading_desc in pairs {
		["goon"] = "a {{ja-r|呉%音|ご%おん}} читањем]" .. on_desc,
		["kan'on"] = "a {{ja-r|漢%音|かん%おん}} читањем]" .. on_desc,
		["kan'yōon"] = "a {{ja-l|慣用音|かんようおん|kan'yōon}} читањем]" .. on_desc,
		["kun"] = "a {{ja-r|訓%読み|くん%よみ}} or {{ja-r|訓|くん}} читањем]",
		["nanori"] = "a {{ja-r|名%乗り|な%のり}} читањем, which is a type of reading used for people and places",
		["on"] = "an {{ja-r|音%読み|おん%よみ}} or {{ja-r|音|おん}} читањем]",
		["tōon"] = "a {{ja-r|唐%音|とう%おん}} читањем]" .. on_desc,
		["sōon"] = "a {{ja-r|宋%音|そう%おん}} читањем]" .. on_desc,
	} do
		labels["термини који се пишу са канџи са " .. reading_type .. " читањем"] = {
			description = "{{{langname}}} categories with terms that are spelled with one or more kanji which exhibit " .. reading_desc .. ".",
			additional = reading_type == "on" and on_continuation,
			breadcrumb = reading_type,
			parents = {{name = "термини по канџи типу читања", sort = reading_pattern}},
		}
	end

	labels["terms spelled with ateji"] = {
		intro = "{{wikipedia|Ateji}}",
		description = "{{{langname}}} terms containing one or more [[Додатак:Јапански речник#ateji|ateji]] ({{m|ja|当て字}}), which are [[kanji]] used to represent sounds rather than meanings (though meaning may have some influence on which kanji are chosen).",
		parents = {{name = "{{{langcat}}}", raw = true}},
	}

	labels["terms spelled with daiyōji"] = {
		description = "Japanese terms spelled using [[Додатак:Јапански речник#daiyouji|daiyōji]], categorized using {{temp|ja-daiyouji}}.",
		parents = {"термини по етимологији"},
	}

	labels["terms spelled with jukujikun"] = {
		description = "{{{langname}}} terms containing one or more [[Додатак:Јапански речник#jukujikun|jukujikun]] ({{m|ja|熟字訓}}), which are [[kanji]] used to represent meanings rather than sounds.",
		parents = {{name = "{{{langcat}}}", raw = true}},
	}

	labels["words with multiple readings"] = {
		description = "{{{langname}}} words with multiple pronunciations (hence multiple [[kana]] spellings).",
		parents = {{name = "{{{langcat}}}", raw = true}},
	}

	labels["канџи читање по броју од морае"] = {
		description = "{{{langname}}} categories grouped with regard to the number of morae in their kanji readings.",
		parents = {{name = "{{{langcat}}}", raw = true}},
	}
end



function export.add_handlers(handlers, lang, m_lang, m_lang_kanji_readings)
	-- FIXME: Only works for 0 through 19.
	local word_to_number = {}
	for k, v in pairs(m_numeric.ones_position) do
		word_to_number[v] = k
	end

	local kana_capture = "([-ぁ-ー𛀁𛀆]+)"

	local periods = {
		historical = true,
		ancient = true,
	}

	local function get_period_text_and_reading_type_link(period, reading_type)
		period = period ~= "" and period or nil
		if period and not periods[period] then
			return nil
		end
		local period_text = period and period .. " " or nil

		-- Allow periods (historical or ancient) by themselves; they will parse as reading types.
		if not period and periods[reading_type] then
			return nil, reading_type
		end

		local reading_label = m_lang_kanji_readings.accented_labels_to_labels[reading_type]
		if not reading_label then
			return nil
		end
		reading_label = m_lang_kanji_readings.labels[reading_label]
		local reading_type_link = "[[" .. reading_label.entry .. "|" .. mw.ustring.lower(reading_label.text) .. "]]"
		return period_text, reading_type_link
	end
			
	local function get_tagged_reading(reading)
		return require("Модул:script utilities").tag_text(reading, lang, m_lang_kanji_readings.get_script(reading))
	end

	local function get_reading_link(reading, historical)
		return m_lang_kanji_readings.plain_link {
			term = reading, tr = m_lang.kana_to_romaji(string.gsub(reading, '%-', ''), historical and { hist = true })
		}
	end

	local function is_on_subtype(reading_type)
		return reading_type:find(".on$")
	end


	table.insert(handlers, function(data)
		local count, plural = data.label:match("^појмови написани са (.+) Хан текст карактер(а?)$")
		if count then
			-- Make sure 'one' goes with singular and other numbers with plural.
			if (count == "један") ~= (plural == "") then
				return nil
			end
			local num = word_to_number[count]
			if not num then
				return nil
			end
			return {
				description = "{{{langname}}} појмови написани са " .. count .. " Хан текст карактер" .. plural .. " (такође знано као [[kanji]]).",
				breadcrumb = num,
				parents = {{name = "број карактера", sort = num}},
			}
		end
	end)


	table.insert(handlers, function(data)
		local count, plural = data.label:match("^канџи читани са (.+) мора(е?)$")
		if count then
			-- Make sure 'one' goes with singular and other numbers with plural.
			if (count == "један") ~= (plural == "") then
				return nil
			end
			local num = word_to_number[count]
			if not num then
				return nil
			end
			return {
				description = "{{{langname}}} канџи читани са " .. count .. " мора" .. plural .. ".",
				breadcrumb = num,
				parents = {{name = "канџи читање по броју од морае", sort = num}},
			}
		end
	end)


	table.insert(handlers, function(data)
		local label_pref, period, reading_type, reading = rmatch(data.label, "^(канџи са ([a-z]-) ?([%a']+) reading )" .. kana_capture .. "$")
		if period then
			local period_text, reading_type_link = get_period_text_and_reading_type_link(period, reading_type)
			if not reading_type_link then
				return nil
			end

			-- Compute parents.
			local parents = {
				{name = "канџи по " .. (period_text or "") .. reading_type .. " читању", sort = m_lang.jsort(reading)}
			}
			if is_on_subtype(reading_type) then
				table.insert(parents, {name = "канџи са " .. (period_text or "") .. "on reading " .. reading, sort = reading_type})
			elseif period_text then
				table.insert(parents, {name = "канџи са " .. period_text .. "reading " .. reading, sort = reading_type})
			end
			if not period_text then
				table.insert(parents, {name = "канџи читани као " .. reading, sort = reading_type})
			end

			local tagged_reading = get_tagged_reading(reading)
			return {
				description = "{{{langname}}} [[kanji]] with the " .. (period_text or "") .. reading_type_link .. " reading " ..
					get_reading_link(reading, period_text) .. ".",
				displaytitle = "{{{langname}}} " .. label_pref .. tagged_reading,
				breadcrumb = tagged_reading,
				parents = parents,
			}
		end
	end)


	table.insert(handlers, function(data)
		local period, reading_type = rmatch(data.label, "^канџи по ([a-z]-) ?([%a']+) читању$")
		if period then
			local period_text, reading_type_link = get_period_text_and_reading_type_link(period, reading_type)
			if not reading_type_link then
				return nil
			end

			-- Compute parents.
			local parents = {
				is_on_subtype(reading_type) and {name = "канџи по " .. (period_text or "") .. "on reading", sort = reading_type} or
				period_text and {name = "канџи по " .. reading_type .. " читању", sort = period} or
				{name = "канџи по читању", sort = reading_type}
			}
			if period_text then
				table.insert(parents, {name = "канџи по " .. period_text .. "reading", sort = reading_type})
			end

			-- Compute description.
			local description = "{{{langname}}} [[kanji]] categorized by " .. (period_text or "") .. reading_type_link .. " reading."
			return {
				description = description,
				breadcrumb = (period_text or "") .. reading_type,
				parents = parents,
			}
		end
	end)


	table.insert(handlers, function(data)
		local label_pref, reading = rmatch(data.label, "^(канџи читани као )" .. kana_capture .. "$")
		if reading then
			local parents = {{name = "канџи по читању", sort = m_lang.jsort(reading)}}

			local tagged_reading = get_tagged_reading(reading)
			return {
				description = "{{{langname}}} [[kanji]] читани као " .. get_reading_link(reading, period_text) .. ".",
				displaytitle = "{{{langname}}} " .. label_pref .. tagged_reading,
				breadcrumb = tagged_reading,
				parents = parents,
			}
		end
	end)


	table.insert(handlers, function(data)
		local label_pref, reading = rmatch(data.label, "^(термини који се пишу са канџи читани као )" .. kana_capture .. "$")
		if reading then
			-- Compute parents.
			local sort_key = m_lang.jsort(reading)
			local mora_count = m_lang.count_morae(reading)
			local mora_count_words = m_numeric.spell_number(tostring(mora_count))
			local parents = {
				{name = "термини по канџи читању", sort = sort_key},
				{name = "канџи читани са " .. mora_count_words .. " мора" .. (mora_count > 1 and "е" or ""), sort = sort_key},
				{name = "канџи читани као " .. reading, sort = " "},
			}

			local tagged_reading = get_tagged_reading(reading)
			return {
				description = "{{{langname}}} terms that contain kanji that exhibit a reading of " .. get_reading_link(reading) ..
				" in those terms prior to any sound changes.",
				displaytitle = "{{{langname}}} " .. label_pref .. tagged_reading,
				breadcrumb = tagged_reading,
				parents = parents,
			}
		end
	end)


	table.insert(handlers, function(data)
		local kanji, reading = rmatch(data.label, "^термини који се пишу са (.) читани као " .. kana_capture .. "$")
		if not kanji then
			return nil
		end
		local params = {
			[4] = {list = true},
		}
		local args = require("Модул:parameters").process(data.args, params)
		if #args[4] == 0 then
			error("For categories of the form \"" .. data.lang:getCanonicalName() ..
				" terms spelled with KANJI read as READING\", at least one reading type (e.g. \"kun\" or \"on\") must be specified using 1=, 2=, 3=, etc.")
		end
		local reading_types = {}
		for _, reading_type in ipairs(args[4]) do
			table.insert(reading_types, "<i>" .. reading_type .. "</i> reading")
		end
		reading_types = require("Модул:table").serialCommaJoin(reading_types, {conj = "or"})

		local parents = {
			{name = "термини који се пишу са " .. kanji, sort = m_lang.jsort(reading)},
			-- FIXME, using the kanji directly as the sort key is what it did before but maybe we should call [[Module:zh-sortkey]]
			-- to get the radical/stroke sort key
			{name = "термини који се пишу са канџи читани као " .. reading, sort = kanji},
		}
		for _, reading_type in ipairs(args[4]) do
			table.insert(parents, {name = "термини који се пишу са канџи са " .. reading_type .. " читањем", sort = m_lang.jsort(reading)})
		end
		local tagged_kanji = get_tagged_reading(kanji)
		local tagged_reading = get_tagged_reading(reading)
		return {
			description = "{{{langname}}} термини који се пишу са {{{{{langcode}}}-l|" .. kanji .. "}} with its " ..
				reading_types .. " of " .. get_reading_link(reading) .. ".",
			displaytitle = "{{{langname}}} термини који се пишу са " .. tagged_kanji .. " читани као " .. tagged_reading,
			breadcrumb = "читан као " .. tagged_reading,
			parents = parents,
		}, true
	end)


	table.insert(handlers, function(data)
		local kanji, daiyoji = rmatch(data.label, "^terms with (.) replaced by daiyōji (.)$")
		if not kanji then
			return nil
		end
		local params = {
			["sort"] = {},
		}
		local args = require("Модул:parameters").process(data.args, params)
		if not args.sort then
			error("For categories of the form \"" .. data.lang:getCanonicalName() ..
				" terms with KANJI replaced by daiyōji DAIYOJI\", the sort key must be specified using sort=")
		end

		local tagged_kanji = get_tagged_reading(kanji)
		local tagged_daiyoji = get_tagged_reading(daiyoji)
		return {
			description = "{{{langname}}} terms with {{{{{langcode}}}-l|" .. kanji .. "}} replaced by [[Додатак:Јапански речник#daiyouji|daiyōji]] {{{{{langcode}}}-l|" .. daiyoji .. "}}.",
			displaytitle = "{{{langname}}} terms with " .. tagged_kanji .. " replaced by daiyōji " .. tagged_daiyoji,
			breadcrumb = tagged_kanji .. " replaced by daiyōji " .. tagged_daiyoji,
			parents = {{name = "terms spelled with daiyōji", sort = args.sort}},
		}, true
	end)
end


return export