模块:读音显示:修订间差异
来自潮语辞书
更多操作
小无编辑摘要 |
小无编辑摘要 |
||
第9行: | 第9行: | ||
local mode = frame.args[2] or "潮拼" | local mode = frame.args[2] or "潮拼" | ||
local | local sanrao_regions = { "三饶", "凤凰", "新丰", "新塘", "汤溪", "浮山", "浮滨", "东山" } | ||
for _, region in ipairs(regions) do | local haiyang_regions = { "府城", "枫溪", "古巷", "凤塘", "意溪", "赤凤", "归湖", "浮洋" } | ||
local function renderRegions(regions) | |||
local items = {} | |||
for _, region in ipairs(regions) do | |||
local reading = frame:callParserFunction{ | |||
name = "#invoke", | |||
args = { "字表调用", "getReading", char, region, mode } | |||
} | |||
table.insert(items, | |||
string.format( | |||
'<li><span class="place">%s</span><span class="pronunciation">%s</span></li>', | |||
region, reading or "查无" | |||
) | |||
) | ) | ||
) | end | ||
return table.concat(items, "\n") | |||
end | end | ||
local sanrao_html = renderRegions(sanrao_regions) | |||
local haiyang_html = renderRegions(haiyang_regions) | |||
local class = (mode == "IPA") and "pronunciation-ipa" or "pronunciation-chao" | local class = (mode == "IPA") and "pronunciation-ipa" or "pronunciation-chao" | ||
local html = string.format([[ | |||
local html = string.format([[ | |||
<div class="entry-section regional-pronunciation-section %s"> | <div class="entry-section regional-pronunciation-section %s"> | ||
<h2>各地方音</h2> | <h2>各地方音</h2> | ||
<div class="region-group"> | <div class="region-group"> | ||
<div class="shanggu-serif"><big>饶平- | <div class="shanggu-serif"><big>饶平-三饶片</big></div> | ||
<ul class="dialect-list"> | <ul class="dialect-list"> | ||
%s | %s | ||
</ul> | </ul> | ||
</div> | </div> | ||
</div>]], class, | |||
<div class="region-group"> | |||
<div class="shanggu-serif"><big>海阳-府城片</big></div> | |||
<ul class="dialect-list"> | |||
%s | |||
</ul> | |||
</div> | |||
</div>]], class, sanrao_html, haiyang_html) | |||
return html | return html |
2025年7月10日 (四) 07:16的版本
此模块的文档可以在模块:读音显示/doc创建
local p = {}
local mw = mw
function p.render(frame)
local char = frame.args[1]
if not char or char == "" then
return "错误:缺少字。"
end
local mode = frame.args[2] or "潮拼"
local sanrao_regions = { "三饶", "凤凰", "新丰", "新塘", "汤溪", "浮山", "浮滨", "东山" }
local haiyang_regions = { "府城", "枫溪", "古巷", "凤塘", "意溪", "赤凤", "归湖", "浮洋" }
local function renderRegions(regions)
local items = {}
for _, region in ipairs(regions) do
local reading = frame:callParserFunction{
name = "#invoke",
args = { "字表调用", "getReading", char, region, mode }
}
table.insert(items,
string.format(
'<li><span class="place">%s</span><span class="pronunciation">%s</span></li>',
region, reading or "查无"
)
)
end
return table.concat(items, "\n")
end
local sanrao_html = renderRegions(sanrao_regions)
local haiyang_html = renderRegions(haiyang_regions)
local class = (mode == "IPA") and "pronunciation-ipa" or "pronunciation-chao"
local html = string.format([[
<div class="entry-section regional-pronunciation-section %s">
<h2>各地方音</h2>
<div class="region-group">
<div class="shanggu-serif"><big>饶平-三饶片</big></div>
<ul class="dialect-list">
%s
</ul>
</div>
<div class="region-group">
<div class="shanggu-serif"><big>海阳-府城片</big></div>
<ul class="dialect-list">
%s
</ul>
</div>
</div>]], class, sanrao_html, haiyang_html)
return html
end
return p