模块:字表调用:修订间差异
来自潮语辞书
更多操作
小无编辑摘要 |
小无编辑摘要 |
||
第1行: | 第1行: | ||
local p = {} | local p = {} | ||
local mw = mw | local mw = mw | ||
-- 地区名到模块路径的映射表 | |||
local region_map = { | |||
-- 饶平-三饶片 | |||
["三饶"] = "饶平-三饶片-三饶", | |||
["凤凰"] = "饶平-三饶片-凤凰", | |||
["新丰"] = "饶平-三饶片-新丰", | |||
["新塘"] = "饶平-三饶片-新塘", | |||
["汤溪"] = "饶平-三饶片-汤溪", | |||
["浮山"] = "饶平-三饶片-浮山", | |||
["浮滨"] = "饶平-三饶片-浮滨", | |||
["东山"] = "饶平-三饶片-东山", | |||
-- 海阳-府城片 | |||
["府城"] = "海阳-府城片-府城", | |||
["枫溪"] = "海阳-府城片-枫溪", | |||
["古巷"] = "海阳-府城片-古巷", | |||
["凤塘"] = "海阳-府城片-凤塘", | |||
["意溪"] = "海阳-府城片-意溪", | |||
["赤凤"] = "海阳-府城片-赤凤", | |||
["归湖"] = "海阳-府城片-归湖", | |||
["浮洋"] = "海阳-府城片-浮洋", | |||
} | |||
function p.getReading(frame) | function p.getReading(frame) | ||
local char = frame.args[1] | local char = frame.args[1] | ||
local region = frame.args[2] | local region = frame.args[2] | ||
local mode = frame.args[3] or "潮拼" | local mode = frame.args[3] or "潮拼" | ||
if not char or char == "" then | if not char or char == "" then | ||
第14行: | 第37行: | ||
end | end | ||
local module_path = " | local module_path = region_map[region] | ||
local ok, mod = pcall(require, "Module:" .. module_path) | if not module_path then | ||
return "查无此地区数据。" | |||
end | |||
local ok, mod = pcall(require, "Module:调查字表/" .. module_path) | |||
if not ok or not mod or not mod.data then | if not ok or not mod or not mod.data then | ||
return "查无此地区数据。" | return "查无此地区数据。" | ||
第27行: | 第54行: | ||
local result = {} | local result = {} | ||
for _, entry in ipairs(readings) do | for _, entry in ipairs(readings) do | ||
local s = entry[mode] or "— | local s = entry[mode] or "—" | ||
local zt = entry["字态"] or "" | local zt = entry["字态"] or "" | ||
local note = entry["注释"] or "" | local note = entry["注释"] or "" |
2025年7月10日 (四) 07:16的版本
此模块的文档可以在模块:字表调用/doc创建
local p = {}
local mw = mw
-- 地区名到模块路径的映射表
local region_map = {
-- 饶平-三饶片
["三饶"] = "饶平-三饶片-三饶",
["凤凰"] = "饶平-三饶片-凤凰",
["新丰"] = "饶平-三饶片-新丰",
["新塘"] = "饶平-三饶片-新塘",
["汤溪"] = "饶平-三饶片-汤溪",
["浮山"] = "饶平-三饶片-浮山",
["浮滨"] = "饶平-三饶片-浮滨",
["东山"] = "饶平-三饶片-东山",
-- 海阳-府城片
["府城"] = "海阳-府城片-府城",
["枫溪"] = "海阳-府城片-枫溪",
["古巷"] = "海阳-府城片-古巷",
["凤塘"] = "海阳-府城片-凤塘",
["意溪"] = "海阳-府城片-意溪",
["赤凤"] = "海阳-府城片-赤凤",
["归湖"] = "海阳-府城片-归湖",
["浮洋"] = "海阳-府城片-浮洋",
}
function p.getReading(frame)
local char = frame.args[1]
local region = frame.args[2]
local mode = frame.args[3] or "潮拼"
if not char or char == "" then
return "错误:缺少字。"
end
if not region or region == "" then
return "错误:缺少地区。"
end
local module_path = region_map[region]
if not module_path then
return "查无此地区数据。"
end
local ok, mod = pcall(require, "Module:调查字表/" .. module_path)
if not ok or not mod or not mod.data then
return "查无此地区数据。"
end
local readings = mod.data[char]
if not readings then
return "查无“" .. char .. "”在" .. region .. "的读音。"
end
local result = {}
for _, entry in ipairs(readings) do
local s = entry[mode] or "—"
local zt = entry["字态"] or ""
local note = entry["注释"] or ""
local gray = entry["灰色"]
if gray then
s = '<span style="color:gray">' .. s .. '</span>'
end
if zt ~= "" then
s = s .. ' <span style="color:#fff;">[' .. zt .. ']</span>'
end
if note ~= "" then
s = s .. ' <sub>' .. mw.text.nowiki(note) .. '</sub>'
end
table.insert(result, '<div>' .. s .. '</div>')
end
return table.concat(result, "\n")
end
return p