Module:Hani-sortkey/templates

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

This module contains template-callable functions for demonstrating Module:Hani-sortkey.


local export = {}

local m_sortkey = require("Module:Hani-sortkey")
local m_sortkey_sandbox = require("Module:sandbox/Hani-sortkey")

local lang = require("Module:languages").getByCode("zh")
local sc = require("Module:scripts").getByCode("Hani")

local function tag(text)
	return require("Module:script utilities").tag_text(text, lang, sc)
end

local function link(text)
	return require("Module:links").full_link{ term = text, lang = lang, sc = sc, tr = "-" }
end

local a = {}
a = '命裡有時終須有,命裡無時莫強求' -- punctuation
a = 'gas爐' -- non-cjk
a = 'γ粒子' -- non-cjk
a = 'PS/2接口' -- non-cjk + symbols
a = '濕𣲷𣲷' -- exotic unicode
a = '得個……字' -- punctuation?
a = '赛车' -- simplified

function export.showSorting(frame)
	local terms = {}
	
	if frame.args then
		for i, term in ipairs(frame.args) do
			table.insert(terms, mw.text.trim(term))
		end
	else
		terms = a
	end
	
	local module = frame.args.sandbox and m_sortkey_sandbox or m_sortkey
	
	local function comp(term1, term2)
		return (module.makeSortKey(term1)) < (module.makeSortKey(term2))
	end
	
	table.sort(terms, comp)
	
	for i, term in pairs(terms) do
		local title = mw.title.new(term)
		local exists = title and title.exists
		terms = "\n* " .. ( exists and link(term) or tag(term) ) .. " (<code>" .. (module.makeSortKey(term)) .. "</code>)"
	end
	
	return table.concat(terms)
end

function export.sortkey(frame)
	return (m_sortkey.makeSortKey(frame.args, frame.args, frame.args))
end

function export.showIDSLinks(frame)
	local out = {}
	for IDS, sortkey in pairs(mw.loadData("Module:Hani-sortkey/data/unsupported")) do
		table.insert(out, "\n* " .. link(IDS) .. " → <code>" .. sortkey .. "</code>")
	end
	
	return table.concat(out)
end

return export