Modul:ja-usex

Üdvözlöm, Ön a Modul:ja-usex szó jelentését keresi. A DICTIOUS-ban nem csak a Modul:ja-usex szó összes szótári jelentését megtalálod, hanem megismerheted az etimológiáját, a jellemzőit és azt is, hogyan kell a Modul:ja-usex szót egyes és többes számban mondani. Minden, amit a Modul:ja-usex szóról tudni kell, itt található. A Modul:ja-usex szó meghatározása segít abban, hogy pontosabban és helyesebben fogalmazz, amikor beszélsz vagy írsz. AModul:ja-usex és más szavak definíciójának ismerete gazdagítja a szókincsedet, és több és jobb nyelvi forráshoz juttat.

A modult a Modul:ja-usex/doc lapon tudod dokumentálni

local export = {}

local m_ja = require("Module:ja")
-- ]
-- ]
-- ]
-- ]
-- ]
-- ]

local pagename = mw.title.getCurrentTitle().text

local HaniHiraKana_characters
local function test_script(text, scriptCode, entirely)
	if type(text) == "string" and type(scriptCode) == "string" then
		local characters
		if scriptCode == "HaniHiraKana" then
			if HaniHiraKana_characters then
				return HaniHiraKana_characters
			end
			local getScriptByCode = require("Module:scripts").getByCode
			characters = ""
			for code in scriptCode:gmatch("%u%l%l%l") do
				characters = characters .. getScriptByCode(code):getCharacters()
			end
		else
			characters = require("Module:scripts").getByCode(scriptCode):getCharacters()
		end

		local out
		if entirely then
			out = mw.ustring.match(text, "^+$")
		else
			text = mw.ustring.gsub(text, "%W", "")
			out = mw.ustring.find(text, "")
		end

		return out
	else
		mw.log("Parameters to test_script were incorrect.")
	end
end

-- main entry point
function export.show(frame)
	local params = {
		 = {},
		 = {},
		 = {},
		 = {},
		 = {},
		 = {},
		 = { alias_of = "manyou" },
		 = {},
		 = { alias_of = "manyou_kana" },
		 = {},
		 = {},
		 = {},	-- not currently used
	}
	local args = require("Module:parameters").process(frame:getParent().args, params)

	local literally = args.lit

	local sortkey
	-- Use sort parameter, or title if it consists only of kana.
	if args.sort then
		sortkey = args.sort
	elseif test_script(pagename, "Hira", true) or test_script(pagename, "Kana", true) then
		sortkey = pagename
	else
		-- ]
		require("Module:debug").track("ja-usex/no sortkey")
	end

	-- Process sortkey.
	if sortkey then
		sortkey = m_ja.jsort(sortkey)
	end

	local text = {}
	local categories = { "Japanese terms with usage examples" }

	local example, kana, translation

	-- Custom errors are preferable to the generic "These parameters are required.",
	-- which would be generated if "required = true" were added to the tables for parameters 1 and 2.
	if not args then
		error("Usage example text has not been given.")
	elseif test_script(args, "Hani") then
		example = args

		if args and test_script(args, "HaniHiraKana") then
			kana = args
			translation = args
		else
			error("Kana spelling of the usage example text has not been given.")
		end
	elseif test_script(args, "HaniHiraKana") then
		example = args

		if args and test_script(args, "HaniHiraKana") then
			kana = args
			translation = args
		else
			kana = args
			translation = args
		end
	end

	if (not translation) then
		translation = '<small>(please add an English translation of this example)</small>'
		table.insert(categories, "Requests for translations of Japanese usage examples")
	end

	local romaji = args
	local manyou = args
	local old_kana = args
	local ref = args

	local tag_start = " <span style=\"color:darkgreen; font-size:x-small;\">&#91;" -- see also ]
	local tag_end = "&#93;</span>"

	if manyou then
		table.insert(text, ('<span lang="ja" class="Jpan">%s</span>'):format(old_kana ~= "" and require('Module:ja-ruby').ruby_auto{
			term = manyou,
			kana = old_kana,
		} or manyou))
		table.insert(text, tag_start)
		table.insert(text, "]")
		table.insert(text, tag_end)
		table.insert(text, "<dd>")
	end

	local ruby_text
	if example and kana and example ~= kana then
		ruby_text = require('Module:ja-ruby').ruby_auto{
			term = example,
			kana = kana,
		}
	else
		ruby_text = m_ja.remove_ruby_markup(kana)
		kana = require("Module:links").remove_links(kana)
	end
	if ruby_text then
		if string.find(ruby_text, "[[", 1, true) then
			ruby_text = require("Module:links").language_link{ term = ruby_text,
				lang = require("Module:languages").getByCode("ja"),
			}
		end
		table.insert(text, ('<span lang="ja" class="Jpan">%s</span>'):format(ruby_text))
	end

	if ref then
		table.insert(text, ref)
	end

	if manyou then
		table.insert(text, tag_start)
		table.insert(text, "Modern spelling")
		table.insert(text, tag_end)
		table.insert(text, "</dd>")
	end

	if kana or romaji or translation then
		table.insert(text, "<dl>")
	end
	if kana or romaji then
		table.insert(text, "<dd><i>")
		if romaji then
			table.insert(text, romaji)
		elseif kana then
			-- add capitalization markup to the kana if manual markup is not present
			if mw.ustring.match(kana, "") and not mw.ustring.match(kana, "%^") then
				-- "「テスト」です。"→"「^テスト」^です。"
				kana = mw.ustring.gsub(kana, "(+)", "^%1")

				-- remove "^" in ~other certain circumstances~
				-- TESTS: https://en.wiktionary.org/?oldid=51248532
				kana = mw.ustring.gsub(kana, "()%^", "%1")
				kana = mw.ustring.gsub(kana, "()()%^", "%1%2")
			end

			-- add romaji
			table.insert(text, m_ja.kana_to_romaji(kana))
		end
		table.insert(text, "</i></dd>")
	end
	if translation then
		table.insert(text, "<dd>" .. translation .. "</dd>")
	end
	if literally then
		table.insert(text, "<dd>(literally, “" ..  literally .. "”)</dd>")
	end
	table.insert(text, "</dl>")

	return table.concat(text) .. require("Module:utilities").format_categories(categories, lang, args.sort)
end

return export