Module:User:QFQ/zh-dial-map-helper
Appearance
- The following documentation is located at Module:User:QFQ/zh-dial-map-helper/documentation. [edit]
- Useful links: root page • root page’s subpages • links • transclusions • testcases • sandbox
showkeys
[edit]-- after Mandalay-C
variety_data["Bangkok-C"] = {
group = "粵語",
english = "曼谷(廣府)",
link = "Bangkok",
lat = 13.75,
long = 100.466667
}
-- after Wengyuan
variety_data["Nanxiong-ZJ"] = {
group = "客家語",
english = "南雄(珠璣)",
link = "zh:珠璣巷",
lat = 25.19592,
long = 114.35594
}
-- after Chaoyang
variety_data["Nan'ao-HZ"] = {
group = "閩南語",
english = "南澳(後宅)",
link = "zh:後宅鎮 (南澳縣)",
lat = 23.42024,
long = 117.01934
}
-- after Nan'ao-HZ
variety_data["Nan'ao-YA"] = {
group = "閩南語",
english = "南澳(雲澳)",
link = "zh:雲澳鎮",
lat = 23.40622,
long = 117.10204
}
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