Module:User:Wpi/zh-pron

local export = {}

local m_string_utils = require("Module:string utilities") local qualifier = require('Module:qualifier').format_qualifier

local ucodepoint = mw.ustring.codepoint local find = m_string_utils.find local gsub = m_string_utils.gsub local len = m_string_utils.len local match = m_string_utils.match local u = mw.ustring.char local rsplit = mw.text.split local rgsplit = mw.text.gsplit

local m_data = require("Module:User:Wpi/zh-pron/data") local m_utils = require("Module:User:Wpi/zh-pron/utilities")

-- if not empty local function ine(val) if val == "" then return nil end return val end

local function has_var(var) return args[var] or #args[var .. "a"] > 0 end

function export.make(frame) local args = frame:getParent.args local title = mw.title.getCurrentTitle local pagename = ine(args["pagename"]) or title.text local sortkey = (require("Module:Hani-sortkey").makeSortKey(pagename)) -- Unicode pattern for single Han character, with non-NFC characters -- inserted using mw.ustring.char because they can't be saved in a MediaWiki -- page. -- https://unicode.org/cldr/utility/regex.jsp?a=%5Cp%7BHani%7D local hanzi = "^[⺀-⺙⺛-⻳⼀-⿕々〇〡-〩〸-〻㐀-䶿一-鿼" .. u(0xF900) .. "-" .. u(0xFA6D) .. u(0xFA70) .. "-" .. u(0xFAD9) .. "𠀀-𪛝𪜀-𫜴𫝀-𫠝𫠠-𬺡𬺰-𮯠" .. u(0x2F800) .. "-" .. u(0x2FA1D) .. "𰀀-𱍊]$" local is_single_hanzi = find(pagename, hanzi) ~= nil local namespace = ine(args["namespace"]) or title.nsText local dial = ine(args["dial"]) local mc = ine(args["mc"]) or false local oc = ine(args["oc"]) or false local only_cat = args["only_cat"] == "yes" local make_cat = {} local text_show = {} local text_hide = {} local result = {} local cur = nil local group_has = {} for group in m_data.groups do		group_has = {} for a in group[2] do			if has_var(args[a]) then group_has:insert(a) end end if #group_has > 0 then text_hide:insert(m_utils.boilerplate_group(group[1],1)) if #group_has ~= 1 then text_show:insert(m_utils.boilerplate_group(group[1],nil)) end for a in group_has do				cur = require('Module:User:Wpi/zh-pron/'..m_data.lang_code) if #group_has == 1 then text_show:insert(m_utils.boilerplate(cur.make(args[a]), group)) else text_show:insert(m_utils.boilerplate(cur.make(args[a]), group)) end text_hide:insert(m_utils.boilerplate(cur.make(args[a]), group)) end end end return table.concat(result) end

return export