模組:用戶:Cedric tsan cantonais/沙盒/Yue-rom dialecte

來自維基辭典

呢個模組嘅解說可以喺模組:用戶:Cedric tsan cantonais/沙盒/Yue-rom dialecte/doc度開

local export = {}
local replace = mw.ustring.gsub
local match = mw.ustring.match

local m_data = mw.loadData('Module:IPA/data') -- [[Module:IPA/data]]
local m_symbols = mw.loadData('Module:IPA/data/symbols') -- [[Module:IPA/data/symbols]]
local m_syllables -- [[Module:syllables]]; loaded below if needed

local sub = mw.ustring.sub
local find = mw.ustring.find
local gsub = mw.ustring.gsub
local match = mw.ustring.match
local gmatch = mw.ustring.gmatch
local U = mw.ustring.char
-- Import定先,用唔到再剷走都未遲。

local IPA_tones = { '˩', '˨', '˧', '˦', '˥', }
local super_numbers = { '¹', '²', '³', '⁴', '⁵', }

-- 說明:本模組用於生成廣州/南寧以外嘅粵語方言發音嘅索引,目標係喺模裏面直接輸入國際音標就自動生成分類。未來需要多次調試。

function export.index_link(frame)
	local iPa = type(frame) == 'table' and frame.args[1] or frame

	-- 生成索引超鏈接
	local iPa_links = replace(iPa, '([^1-5 ]+)([1-5]+)', '[[:Category:粵語國際音標索引/%1|%1%2]]')
	
	-- 聲調數字轉換成音標聲調符號
	iPa_links = replace(iPa_links, '[1-5]', IPA_tones)

	-- 生成索引文字(捕捉第一個字嘅音標字母)
	local iPa_cat = '[[Category:粵語國際音標索引/' .. match(iPa, '^[^1-5 ]+') ..']]'

	local count = frame.args.count;
	local text = [==[** [[wikipedia:zh-yue:粵語國際音標|國際音標]]:<span style="font-size:150%; font-weight:bold">]==] .. iPa_links .. [==[</span>]==]

	return text .. iPa_cat
end

function export.dialecte_Txt(frame)
	local dialecte = type(frame) == 'table' and frame.args[1] or frame
	
	local dialecte_link = replace(dialecte , '南寧' , '南寧白')
	local dialecte_link = replace(dialecte , '' , '<font color="red">未知方言</font>')
	
	local dialecte_link = dialecte_link .. '話:'
	
	return dialecte_link
end

function export.dialecte_Cat(frame)
	local dialecte = type(frame) == 'table' and frame.args[1] or frame
	
	local dialecte_link = replace(dialecte , '南寧' , '南寧白')
	local dialecte_link = replace(dialecte , '' , '<font color="red">未知方言</font>')
	
	local dialecte_link = dialecte_link .. '話:'
	
	local dialecte_cat = '[[分類:'.. dialecte_link .. ']]'
	
	return dialecte_cat
end

return export