Module:Lana-sortkey

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

This module will sort text in the Tai Tham script. It is used to sort , Khün, Northern Thai, and Yong. The module should preferably not be called directly from templates or other modules. To use it from a template, use {{sortkey}}. Within a module, use Module:languages#Language:makeSortKey.

For testcases, see Module:Lana-sortkey/testcases.

Functions

makeSortKey(text, lang, sc)
Generates a sortkey for a given piece of text written in the script specified by the code sc, and language specified by the code lang.
When the sort fails, returns nil.

local export = {}
local u = mw.ustring.char
local minorMarkSet = "()"

local minorMarks = {
	 = "0",  = "0",  = "1",  = "2",  = "3",
	 = "4",  = "5",  = "6",  = "7",  = "8"
}

local monographs = {
	"] = "",  = "ᩃᩯ",  = "ᩈ᩠ᩈ",
	 = "᩠ᩁ",  = "᩠ᩃ",  = "᩠ᩃ",
	 = "᩠ᨦ",  = "᩠ᨦ",  = "᩠ᨻ",
	 = "᩠ᨾ",  = "᩠ᨷ",  = "᩠ᩈ",  = "ᩣ"
}

local digraphs = {
	)ᩛ"] = "%1᩠ᨮ", )ᩛ"] = "%1᩠ᨳ", )ᩛ"] = "%1᩠ᨻ"
}

function export.makeSortKey(text, lang, sc)
	local minorKey = ""
	for mark in mw.ustring.gmatch(text, minorMarkSet) do
		minorKey = minorKey .. minorMarks
	end
	text = mw.ustring.gsub(text, minorMarkSet, "")
	
	for from, to in pairs(digraphs) do
		text = mw.ustring.gsub(text, from, to)
	end
	
	for from, to in pairs(monographs) do
		text = mw.ustring.gsub(text, from, to)
	end
	
	return text .. minorKey
end

return export