Module:User:QFQ/zh-dial-map-helper

local export = {}

local variety_data = require("Module:zh/data/dial")

function export.keys(frame) local ks = {} for k, t in pairs(variety_data) do		table.insert(ks, k)	end return 'enwikt_keys = {"' .. table.concat(ks, '", "') .. '"}' end

function export.showkeys(frame) local query = mw.text.split(frame.args[1], ' ') -- {"Bangkok-C","Nanxiong-ZJ","Nan'ao-HZ","Nan'ao-YA"} local data = require("Module:User:QFQ/zh-dial-map-helper/data") function dump(h, t)		local ret = {} local ordered_table = require("Module:User:QFQ/ordered-table") local todo = ordered_table {} -- reverse: { ["官話"]="Mandarin",["粵語"]="Cantonese",["贛語"]="Gan",["客家語"]="Hakka",["徽語"]="Huizhou",["晉語"]="Jin",["九姓漁民船上話"]="Jiuxing Yumin",["閩北語"]="Min Bei",["閩東語"]="Min Dong",["閩南語"]="Min Nan",["莆仙語"]="Puxian Min",["閩中語"]="Min Zhong",["中山閩語"]="Zhongshan Min",["北部平話"]="Northern Pinghua",["南部平話"]="Southern Pinghua",["畲話"]="Shehua",["瓦鄉話"]="Waxiang",["吳語"]="Wu",["湘語"]="Xiang" } todo['group'] = function(s) local t = { ["Mandarin"]="官話",["Cantonese"]="粵語",["Gan"]="贛語",["Hakka"]="客家語",["Huizhou"]="徽語",["Jin"]="晉語",["Jiuxing Yumin"]="九姓漁民船上話",["Min Bei"]="閩北語",["Min Dong"]="閩東語",["Min Nan"]="閩南語",["Puxian Min"]="莆仙語",["Min Zhong"]="閩中語",["Zhongshan Min"]="中山閩語",["Northern Pinghua"]="北部平話",["Southern Pinghua"]="南部平話",["Shehua"]="畲話",["Waxiang"]="瓦鄉話",["Wu"]="吳語",["Xiang"]="湘語" }; return '"' .. t[s] .. '"' end todo['chinese'] = function(s) return '"' .. s .. '"' end todo['link'] = function(s) return '"' .. s .. '"' end todo['lat'] = function(s) return s end todo['long'] = function(s) return s end for k, f in pairs(todo) do			if t[k] then table.insert(ret, string.format('\t%s = %s', k == 'chinese' and 'english' or k, f(t[k]))) end end return string.format('variety_data["%s"] = {\n%s\n}', h, table.concat(ret, ',\n')) end local ret = {} for _, k in pairs(query) do		table.insert(ret, string.format("-- after %s", data[getmetatable(data).findk(data, k) - 1])) table.insert(ret, dump(k, data[k])) end return frame:extensionTag('syntaxhighlight', table.concat(ret, '\n'), { lang = 'lua' } ) end

function export.count(frame) local ks = {} for k, t in pairs(variety_data) do		table.insert(ks, k)	end return #ks end

function export.test(frame) local query = mw.text.split(frame.args[1], ' ') -- {"Bangkok-C","Nanxiong-ZJ","Nan'ao-HZ","Nan'ao-YA"} local data = require("Module:User:QFQ/zh-dial-map-helper/data") function dump(h, t)		local ret = {} local ordered_table = require("Module:User:QFQ/ordered-table") local todo = ordered_table {} -- reverse: { ["官話"]="Mandarin",["粵語"]="Cantonese",["贛語"]="Gan",["客家語"]="Hakka",["徽語"]="Huizhou",["晉語"]="Jin",["九姓漁民船上話"]="Jiuxing Yumin",["閩北語"]="Min Bei",["閩東語"]="Min Dong",["閩南語"]="Min Nan",["莆仙語"]="Puxian Min",["閩中語"]="Min Zhong",["中山閩語"]="Zhongshan Min",["北部平話"]="Northern Pinghua",["南部平話"]="Southern Pinghua",["畲話"]="Shehua",["瓦鄉話"]="Waxiang",["吳語"]="Wu",["湘語"]="Xiang" } todo['group'] = function(s) local t = { ["Mandarin"]="官話",["Cantonese"]="粵語",["Gan"]="贛語",["Hakka"]="客家語",["Huizhou"]="徽語",["Jin"]="晉語",["Jiuxing Yumin"]="九姓漁民船上話",["Min Bei"]="閩北語",["Min Dong"]="閩東語",["Min Nan"]="閩南語",["Puxian Min"]="莆仙語",["Min Zhong"]="閩中語",["Zhongshan Min"]="中山閩語",["Northern Pinghua"]="北部平話",["Southern Pinghua"]="南部平話",["Shehua"]="畲話",["Waxiang"]="瓦鄉話",["Wu"]="吳語",["Xiang"]="湘語" }; return '"' .. t[s] .. '"' end todo['chinese'] = function(s) return '"' .. s .. '"' end todo['link'] = function(s) return '"' .. s .. '"' end todo['lat'] = function(s) return s end todo['long'] = function(s) return s end for k, f in pairs(todo) do			if t[k] then table.insert(ret, string.format('\t%s = %s', k == 'chinese' and 'english' or k, f(t[k]))) end end return string.format('variety_data["%s"] = {\n%s\n}', h, table.concat(ret, ',\n')) end local ret = {} for _, k in pairs(query) do		table.insert(ret, string.format("-- after %s", data[getmetatable(data).findk(data, k) - 1])) table.insert(ret, dump(k, data[k])) end return frame:extensionTag('syntaxhighlight', table.concat(ret, '\n'), { lang = 'lua' } ) end

return export