モジュール:zh-pron
ナビゲーションに移動
検索に移動
このモジュールについての説明文ページを モジュール:zh-pron/doc に作成できます
local export = {}
local find = mw.ustring.find
local match = mw.ustring.match
local gsub = mw.ustring.gsub
local langname = {
["cdo"] = "Min Dong",
["cmn"] = "Mandarin",
["cjy"] = "Jin",
["dng"] = "Dungan",
["gan"] = "Gan",
["hak"] = "Hakka",
["hsn"] = "Xiang",
["mnp"] = "Min Bei",
["nan"] = "Min Nan",
["wuu"] = "Wu",
["yue"] = "Cantonese",
}
local langname_abbr = {
["m"] = "Mandarin",
["m-s"] = "Sichuanese",
["dg"] = "Dungan",
["c"] = "Cantonese",
["c-t"] = "Taishanese",
["g"] = "Gan",
["h"] = "Hakka",
["j"] = "Jin",
["mb"] = "Min Bei",
["md"] = "Min Dong",
["mn"] = "Min Nan",
["mn-t"] = "Min Nan",
["w"] = "Wu",
["x"] = "Xiang",
}
local pos_aliases_cat = {
["n"] = "名詞", ["noun"] = "名詞",
["pn"] = "固有名詞", ["propn"] = "固有名詞", ["proper"] = "固有名詞", ["proper noun"] = "固有名詞",
["pron"] = "代名詞", ["pronoun"] = "代名詞",
["v"] = "動詞", ["verb"] = "動詞",
["a"] = "形容詞", ["adj"] = "形容詞", ["adjective"] = "形容詞",
["adv"] = "副詞", ["adverb"] = "副詞",
["prep"] = "介詞", ["pre"] = "介詞",
["postp"] = "後置詞", ["post"] = "後置詞",
["con"] = "接続詞", ["conj"] = "接続詞", ["conjunction"] = "接続詞",
["part"] = "助詞", ["particle"] = "助詞",
["pref"] = "接頭辞", ["prefix"] = "接頭辞",
["suf"] = "接尾辞", ["suffix"] = "接尾辞",
["interfix"] = "接中辞",
["prov"] = "ことわざ", ["proverb"] = "ことわざ",
["id"] = "成句", ["idiom"] = "成句",
["ch"] = "成句", ["cy"] = "成句", ["chengyu"] = "成句",
["ph"] = "phrases", ["phrase"] = "phrases",
["intj"] = "間投詞", ["interj"] = "間投詞", ["interjection"] = "間投詞",
["cl"] = "量詞", ["cls"] = "量詞", ["classifier"] = "量詞",
["num"] = "数詞", ["numeral"] = "数詞",
["abb"] = "略語", ["abbreviation"] = "略語",
["det"] = "限定詞", ["deter"] = "限定詞", ["determiner"] = "限定詞",
}
-- if not empty
local function ine(val)
if val == "" then
return nil
end
return val
end
local function makeNote(text)
if find(text, ": ") then
text = "\n*" .. gsub(gsub(text, "\n", ".\n*"), "([:;]) ", "%1\n**")
elseif find(text, "; ") then
text = "\n*" .. gsub(text, '; ', ";\n*")
end
text = gsub(text, '“([^”]+)”', function (a) return '“' .. gsub(a, ";\n%*+", "; ") .. '”' end)
return "\n<div style=\"border: 1px solid green; padding: 4px; margin: 8px; background: #F7F4ED; font-size: 85%\">'''Note''': " .. text .. ".</div>"
end
local function ipa_format(text)
local numbers = { [1]='¹',[2]='²',[3]='³',[4]='⁴',[5]='⁵',[0]='⁰',['-']='⁻',['/']='/, /' }
return gsub(text,'[0-5%-/]',numbers)
end
local function add_audio(text, audio, lang)
-- This function has side effects
if audio then
if audio == "y" then audio = lang .. '-' .. mw.title.getCurrentTitle().baseText .. '.ogg' end
table.insert(text, '\n*** <div style="display:inline-block; position:relative; top:0.5em;">[[File:')
table.insert(text, audio)
table.insert(text, ']]</div>')
table.insert(text, '[[Category:')
table.insert(text, langname[lang:sub(1, 3)])
table.insert(text, ' terms with audio links]]')
end
end
local function Consolas(text)
return '<span style="font-family: Consolas, monospace;">' .. text .. '</span>'
end
local function format_IPA(text)
return '<span class="IPA">' .. text .. '</span>'
end
function export.make(frame)
local args = frame:getParent().args
local title = mw.title.getCurrentTitle()
local pagename = title.text
local namespace = title.nsText
local m_rom = ine(args["m"])
local m_s_rom = ine(args["m-s"])
local dg_rom = ine(args["dg"])
local c_rom = ine(args["c"])
local c_t_rom = ine(args["c-t"])
local g_rom = ine(args["g"])
local h_rom = ine(args["h"])
local j_rom = ine(args["j"])
local mb_rom = ine(args["mb"])
local md_rom = ine(args["md"])
local mn_rom = ine(args["mn"])
local mn_t_rom = ine(args["mn-t"])
local w_rom = ine(args["w"])
local x_rom = ine(args["x"])
local m_audio = ine(args["ma"])
local m_audio2 = ine(args["ma2"])
local m_s_audio = ine(args["m-sa"])
local dg_audio = ine(args["dga"])
local c_audio = ine(args["ca"])
local c_t_audio = ine(args["c-ta"])
local g_audio = ine(args["ga"])
local h_audio = ine(args["ha"])
local j_audio = ine(args["ja"])
local md_audio = ine(args["mda"])
local mn_audio = ine(args["mna"])
local mn_t_audio = ine(args["mn-ta"])
local w_audio = ine(args["wa"])
local x_audio = ine(args["xa"])
local m_sort = ine(args["m-sort"])
local m_s_sort = ine(args["m-s-sort"])
local dg_sort = ine(args["dg-sort"])
local c_sort = ine(args["c-sort"])
local c_t_sort = ine(args["c-t-sort"])
local g_sort = ine(args["g-sort"])
local h_sort = ine(args["h-sort"])
local j_sort = ine(args["j-sort"])
local mb_sort = ine(args["mb-sort"])
local md_sort = ine(args["md-sort"])
local mn_sort = ine(args["mn-sort"])
local mn_t_sort = ine(args["mn-t-sort"])
local w_sort = ine(args["w-sort"])
local x_sort = ine(args["x-sort"])
local dial = ine(args["dial"])
local mc = ine(args["mc"]) or false
local oc = ine(args["oc"]) or false
local only_cat = args["only_cat"] == "yes"
local text = {}
if not only_cat then
local textShow = {'<div class="toccolours mw-collapsible mw-collapsed zhpron" style="width:500px; font-size:100%; overflow: hidden">'}
local textHide = {}
if m_rom or m_s_rom or dg_rom then
table.insert(textShow, '\n* [[w:標準中国語|現代中国語]]')
end
if m_rom or m_audio then
local m_args = {}
local m_pron = require("モジュール:cmn-pron")
if m_rom then
local str_analysis = m_pron.str_analysis
local other_m_vars = { (m_s_rom or ""), (m_s_audio or ""), (dg_rom or ""), (dg_audio or "") }
table.insert(textShow, '\n' .. str_analysis(m_rom, 'head', table.concat(other_m_vars) ~= ""))
m_args[1] = str_analysis(m_rom,'')
local m_args_names = {
'1n','1na','1nb','1nc','1nd','py','cap','tl','tl2','tl3','a','audio','er','ertl','ertl2','ertl3','era','eraudio',
'2n','2na','2nb','2nc','2nd','2py','2cap','2tl','2tl2','2tl3','2a','2audio','2er','2ertl','2ertl2','2ertl3','2era','2eraudio',
'3n','3na','3nb','3nc','3nd','3py','3cap','3tl','3tl2','3tl3','3a','3audio','3er','3ertl','3ertl2','3ertl3','3era','3eraudio',
'4n','4na','4nb','4nc','4nd','4py','4cap','4tl','4tl2','4tl3','4a','4audio','4er','4ertl','4ertl2','4ertl3','4era','4eraudio',
'5n','5na','5nb','5nc','5nd','5py','5cap','5tl','5tl2','5tl3','5a','5audio','5er','5ertl','5ertl2','5ertl3','5era','5eraudio',
}
for _, name in ipairs(m_args_names) do
m_args[name] = str_analysis(m_rom, name)
end
for i = 2, 5 do
m_args[i] = str_analysis(m_rom, tostring(i))
end
end
m_args['a'] = m_audio
m_args['a2'] = m_audio2
local debug = ""
for code,name in pairs(m_args) do
debug = debug .. code .. ":" .. name .. ","
end
table.insert(textHide, m_pron.make_args(m_args))
if args["m_note"] then table.insert(textHide, makeNote(args["m_note"])) end
end
if m_s_rom or m_s_audio then
local m_s_pron = require("モジュール:cmn-pron-Sichuan")
local m_s_processed = gsub(gsub(gsub(m_s_rom, '/', ' / '), '([%d-])([%a])', '%1 %2'), '([%d-]+)', '<sup>%1</sup>')
if m_s_rom then
table.insert(textShow, '\n*: <small>(<i>[[w:zh:四川话|四川語]], [[w:四川话拼音|四川語拼音]]</i>)</small>: ')
table.insert(textShow, Consolas(m_s_processed))
end
if not (m_rom or m_audio) then
table.insert(textHide, '\n* [[w:標準中国語|現代中国語]]')
end
table.insert(textHide, '\n** <small>(<i>[[w:成都|成都]]</i>)</small>')
table.insert(textHide, '\n*** <small><i>四川語拼音</i></small>: ')
table.insert(textHide, Consolas(m_s_processed))
local xinwenz = m_s_pron.convert(m_s_rom, 'SWZ')
if xinwenz then
table.insert(textHide, '\n*** <small><i>四川語ラテン化新文字</i></small>: ')
table.insert(textHide, Consolas(m_s_pron.convert(m_s_rom, 'SWZ')))
end
table.insert(textHide, '\n*** <small>[[w:国際音声記号|IPA]]</small>: ')
table.insert(textHide, format_IPA(m_s_pron.convert(m_s_rom, 'IPA')))
add_audio(textHide, m_s_audio, 'cmn-sichuan')
if args["m-s_note"] then table.insert(textHide, makeNote(args["m-s_note"])) end
end
if dg_rom or dg_audio then
local dg_pron = require("モジュール:dng-pron")
local dg_processed = dg_pron.process(dg_rom)
if dg_rom then
table.insert(textShow, '\n*: <small>(<i>[[w:ドンガン語|ドンガン語]], [[w:キリル文字|キリル文字]]</i>)</small>: ')
table.insert(textShow, Consolas(dg_processed))
end
if not (m_rom or m_audio or m_s_rom or m_s_audio) then
table.insert(textHide, '\n* [[w:標準中国語|現代中国語]]')
end
table.insert(textHide, '\n** <small>(<i>[[w:ドンガン語|ドンガン語]]</i>)</small>')
table.insert(textHide, '\n*** <small><i>[[w:キリル文字|キリル文字]]</i></small>: ')
table.insert(textHide, Consolas(dg_processed))
table.insert(textHide, '\n*** <small>[[w:国際音声記号|IPA]] <sup>([[付録:ドンガン語の発音表記|?]])</sup></small>: ')
table.insert(textHide, format_IPA(dg_pron.convert(dg_rom, 'IPA')) .. '\n**: <small>(Note: Dungan pronunciation is currently experimental and may be inaccurate.)</small>')
add_audio(textHide, dg_audio, 'dng')
if args["dg_note"] then table.insert(textHide, makeNote(args["dg_note"])) end
end
if c_rom or c_audio or c_t_rom or c_t_audio then
local c_pron = require("モジュール:yue-pron")
if c_rom or c_t_rom then
table.insert(textShow, '\n* [[w:広東語|広東語]]')
table.insert(textHide, '\n* [[w:広東語|広東語]]')
if c_rom then
c_rom = c_rom:gsub("%*","-")
local c_processed = c_rom:gsub(',([^ ])',', %1')
if mw.ustring.len(pagename) == 1 then
c_processed = c_processed:gsub('([^, ]+)','[[%1]]')
c_processed = c_processed:gsub('%[%[%[%[','[[')
c_processed = c_processed:gsub('%]%]%]%]',']]')
c_processed = gsub(c_processed, '%[%[([^%]]+)%]%]', function(a)
return '[[' .. a .. '|' .. gsub(a, '([1-9-]+)', '<sup>%1</sup>') .. ']]' end)
else
c_processed = gsub(c_processed, '([1-9-]+)', '<sup>%1</sup>')
end
if not c_t_rom then
table.insert(textShow, ' <small>(<i>')
else
table.insert(textShow, '\n*: <small>(<i>[[w:広東語|広州方言]], ')
end
table.insert(textShow, '[[w:香港語言学学会粤語拼音方案|粤拼]]</i>)</small>: ' .. Consolas(c_processed))
c_rom = c_rom:gsub('[%[%]]','')
local c_hom = mw.loadData("モジュール:yue-pron/hom")
local c_hom_exists = false
for _,c_first in ipairs(c_pron.jyutping_format(c_rom)) do
if c_hom[c_first] then
c_hom_exists = c_first
end
end
table.insert(textHide, '\n** <small>(<i>[[w:広東語|標準広東語]], [[w:広東語|広州方言]]</i>)</small>')
if not c_hom_exists then
table.insert(textHide, '<sup><small><abbr title="Add Cantonese homophones (click on this if and only if you know what you are doing!)"><span class="plainlinks">[')
table.insert(textHide, tostring(mw.uri.fullUrl("モジュール:yue-pron/hom",{["action"]="edit"})))
table.insert(textHide, ' +]</span></abbr></small></sup>')
end
local c_comma = gsub(c_rom,',([^ ])',', %1')
table.insert(textHide, '\n*** <small><i>[[w:香港語言学学会粤語拼音方案|粤拼]]</i></small>: ')
table.insert(textHide, Consolas(tostring(gsub(c_comma, '([1-9-]+)', '<sup>%1</sup>'))))
table.insert(textHide, '\n*** <small><i>[[w:イェール粤語拼音|イェール式]]</i></small>: ')
table.insert(textHide, Consolas(c_pron.jyutping_to_yale(c_rom)))
table.insert(textHide, '\n*** <small><i>[[w:教育学院拼音方案|教院式]]</i></small>: ')
table.insert(textHide, Consolas(tostring(gsub(c_pron.jyutping_to_cantonese_pinyin(c_rom), '([1-9-]+)', '<sup>%1</sup>'))))
table.insert(textHide, '\n*** <small><i>広東拼音方案</i></small>: ')
table.insert(textHide, Consolas(tostring(gsub(c_pron.jyutping_to_guangdong(c_rom), '([1-9-]+)', '<sup>%1</sup>'))))
table.insert(textHide, '\n*** <small>[[w:国際音声記号|IPA]] <sup>([[付録:広東語の発音表記|?]])</sup></small>: ')
table.insert(textHide, format_IPA('/' .. c_pron.jyutping_to_ipa(c_rom) .. '/'))
for _,c_first in ipairs(c_pron.jyutping_format(c_rom)) do
if c_hom_exists == c_first then
local hom_textHide = {'\n*** <small>同音異義語</small>: <table class="wikitable mw-collapsible mw-collapsed" style="width:15em;margin:0;'}
local hom_text = {}
table.insert(hom_textHide, 'position:left; text-align:center"><tr><th></th></tr><tr><td><div style="float: right; clear: right;"><sup>')
table.insert(hom_textHide, '<span class="plainlinks">[')
table.insert(hom_textHide, tostring(mw.uri.fullUrl("モジュール:yue-pron/hom",{["action"]="edit"})))
table.insert(hom_textHide, ' edit]</span></sup></div><div style="visibility:hidden; float:left"><sup><span style="color:#FFF">edit</span></sup></div>')
for _,hom in ipairs(c_hom[c_first]) do
table.insert(hom_text, mw.getCurrentFrame():expandTemplate{ title = "テンプレート:zh-l", args = { hom, tr = "-" } })
end
table.insert(hom_textHide, table.concat(hom_text, "<br>"))
table.insert(hom_textHide, '</td></tr></table>')
table.insert(textHide, table.concat(hom_textHide))
table.insert(textHide, '[[カテゴリ:広東語 同音異義]]')
end
end
add_audio(textHide, c_audio, 'yue')
if not args["c_note"] and c_rom and (find(c_rom, "^[ao]") or find(c_rom, ",[ao]")) and mw.ustring.len(pagename) == 1 then
args["c_note"] = "The zero initial " .. format_IPA("/∅-/") .. " is commonly pronounced with a ''ng''-initial " .. format_IPA("/ŋ-/") .. " in some varieties of Cantonese, including Hong Kong Cantonese"
end
if args["c_note"] then table.insert(textHide, makeNote(args["c_note"])) end
end
if c_t_rom then
local c_t_processed = c_t_rom:gsub(',([^ ])',', %1')
c_t_processed = gsub(c_t_processed, '([1-9%*]%-?[1-9%*]?)', '<sup>%1</sup>')
table.insert(textShow, (c_rom and '\n*:' or '') .. ' <small>(<i>台山語</i>)</small>: ')
table.insert(textShow, Consolas(c_t_processed))
c_t_rom = c_t_rom:gsub('[%[%]]','')
local c_t_comma = gsub(c_t_rom,',([^ ])',', %1')
table.insert(textHide, '\n** <small>(<i> 台山語, 台城街道</i>)</small>')
table.insert(textHide, '\n*** <small><i>[[Wiktionary:About Chinese/Cantonese/Taishanese|Wiktionary]]</i></small>: ')
table.insert(textHide, Consolas(tostring(gsub(c_t_comma, '([1-9%*]%-?[1-9%*]?)', '<sup>%1</sup>'))))
table.insert(textHide, '\n*** <small>[[w:国際音声記号|IPA]]</small>: ')
table.insert(textHide, format_IPA(c_pron.hoisanva_to_ipa(c_t_rom)))
add_audio(textHide, c_t_audio, 'yue-taishan')
if args["c-t_note"] then table.insert(textHide, makeNote(args["c-t_note"])) end
end
end
end
if g_rom or g_audio then
local g_pron = require("モジュール:gan-pron")
if g_rom then
table.insert(textShow, '\n* [[w:贛語|贛語]]: ')
table.insert(textShow, Consolas(g_pron.rom(g_rom)))
end
table.insert(textHide, '\n* [[w:贛語|贛語]]')
table.insert(textHide, '\n** <small>(<i>南昌語</i>)</small>')
table.insert(textHide, '\n*** <small><i>[[Wiktionary:About Chinese/Gan|Wiktionary]]</i></small>: ')
table.insert(textHide, Consolas(g_pron.rom(g_rom)))
table.insert(textHide, '\n*** <small>[[w:国際音声記号|IPA]] <sup>([[付録:贛語の発音表記|?]])</sup></small>: ')
table.insert(textHide, format_IPA('/' .. g_pron.ipa(g_rom) .. '/'))
add_audio(textHide, g_audio, 'gan')
if args["g_note"] then table.insert(textHide, makeNote(args["g_note"])) end
end
if h_rom and (find(h_rom, 'pfs=.') or find(h_rom, 'gd=.')) or h_audio then
local h_pron = require("モジュール:hak-pron")
if find(h_rom, "pfs=.") or find(h_rom, 'gd=.') then
table.insert(textShow, '\n* [[w:客家語|客家語]]')
table.insert(textShow, h_pron.rom_display(h_rom,'yes'))
end
table.insert(textHide, '\n* [[w:客家語|客家語]]')
if h_rom then table.insert(textHide, h_pron.rom_display(h_rom,'')) end
if h_audio then add_audio(textHide,h_audio,'hak') end
if args["h_note"] then table.insert(textHide, makeNote(args["h_note"])) end
end
if j_rom or j_audio then
local j_pron = require("モジュール:cjy-pron")
if j_rom then
table.insert(textShow, '\n* [[w:晋語|晋語]] <small>(<i>[[Wiktionary:About Chinese/Jin|Wiktionary]]</i>)</small>: ')
table.insert(textShow, Consolas(j_pron.rom(j_rom)))
end
table.insert(textHide, '\n* [[w:晋語|晋語]]')
table.insert(textHide, '\n** <small>(<i>太原語</i>)<sup>[[:w:zh:太原話|+]]</sup></small>')
if j_rom then
table.insert(textHide, '\n*** <small><i>[[Wiktionary:About Chinese/Jin|Wiktionary]]</i></small>: ')
table.insert(textHide, Consolas(j_pron.rom(j_rom)))
end
local no_sandhi = false
local roms = mw.text.split(j_rom, '/')
for i = 1, table.getn(roms) do
if find(roms[i], ' [^ ]+ ') then
no_sandhi = true
break
end
end
table.insert(textHide, '\n*** <small>[[w:国際音声記号|IPA]] (<i>old-style' .. (no_sandhi and ', no sandhi' or '') .. '</i>)</small>: ')
table.insert(textHide, format_IPA('/' .. j_pron.ipa(j_rom, no_sandhi and "no_sandhi" or "") .. '/'))
add_audio(textHide, j_audio, 'cjy')
if args["j_note"] then table.insert(textHide, makeNote(args["j_note"])) end
end
if mb_rom or mb_audio then
local mb_pron = require("モジュール:mnp-pron")
if mb_rom then
table.insert(textShow, '\n* [[w:閩北語|閩北語]] <small>(<i>[[w:建寧ローマ字|KCR]]</i>)</small>: ')
table.insert(textShow, Consolas(mb_pron.rom(mb_rom)))
end
table.insert(textHide, '\n* [[w:閩北語|閩北語]]')
table.insert(textHide, "\n** <small>(<i>[[w:建甌語|建甌語]]</i>)</small>")
if mb_rom then
table.insert(textHide, '\n*** <small><i>[[w:建寧ローマ字|建寧ローマ字]]</i></small>: ')
table.insert(textHide, Consolas(mb_pron.rom(mb_rom)))
table.insert(textHide, "\n*** <small>[[w:国際音声記号|IPA]] <sup>([[付録:閩北語の発音表記|?]])</sup></small>: ")
table.insert(textHide, format_IPA(mb_pron.ipa(mb_rom)))
end
add_audio(textHide, mb_audio, 'mnp')
if args["mb_note"] then table.insert(textHide, makeNote(args["mb_note"])) end
end
if md_rom or md_audio then
local md_pron = require("モジュール:cdo-pron")
if md_rom then
table.insert(textShow, '\n* [[w:閩東語|閩東語]] <small>(<i>[[平話字|BUC]]</i>)</small>: ')
table.insert(textShow, Consolas(md_pron.rom(md_rom)))
end
table.insert(textHide, '\n* [[w:閩東語|閩東語]]')
table.insert(textHide, '\n** <small>(<i>[[w:福州語|福州語]]</i>)</small>')
if md_rom then
table.insert(textHide, '\n*** <small><i>[[平話字]]</i></small>: ')
table.insert(textHide, Consolas(md_pron.rom(md_rom)))
if not (md_rom and find(md_rom, '([^/]*)-([^/]*)-([^/]*)-([^/]*)-([^/]*)')) then
table.insert(textHide, '\n*** <small>[[w:国際音声記号|IPA]] <sup>([[付録:閩東語の発音表記|?]])</sup></small>: ')
table.insert(textHide, format_IPA('/' .. md_pron.ipa(md_rom) .. '/'))
else
table.insert(textHide, '\n*** <small>[[w:国際音声記号|IPA]] <sup>([[付録:閩東語の発音表記|?]])</sup> (<i>no sandhi</i>)</small>: ')
table.insert(textHide, format_IPA('/' .. md_pron.ipa(md_rom, "no_sandhi") .. '/'))
end
end
add_audio(textHide, md_audio, 'cdo')
if args["md_note"] then table.insert(textHide, makeNote(args["md_note"])) end
end
if mn_rom or mn_audio or mn_t_rom or mn_t_audio then
local mn_pron = require("モジュール:nan-pron")
if mn_rom or mn_t_rom then
table.insert(textShow, '\n* [[w:閩南語|閩南語]]')
if mn_rom then
table.insert(textShow, ( not mn_t_rom and " <small>(<i>" or "\n*: <small>(<i>[[w:福建語|福建語]], ") .. '[[w:白話字|POJ]]</i>)</small>: ')
table.insert(textShow, Consolas(mn_pron.poj_display(mn_pron.poj_check_invalid(mn_rom))))
end
if mn_t_rom then
table.insert(textShow, (mn_rom and '\n*:' or '') .. ' <small>(<i>[[w:潮州語|潮州語]]拼音</i>)</small>: ')
table.insert(textShow, Consolas(mn_pron.pengim_display(mn_t_rom)))
end
end
table.insert(textHide, '\n* [[w:閩南語|閩南語]]')
if mn_rom or mn_audio then
table.insert(textHide, mn_pron.generate_all(mn_rom))
add_audio(textHide, mn_audio, 'nan')
if args["mn_note"] then table.insert(textHide, makeNote(args["mn_note"])) end
end
if mn_t_rom or mn_t_audio then
table.insert(textHide, '\n** <small>(<i>[[w:潮州語|潮州語]]</i>)</small>')
table.insert(textHide, '\n*** <small><i>[[w:拼音|拼音]]</i></small>: ')
table.insert(textHide, Consolas(mn_pron.pengim_display(mn_t_rom)))
table.insert(textHide, '\n*** <small><i>[[w:白話字|白話字]]-like</i></small>: ')
table.insert(textHide, Consolas(mn_pron.pengim_to_pojlike_conv(mn_t_rom)))
table.insert(textHide, '\n*** <small>[[w:国際音声記号|IPA]] <sup>([[付録:閩南語の発音表記|?]])</sup></small>: ')
table.insert(textHide, format_IPA(mn_pron.pengim_to_ipa_conv(mn_t_rom)))
add_audio(textHide, mn_t_audio, 'nan-teochew')
if args["mn-t_note"] then table.insert(textHide, makeNote(args["mn-t_note"])) end
end
end
if w_rom or w_audio then
local w_pron = require("モジュール:wuu-pron")
if w_rom then
table.insert(textShow, '\n* [[w:呉語|呉語]] <small>(<i>[[Wiktionary:About Chinese/Wu|Wiktionary]]</i>)</small>: ')
table.insert(textShow, Consolas(w_pron.rom(w_rom)))
end
table.insert(textHide, '\n* [[w:呉語|呉語]]')
table.insert(textHide, '\n** <small>(<i>[[w:上海語|上海語]]</i>)</small>')
table.insert(textHide, '\n*** <small><i>[[Wiktionary:About Chinese/Wu|Wiktionary]]</i></small>: ')
table.insert(textHide, Consolas(w_pron.rom(w_rom)))
table.insert(textHide, '\n*** <small>[[w:国際音声記号|IPA]] <sup>([[付録:呉語の発音表記|?]])</sup></small>: ')
table.insert(textHide, format_IPA('/' .. w_pron.ipa_conv(w_rom) .. '/'))
add_audio(textHide, w_audio, 'wuu')
if args["w_note"] then table.insert(textHide, makeNote(args["w_note"])) end
end
if x_rom or x_audio then
local x_pron = require("モジュール:hsn-pron")
if x_rom then
table.insert(textShow, '\n* [[w:湘語|湘語]] <small>(<i>[[Wiktionary:About Chinese/Xiang|Wiktionary]]</i>)</small>: ')
table.insert(textShow, Consolas(x_pron.rom(x_rom)))
end
table.insert(textHide, '\n* [[w:湘語|湘語]]')
table.insert(textHide, '\n** <small>(<i>長沙語</i>)</small>')
if x_rom then
local x_diff = x_pron.stylediff(x_rom)
table.insert(textHide, '\n*** <small><i>[[Wiktionary:About Chinese/Xiang|Wiktionary]]</i></small>: ')
table.insert(textHide, Consolas(x_pron.rom(x_rom)))
table.insert(textHide, '\n*** <small>[[w:国際音声記号|IPA]] <sup>([[付録:湘語の発音表記|?]])</sup>')
table.insert(textHide, x_diff and ' (<i>old-style</i>)' or '')
table.insert(textHide, '</small>: ')
table.insert(textHide, format_IPA('/' .. x_pron.ipa(x_rom) .. '/'))
if x_diff then
table.insert(textHide, '\n*** <small>[[w:国際音声記号|IPA]] <sup>([[付録:湘語の発音表記|?]])</sup> (<i>new-style</i>)</small>: ')
table.insert(textHide, format_IPA('/' .. x_pron.ipa(x_rom, 'new') .. '/'))
end
end
add_audio(textHide, x_audio, 'hsn')
if args["x_note"] then table.insert(textHide, makeNote(args["x_note"])) end
end
text = {table.concat(textShow), '\n<div class="mw-collapsible-content zhpron">\n----\n', table.concat(textHide), '</div>'}
if not c_rom then table.insert(text, "[[Category:Kenny's testing category 2]]") end
if dial ~= "n" and mw.ustring.len(pagename) == 1 then
local success, m_dial = pcall(mw.loadData, "モジュール:zh/data/dial-pron/" .. pagename)
if success then
local dialPron = {}
local temporary = {}
if dial and find(dial, "^[0-9\,]+$") then
for element in mw.text.gsplit(dial, ",") do
table.insert(dialPron, m_dial[tonumber(element)])
end
else
for _, element in ipairs(m_dial) do
table.insert(dialPron, element)
end
end
for _, set in ipairs(dialPron) do
for _, object in ipairs(set[2]) do
table.insert(temporary, object)
end
end
local rand = mw.ustring.gsub("-" .. table.concat(temporary), "[^A-Za-z0-9]", mw.ustring.codepoint('%1'))
table.insert(text, '\n----\n<div style="background-color:#FAFFFA">\n* <div title="expand" ' ..
'class="mw-customtoggle-dial' .. rand .. '"><span style="color:#3366bb">Dialectal data' ..
'</span><span style="float:right; border:1px solid #ccc; border-radius:1px; ' ..
'padding:0 0; font-size:90%">▼</span></div>')
table.insert(text, '\n{| class="wikitable mw-collapsible mw-collapsed" ' ..
'id="mw-customcollapsible-dial' .. rand .. '" style="width:100%; margin:0; ' ..
'text-align:center; border-collapse: collapse; border-style: hidden;"')
local locStart = '\n|-\n!'
local readingStart = table.concat({'\n!style="background:#E8ECFA; width:9em"|',
'<div style="float: right; clear: right; font-size:60%"><span class="plainlinks">[', tostring(mw.uri.fullUrl("Module:zh/data/dial-pron/" .. pagename, {["action"]="edit"})), ' edit]</span></div><span lang="zh" class="Hani">'})
local locEnd = '<span class="IPA">'
local headclr = 'style="background:#E8ECFA"|'
local mclr = 'style="background:#FAF5F0"|'
local jclr = 'style="background:#F0F5FA"|'
local wclr = 'style="background:#F4F0FA"|'
local huclr = 'style="background:#FAF9F0"|'
local xclr = 'style="background:#F0F2FA"|'
local gclr = 'style="background:#F0FAF3"|'
local haclr = 'style="background:#FAF0F6"|'
local cclr = 'style="background:#F0F5FA"|'
local minclr = 'style="background:#F7FAF0"|'
local clrList = {
mclr, mclr, mclr, mclr, mclr, mclr, mclr, mclr, mclr, mclr,
mclr, mclr, mclr, mclr, mclr, mclr, mclr, jclr, jclr, jclr,
wclr, wclr, wclr, wclr, huclr, huclr, xclr, xclr, gclr, haclr,
haclr, cclr, cclr, cclr, minclr, minclr, minclr, minclr, minclr
}
local locList = {
table.concat({headclr, "Variety\n!", headclr, "Location"}),
table.concat({"rowspan=17 ", mclr, "現代中国語\n!", mclr, "[[w:北京語|北京語]]\n|", mclr}),
table.concat({mclr, "[[w:|ハルビン市|ハルビン語]]\n|", mclr}),
table.concat({mclr, "[[w:|天津市|天津語]]\n|", mclr}),
table.concat({mclr, "[[w:済南市|済南語]]\n|", mclr}),
table.concat({mclr, "[[w:青島市|青島語]]\n|", mclr}),
table.concat({mclr, "[[w:zh:鄭州話|鄭州語]]\n|", mclr}),
table.concat({mclr, "[[w:関中市|関中語]]\n|", mclr}),
table.concat({mclr, "[[w:西寧市|西寧語]]\n|", mclr}),
table.concat({mclr, "[[w:銀川市|銀川語]]\n|", mclr}),
table.concat({mclr, "[[w:zh:蘭州話|蘭州語]]\n|", mclr}),
table.concat({mclr, "[[w:zh:烏魯木齊話|ウルムチ語]]\n|", mclr}),
table.concat({mclr, "[[w:zh:武漢話|武漢語]]\n|", mclr}),
table.concat({mclr, "[[w:|成都市|成都語]]\n|", mclr}),
table.concat({mclr, "[[w:zh:貴陽話|貴陽語]]\n|", mclr}),
table.concat({mclr, "[[w:昆明市|昆明語]]\n|", mclr}),
table.concat({mclr, "[[w:南京市|南京語]]\n|", mclr}),
table.concat({mclr, "[[w:zh:合肥話|合肥語]]\n|", mclr}),
table.concat({"rowspan=3 ", jclr, "晋語\n!", jclr, "[[w:zh:太原話|太原語]]\n|", jclr}),
table.concat({jclr, "[[w:平遥古城|平遥片]]\n|", jclr}),
table.concat({jclr, "張呼片\n|", jclr}),
table.concat({"rowspan=4 ", wclr, "呉語\n!", wclr, "[[w:上海語|上海語]]\n|", wclr}),
table.concat({wclr, "[[w:蘇州市|蘇州語]]\n|", wclr}),
table.concat({wclr, "[[w:杭州市|杭州語]]\n|" , wclr}),
table.concat({wclr, "[[w:温州語|温州語]]\n|", wclr}),
table.concat({"rowspan=2 ", huclr, "徽語\n!", huclr, "[[w:歙県|歙県]]\n|", huclr}),
table.concat({huclr, "[[w:zh:屯溪話|屯溪]]\n|", huclr}),
table.concat({"rowspan=2 ", xclr, "湘語\n!", xclr, "[[w:長沙市|長沙語]]\n|", xclr}),
table.concat({xclr, "[[w:zh:湘潭話|湘潭語]]\n|", xclr}),
table.concat({gclr, "贛語\n!", gclr, "[[w:南昌市|南昌語]]\n|", gclr}),
table.concat({"rowspan=2 ", haclr, "客家語\n!", haclr, "梅県方言\n|", haclr}),
table.concat({haclr, "[[w:桃園市|桃園]]\n|", haclr}),
table.concat({"rowspan=3 ", cclr, "広東語\n!", cclr, "[[w:広州市|広州語]]\n|", cclr}),
table.concat({cclr, "[[w:南寧市|南寧語]]\n|", cclr}),
table.concat({cclr, "[[w:香港|香港方言]]\n|", cclr}),
table.concat({"rowspan=5 ", minclr, "閩語\n!", minclr, "[[w:廈門語|廈門語]] (Min Nan)\n|", minclr}),
table.concat({minclr, "[[w:福州語|福州語]] (閩東語)\n|", minclr}),
table.concat({minclr, "[[w:建甌語|建甌語]] (閩北語)\n|", minclr}),
table.concat({minclr, "[[w:汕頭市|汕頭語]] (閩南語)\n|", minclr}),
table.concat({minclr, "[[w:海口語|海口語]] (閩南語)\n|", minclr})}
local function ipa_correct(ipa, location)
if location == 22 then return (gsub(ipa, "13", "23")) else return ipa end
end
local function fmtDial(text, location)
local fmttedPron = {}
if text == "" then return "" end
for pronunciation in mw.text.gsplit(text, "|") do
local ipa = match(pronunciation, "^[^\(\)一-龯㐀-䶵~,]+")
ipa = gsub(ipa, "([ptk])([0-5])", "%1̚%2")
local environ = match(pronunciation, "[\(\)一-龯㐀-䶵~,]*$") or false
table.insert(fmttedPron, "<span class=\"IPA\"><small>/" ..
tostring(ipa_format(ipa_correct(ipa, location))) .. "/</small></span>" .. (environ
and " <span class=\"Hani\" lang=\"zh\"><small>"..environ.."</small></span>" or nil))
end
return table.concat(fmttedPron, "<br>")
end
for locationNo = 1, 40 do
for readingNo = 1, #dialPron do
if readingNo == 1 then
table.insert(text, locStart)
table.insert(text, locList[locationNo])
end
if locationNo == 1 then
local situation = dialPron[readingNo][1]
table.insert(text, readingStart)
table.insert(text, pagename)
table.insert(text, (pagename ~= situation and " (" ..
gsub(situation, pagename, "<b>" .. pagename .. "</b>") .. ")" or ""))
table.insert(text, "</span>")
else
table.insert(text, (readingNo == 1 and "" or "\n|" .. clrList[locationNo-1]))
table.insert(text, locEnd)
table.insert(text, fmtDial(dialPron[readingNo][2][locationNo-1], locationNo))
table.insert(text, "</span>")
end
end
end
table.insert(text, "\n|}</div>")
end
end
local mc_preview, oc_preview
local m_ltc_pron = require("モジュール:ltc-pron")
local m_och_pron = require("モジュール:och-pron")
if mc then
mc_preview = m_ltc_pron.retrieve_pron(pagename, false, mc, true)
if not mc_preview then
require('モジュール:debug').track('zh-pron/Middle Chinese data not found')
mc = false
end
end
if oc then
oc_preview = m_och_pron.generate_show(pagename, oc)
if not oc_preview then
require('モジュール:debug').track('zh-pron/Old Chinese data not found')
oc = false
end
end
if mc or oc then
table.insert(text, '\n----\n<div style="background-color:#f7fbff">')
if mc then
table.insert(text, m_ltc_pron.ipa(mc, mc_preview))
end
if oc then
table.insert(text, m_och_pron.ipa(oc, oc_preview))
end
table.insert(text, "</div>")
end
table.insert(text, "</div>")
if namespace == "" then
if mc then
mc_sortkey=gsub(gsub(mc_preview, '<[^>]*>', ''), '&[^;]*;', '')
table.insert(text, '[[カテゴリ:中古漢語|' .. mc_sortkey .. ']]')
end
if oc then
if match(oc_preview, 'Zhengzhang') then
oc_sortkey=gsub(oc_preview, '^.*Zhengzhang.*/%*([^/]*)/.*$', '%1')
else
oc_sortkey=gsub(oc_preview, '^.*/([^/]*)/.*$', '%1')
end
oc_sortkey=gsub(gsub(oc_sortkey, '<[^>]*>', ''), '&[^;]*;', '')
table.insert(text, '[[カテゴリ:上古漢語|' .. oc_sortkey .. ']]')
end
if not ine(args["cat"]) then
table.insert(text, '[[カテゴリ:zh-pron 品詞未指定]]')
end
end
end
local conv_text = {}
if namespace == "" then
local catText = args["cat"] or ""
local cat = {}
local cat_start = '[[カテゴリ:'
local cat_end = ']]'
if w_rom then
w_rom = gsub(w_rom, '%d', '')
end
local sortkey = require("モジュール:zh-sortkey").makeSortKey(pagename)
local function add_cat(cat_table, name, cat, rom)
local this_cat = {}
table.insert(this_cat, cat_start)
table.insert(this_cat, name)
table.insert(this_cat, cat)
table.insert(this_cat, "|")
table.insert(this_cat, rom)
table.insert(this_cat, cat_end)
table.insert(cat_table, table.concat(this_cat))
end
cat = mw.text.split(catText, ',', true)
if (pos_aliases_cat[cat[1]] or "") == 'chengyu' then
table.insert(cat, 2, '成句')
end
table.insert(cat, 1, "")
for i = 1, #cat do
if cat[i] == " " then break end
cat[i] = gsub(cat[i], '^ +', '')
if find(cat[i], ':') then
local lang_name, category = langname_abbr[mw.text.split(cat[i], ':', true)[1]], (pos_aliases_cat[mw.text.split(cat[i], ':', true)[2]] or cat[i])
add_cat(conv_text, 'Chinese ', category, sortkey)
table.insert(conv_text, cat_start)
table.insert(conv_text, lang_name)
table.insert(conv_text, ' ')
table.insert(conv_text, category)
table.insert(conv_text, '|')
table.insert(conv_text, (lang_name == 'Cantonese' and c_rom or
(lang_name == 'Min Nan' and mn_rom or mn_t_rom or sortkey)) .. cat_end)
else
cat[i] = pos_aliases_cat[cat[i]] or cat[i]
add_cat(conv_text, '中国語 ', cat[i], sortkey)
if m_rom then add_cat(conv_text, '中国語 ', cat[i], m_sort or m_rom) end
if m_s_rom or m_s_audio then add_cat(conv_text, '中国語 ', cat[i], m_s_sort or m_s_rom) end
if dg_rom or dg_audio then add_cat(conv_text, 'ドンガン語 ', cat[i], dg_sort or dg_rom) end
if c_rom then add_cat(conv_text, '広東語 ', cat[i], c_sort or c_rom:gsub('[%[%]]','')) end
if c_t_rom then add_cat(conv_text, '台山語 ', cat[i], c_t_sort or c_t_rom) end
if g_rom or g_audio then add_cat(conv_text, '贛語 ', cat[i], g_sort or g_rom:gsub("'", "")) end
if h_rom and (find(h_rom, 'pfs=.') or find(h_rom, 'gd=.')) or h_audio then add_cat(conv_text, '客家語 ', cat[i], h_sort or mw.ustring.gsub(mw.ustring.gsub(h_rom, 'pfs=', ''), 'gd=', '')) end
if j_rom or j_audio then add_cat(conv_text, '晋語 ', cat[i], j_sort or j_rom) end
if mb_rom or mb_audio then add_cat(conv_text, '閩北語 ', cat[i], mb_sort or mb_rom) end
if md_rom or md_audio then add_cat(conv_text, '閩東語 ', cat[i], md_sort or md_rom) end
if mn_rom or mn_audio then add_cat(conv_text, '閩南語 ', cat[i], mn_sort or mn_rom) end
if mn_t_rom or mn_t_audio then add_cat(conv_text, '潮州語 ', cat[i], mn_t_sort or mn_t_rom) end
if w_rom or w_audio then add_cat(conv_text, '呉語 ', cat[i], w_sort or w_rom) end
if x_rom or x_audio then add_cat(conv_text, '湘語 ', cat[i], x_sort or x_rom) end
end
end
table.insert(conv_text, cat_start)
table.insert(conv_text, '中国語 国際音声記号あり|')
table.insert(conv_text, sortkey)
table.insert(conv_text, cat_end)
if mw.ustring.len(pagename) == 1 then
table.insert(conv_text, cat_start)
table.insert(conv_text, '漢字|')
table.insert(conv_text, sortkey)
table.insert(conv_text, cat_end)
end
end
if namespace ~= '' then
return (gsub(table.concat(text) .. table.concat(conv_text), "%[%[カテゴリ:[^%]]+%]%]", ""))
else
return (table.concat(text) .. table.concat(conv_text))
end
end
return export