Module:script utilities/tracking

Hello, you have come here looking for the meaning of the word Module:script utilities/tracking. In DICTIOUS you will not only get to know all the dictionary meanings for the word Module:script utilities/tracking, but we will also tell you about its etymology, its characteristics and you will know how to say Module:script utilities/tracking in singular and plural. Everything you need to know about the word Module:script utilities/tracking you have here. The definition of the word Module:script utilities/tracking will help you to be more precise and correct when speaking or writing your texts. Knowing the definition ofModule:script utilities/tracking, as well as those of other words, enriches your vocabulary and provides you with more and better linguistic resources.

List of tracked conditions

All the patterns that are tracked for each language, with a link to "What Links Here" page for the subtemplate of Wiktionary:Tracking/script that tracks them. Diacritics are shown over a dotted circle () to make them easier to read.

Testcases


local export = {}

local U = mw.ustring.char
--[[
--	redirect_to: tracking conditions to redirect to (allows multiple languages
	to use the same conditions)

--	path: added to Wiktionary:Tracking; default is language code (or code under 
	tracking conditions are listed)
	--	Wiktionary:Tracking/Greek
	--	Wiktionary:Tracking/ang

--	code: added after path
	--	Wiktionary:Tracking/Greek/spacing-coronis
	--	Wiktionary:Tracking/ang/acute

--	chars: what to search for in the text; can be a table containing multiple
	patterns
]]

export.allTrackingConditions = {
	 = {
		{ chars = U(0x301), code = "acute", decompose = true },
	},
	 = {
		{ redirect_to = "Greek" },
		
		path = "Ancient Greek",
		{ chars = U(0x1FBD),							code = "spacing-coronis" },
		{ chars = U(0x1FBF),							code = "spacing-smooth-breathing" },
		{ chars = "", code = "wrong-apostrophe" },
	},
	 = {
		{ redirect_to = "Greek" },
	},
	 = {
		{ chars = "ϑ", code = "wrong-theta" },
		{ chars = "ϰ", code = "wrong-kappa" },
		{ chars = "ϱ", code = "wrong-rho" },
		{ chars = "ϕ", code = "wrong-phi" },
	},
	 = {
		path = "Russian",
		{ chars = U(0x300), code = "grave-accent", decompose = true },
	},
	 = {
		path = "Tibetan",
		{ chars = { "$", "%]%]$" }, code = "trailing-punctuation" },
	},
	 = {
		path = "Thai",
		{ chars = "เ".."เ", code = "broken-ae" },
		{ chars = "ํ?า", code = "broken-am" },
		{ chars = "า", code = "wrong-rue-lue" },
	},
	 = {
		path = "Lao",
		{ chars = "ເ".."ເ", code = "broken-ae" },
		{ chars = "ໍ?າ", code = "broken-am" },
		{ chars = "ຫນ", code = "possible-broken-ho-no" },
		{ chars = "ຫມ", code = "possible-broken-ho-mo" },
		{ chars = "ຫລ", code = "possible-broken-ho-lo" },
	},
	 = {
		path = "Lü",
		{ chars = "ᦵ".."ᦵ", code = "broken-ae" },
		{ chars = "", code = "possible-wrong-sequence" },
	},
}

local function interpretCondition(condition, text, path)
	-- Ignore conditions that don't have "chars" or "code".
	local required = { "chars", "code" }
	for i, param in pairs(required) do
		if not condition then
			return nil
		end
	end
	
	if type(condition.chars) ~= "table" then
		condition.chars = { condition.chars }
	end
	
	for i, char in pairs(condition.chars) do
		local text = condition.decompose and mw.ustring.toNFD(text) or text
		
		if type(char) == "string" and mw.ustring.find(text, char) then
			require("Module:debug").track("script/" .. path .. "/" .. condition.code)
		end
	end
end

local function interpretConditions(text, code)
	if not text then
		return nil
	end
	
	local trackingConditions = export.allTrackingConditions
	
	if trackingConditions then
		local path = trackingConditions.path or code
		
		for i, condition in ipairs(trackingConditions) do
			local target = condition.redirect_to
			if target then
				interpretConditions(text, target)
			else
				local path = condition.path or path
				
				interpretCondition(condition, text, path)
			end
		end
	end
end

function export.track(text, lang)
	local langCode = lang:getCode()
	interpretConditions(text, langCode)
end

return export