local export = {}
local find = mw.ustring.find
local match = mw.ustring.match
local gsub = mw.ustring.gsub
local langname = {
= "Min Dong dili",
= "Mandarin dili",
= "Jin Çincesi",
= "Dunganca",
= "Gan dili",
= "Hakka Çincesi",
= "Hunan dili",
= "Min Bei dili",
= "Min Nan dili",
= "Wu Çincesi",
= "Kantonca",
}
local langname_abbr = {
= "Mandarin dili",
= "Siçuan Mandarin dili",
= "Dunganca",
= "Kantonca",
= "Taishanca",
= "Gan dili",
= "Hakka Çincesi",
= "Jin Çincesi",
= "Min Bei dili",
= "Min Dong dili",
= "Min Nan dili",
= "Teochew dili",
= "Wu Çincesi",
= "Hunan dili",
}
local pos_aliases_cat = {
= "adlar", = "adlar",
= "özel adlar", = "özel adlar",
= "adıllar",
= "eylemler", = "eylemler",
= "ön adlar", = "ön adlar",
= "belirteçler", = "belirteçler",
= "ilgeçler", = "ilgeçler",
= "bağlaçlar", = "bağlaçlar",
= "ön ekler", = "ön ekler",
= "son ekler", = "son ekler",
= "atasözleri", = "atasözleri",
= "deyimler", = "deyimler",
= "chengyu", = "chengyu", = "chengyu",
= "sözceler", = "sözceler",
= "ünlemler", = "ünlemler",
= "sınıflandırıcılar", = "sınıflandırıcılar",
= "sayı adları", = "sayı adları",
= "kısaltmalar", = "kısaltmalar",
= "belirleyiciler", = "belirleyiciler",
= "heceler",
}
-- 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%\">'''Not''': " .. text .. ".</div>"
end
local function ipa_format(text)
local numbers = { ='¹',='²',='³',='⁴',='⁵',='⁰',='⁻',='/, /' }
return gsub(text,'',numbers)
end
local function add_audio(text, audio, lang)
-- This function has side effects
if audio then
if audio == "e" then audio = string.format('%s-%s.ogg', lang, mw.title.getCurrentTitle().baseText) end
table.insert(text, '\n*** [[Dosya:')
table.insert(text, audio)
table.insert(text, ']]')
table.insert(text, '[[Kategori:')
table.insert(text, langname)
table.insert(text, ' ses dosyaları olan sözcükler]]')
end
end
local function add_audio_show(text, audio, lang)
-- This function has side effects
if audio then
if audio == "e" then audio = string.format('%s-%s.ogg', lang, mw.title.getCurrentTitle().baseText) end
table.insert(text, '\n*:: <div style="display:inline-block; position:relative; top:0.5em;">[[Dosya:')
table.insert(text, audio)
table.insert(text, ']]</div>')
table.insert(text, '[[Kategori:')
table.insert(text, langname)
table.insert(text, ' ses dosyaları olan sözcükler]]')
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 = ine(args) or title.text
-- Unicode pattern for single Han character, with non-NFC characters
-- inserted using mw.ustring.char because they can't be saved in a MediaWiki
-- page.
-- https://unicode.org/cldr/utility/regex.jsp?a=%5Cp%7BHani%7D
local hanzi = "^[⺀-⺙⺛-⻳⼀-⿕々〇〡-〩〸-〻㐀-䶿一-鿼"
.. mw.ustring.char(0xF900) .. "-" .. mw.ustring.char(0xFA6D)
.. mw.ustring.char(0xFA70) .. "-" .. mw.ustring.char(0xFAD9)
.. "𠀀-𪛝𪜀-𫜴𫝀-𫠝𫠠-𬺡𬺰-𮯠" .. mw.ustring.char(0x2F800)
.. "-" .. mw.ustring.char(0x2FA1D) .. "𰀀-𱍊]$"
local is_single_hanzi = mw.ustring.find(pagename, hanzi) ~= nil
local namespace = ine(args) or title.nsText
local m_rom = ine(args)
local m_s_rom = ine(args)
local dg_rom = ine(args)
local c_rom = ine(args)
local c_t_rom = ine(args)
local g_rom = ine(args)
local h_rom = ine(args)
local j_rom = ine(args)
local mb_rom = ine(args)
local md_rom = ine(args)
local mn_rom = ine(args)
local mn_t_rom = ine(args)
local w_rom = ine(args)
local x_rom = ine(args)
local m_audio = ine(args)
local m_audio2 = ine(args)
local m_s_audio = ine(args)
local dg_audio = ine(args)
local c_audio = ine(args)
local c_t_audio = ine(args)
local g_audio = ine(args)
local h_audio = ine(args)
local j_audio = ine(args)
local md_audio = ine(args)
local mn_audio = ine(args)
local mn_t_audio = ine(args)
local w_audio = ine(args)
local x_audio = ine(args)
local dial = ine(args)
local mc = ine(args) or false
local oc = ine(args) or false
local only_cat = args == "evet"
local text = {} --the pronunciation table
if not only_cat then
--The whole table consists of 4 parts
--"textShow" contains Part 1, 3 and 4
local textShow = {'<div class="main-box zhpron" style="display:inline-block; padding:10px; font-size:100%; overflow: hidden">'}
--"textHide" is Part 2
local textHide = {}
table.insert(textShow, '<div class="vsSwitcher" data-toggle-category="Söylenişleri">\n<span class="vsToggleElement" style="float: right;"></span>')
--Part 1 and 2, "Pronunciation" and "Pronunciation expressed in different romanizations"
if m_rom or m_s_rom or dg_rom then
table.insert(textShow, '\n* ]')
end
if m_rom or m_audio then
local m_args = {}
local m_pron = require("Modül:cmn-söyleniş")
if m_rom then
local str_analysis = m_pron.diz_analiz
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, 'baş', table.concat(other_m_vars) ~= ""))
m_args = str_analysis(m_rom,'')
local m_args_names = {
'1n','1na','1nb','1nc','1nd','py','büy','vs','vs2','vs3','s','ses','er','ervs','ervs2','ervs3','ers','erses',
'2n','2na','2nb','2nc','2nd','2py','2büy','2vs','2vs2','2vs3','2s','2ses','2er','2ervs','2ervs2','2ervs3','2ers','2erses',
'3n','3na','3nb','3nc','3nd','3py','3büy','3vs','3vs2','3vs3','3s','3ses','3er','3ervs','3ervs2','3ervs3','3ers','3erses',
'4n','4na','4nb','4nc','4nd','4py','4büy','4vs','4vs2','4vs3','4s','4ses','4er','4ervs','4ervs2','4ervs3','4ers','4erses',
'5n','5na','5nb','5nc','5nd','5py','5büy','5vs','5vs2','5vs3','5s','5ses','5er','5ervs','5ervs2','5ervs3','5ers','5erses',
}
for _, name in ipairs(m_args_names) do
m_args = str_analysis(m_rom, name)
end
for i = 2, 5 do
m_args = str_analysis(m_rom, tostring(i))
end
end
m_args = m_audio
m_args = m_audio2
local debug = ""
for code,name in pairs(m_args) do
debug = debug .. code .. ":" .. name .. ","
end
table.insert(textShow, m_pron.yap_ses(m_args))
table.insert(textHide, m_pron.yap_args(m_args))
if args then table.insert(textHide, makeNote(args)) end
end
if m_s_rom or m_s_audio then
local m_s_pron = require("Modül:cmn-söyleniş-Siçuan")
local m_s_processed = gsub(gsub(gsub(m_s_rom, '/', ' / '), '()()', '%1 %2'), '(+)', '<sup>%1</sup>')
if m_s_rom then
table.insert(textShow, '\n*: <small>(<i>], ]</i>)</small>: ')
table.insert(textShow, Consolas(m_s_processed))
end
add_audio_show(textShow, m_s_audio, 'cmn-siçuan')
if not (m_rom or m_audio) then
table.insert(textHide, '\n* ]')
end
table.insert(textHide, '\n** <small>(<i>]</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>Sinolojik ] <sup>(])</sup></small>: ')
table.insert(textHide, format_IPA(m_s_pron.convert(m_s_rom, 'IPA')))
-- add_audio(textHide, m_s_audio, 'cmn-siçuan')
if args then table.insert(textHide, makeNote(args)) end
end
if dg_rom or dg_audio then
local dg_pron = require("Modül:dng-söyleniş")
local dg_processed = dg_pron.process(dg_rom)
if dg_rom then
table.insert(textShow, '\n*: <small>(<i>], ]</i>)</small>: ')
table.insert(textShow, Consolas(dg_processed))
end
add_audio_show(textShow, dg_audio, 'dng')
if not (m_rom or m_audio or m_s_rom or m_s_audio) then
table.insert(textHide, '\n* ]')
end
table.insert(textHide, '\n** <small>(<i>]</i>)</small>')
table.insert(textHide, '\n*** <small><i>]</i></small>: ')
table.insert(textHide, Consolas(dg_processed))
table.insert(textHide, '\n*** <small>Sinolojik ] <sup>(])</sup></small>: ')
table.insert(textHide, format_IPA(dg_pron.convert(dg_rom, 'IPA')) .. '\n**: <small>(Not: Dunganca söylenişi şu anda deneyseldir ve doğru olmayabilir.)</small>')
-- add_audio(textHide, dg_audio, 'dng')
if args then table.insert(textHide, makeNote(args)) end
end
if c_rom or c_audio or c_t_rom or c_t_audio then
local c_pron = require("Modül:yue-söyleniş")
if c_rom or c_t_rom then
table.insert(textShow, '\n* ]')
table.insert(textHide, '\n* ]')
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('(+)',']')
c_processed = c_processed:gsub('%[%[%[%[','[[')
c_processed = c_processed:gsub('%]%]%]%]',']]')
c_processed = gsub(c_processed, '%]+)%]%]', function(a)
return '+)', '<sup>%1</sup>') .. ']]' end)
else
c_processed = gsub(c_processed, '(+)', '<sup>%1</sup>')
end
if not c_t_rom then
table.insert(textShow, ' <small>(<i>')
else
table.insert(textShow, '\n*: <small>(<i>], ')
end
table.insert(textShow, ']</i>)</small>: ' .. Consolas(c_processed))
add_audio_show(textShow, c_audio, 'yue')
c_rom = c_rom:gsub(']','')
local c_hom = mw.loadData("Modül:yue-söyleniş/eşs")
local c_hom_exists = false
for _,c_first in ipairs(c_pron.jyutping_format(c_rom)) do
if c_hom then
c_hom_exists = c_first
end
end
table.insert(textHide, '\n** <small>(<i>], ]</i>)</small>')
if not c_hom_exists then
table.insert(textHide, '<sup><small><abbr title="Kantonca eşseslisi ekle"><span class="plainlinks">[')
table.insert(textHide, tostring(mw.uri.fullUrl("Modül:yue-söyleniş/eşs",{="edit"})))
table.insert(textHide, ' +]</span></abbr></small></sup>')
end
local c_comma = gsub(c_rom,',()',', %1')
table.insert(textHide, '\n*** <small><i>]</i></small>: ')
table.insert(textHide, Consolas(tostring(gsub(c_comma, '(+)', '<sup>%1</sup>'))))
table.insert(textHide, '\n*** <small><i>]</i></small>: ')
table.insert(textHide, Consolas(c_pron.jyutping_to_yale(c_rom)))
table.insert(textHide, '\n*** <small><i>]</i></small>: ')
table.insert(textHide, Consolas(tostring(gsub(c_pron.jyutping_to_cantonese_pinyin(c_rom), '(+)', '<sup>%1</sup>'))))
table.insert(textHide, '\n*** <small><i>]</i></small>: ')
table.insert(textHide, Consolas(tostring(gsub(c_pron.jyutping_to_guangdong(c_rom), '(+)', '<sup>%1</sup>'))))
table.insert(textHide, '\n*** <small>Sinolojik ] <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>Eşsesliler</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("Modül:yue-söyleniş/eşs",{="edit"})))
table.insert(hom_textHide, ' düzenle]</span></sup></div><div style="visibility:hidden; float:left"><sup><span style="color:#FFF">düzenle</span></sup></div>')
for _,hom in ipairs(c_hom) do
table.insert(hom_text, mw.getCurrentFrame():expandTemplate{ title = "Template: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 and c_rom and (find(c_rom, "^") or find(c_rom, ",")) and mw.ustring.len(pagename) == 1 then
args = "Sıfır başlangıcı " .. format_IPA("/∅-/") .. " yaygın olarak ''ng''-eki ile " .. format_IPA("/ŋ-/") .. " Kantonca'nın bazı çeşitlerinde kullanılmaktadır, buna Hong Kong Kantonca'sı da dahildir"
end
if args then table.insert(textHide, makeNote(args)) end
end
if c_t_rom then
local c_t_processed = c_t_rom:gsub(',()',', %1')
c_t_processed = gsub(c_t_processed, '(%-??)', '<sup>%1</sup>')
table.insert(textShow, (c_rom and '\n*:' or '') .. ' <small>(<i>], ]</i>)</small>: ')
table.insert(textShow, Consolas(c_t_processed))
add_audio_show(textShow, c_t_audio, 'yue-taishan')
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>]</i></small>: ')
table.insert(textHide, Consolas(tostring(gsub(c_t_comma, '(%-??)', '<sup>%1</sup>'))))
table.insert(textHide, '\n*** <small>Sinolojik ] <sup>(])</sup></small>: ')
table.insert(textHide, format_IPA(c_pron.hoisanva_to_ipa(c_t_rom)))
-- add_audio(textHide, c_t_audio, 'yue-taishan')
if args then table.insert(textHide, makeNote(args)) end
end
end
end
if g_rom or g_audio then
local g_pron = require("Modül:gan-söyleniş")
if g_rom then
table.insert(textShow, '\n* ] <small>(<i>]</i>)</small>: ')
table.insert(textShow, Consolas(g_pron.rom(g_rom)))
end
add_audio_show(textShow, g_audio, 'gan')
table.insert(textHide, '\n* ]')
table.insert(textHide, '\n** <small>(<i>]</i>)</small>')
table.insert(textHide, '\n*** <small><i>]</i></small>: ')
table.insert(textHide, Consolas(g_pron.rom(g_rom)))
table.insert(textHide, '\n*** <small>Sinolojik ] <sup>(])</sup></small>: ')
table.insert(textHide, format_IPA('/' .. g_pron.ipa(g_rom) .. '/'))
-- add_audio(textHide, g_audio, 'gan')
if args then table.insert(textHide, makeNote(args)) end
end
if h_rom and (find(h_rom, 'pfs=.') or find(h_rom, 'gd=.')) or h_audio then
local h_pron = require("Modül:hak-söyleniş")
if find(h_rom, "pfs=.") or find(h_rom, 'gd=.') then
table.insert(textShow, '\n* ]')
table.insert(textShow, h_pron.rom_display(h_rom,'yes'))
end
add_audio_show(textShow, h_audio, 'hak')
table.insert(textHide, '\n* ]')
if h_rom then table.insert(textHide, h_pron.rom_display(h_rom,'')) end
-- add_audio(textHide, h_audio, 'hak')
if args then table.insert(textHide, makeNote(args)) end
end
if j_rom or j_audio then
local j_pron = require("Modül:cjy-söyleniş")
if j_rom then
table.insert(textShow, '\n* ] <small>(<i>]</i>)</small>: ')
table.insert(textShow, Consolas(j_pron.rom(j_rom)))
end
add_audio_show(textShow, j_audio, 'cjy')
table.insert(textHide, '\n* ]')
table.insert(textHide, '\n** <small>(<i>]</i>)<sup>]</sup></small>')
if j_rom then
table.insert(textHide, '\n*** <small><i>]</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, ' + ') then
no_sandhi = true
break
end
end
table.insert(textHide, '\n*** <small>Sinolojik ] (<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 then table.insert(textHide, makeNote(args)) end
end
if mb_rom or mb_audio then
local mb_pron = require("Modül:mnp-söyleniş")
if mb_rom then
table.insert(textShow, '\n* ] <small>(<i>]</i>)</small>: ')
table.insert(textShow, Consolas(mb_pron.rom(mb_rom)))
end
add_audio_show(textShow, mb_audio, 'mnp')
table.insert(textHide, '\n* ]')
table.insert(textHide, "\n** <small>(<i>]</i>)</small>")
if mb_rom then
table.insert(textHide, '\n*** <small><i>]</i></small>: ')
table.insert(textHide, Consolas(mb_pron.rom(mb_rom)))
table.insert(textHide, "\n*** <small>Sinolojik ] <sup>(])</sup></small>: ")
table.insert(textHide, format_IPA(mb_pron.ipa(mb_rom)))
end
-- add_audio(textHide, mb_audio, 'mnp')
if args then table.insert(textHide, makeNote(args)) end
end
if md_rom or md_audio then
local md_pron = require("Modül:cdo-söyleniş")
if md_rom then
table.insert(textShow, '\n* ] <small>(<i>]</i>)</small>: ')
table.insert(textShow, Consolas(md_pron.rom(md_rom)))
end
add_audio_show(textShow, md_audio, 'cdo')
table.insert(textHide, '\n* ]')
table.insert(textHide, '\n** <small>(<i>]</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>Sinolojik ] <sup>(])</sup></small>: ')
table.insert(textHide, format_IPA('/' .. md_pron.ipa(md_rom) .. '/'))
else
table.insert(textHide, '\n*** <small>Sinolojik ] <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 then table.insert(textHide, makeNote(args)) end
end
if mn_rom or mn_audio or mn_t_rom or mn_t_audio then
local mn_pron = require("Modül:nan-söyleniş")
if mn_rom or mn_t_rom then
table.insert(textShow, '\n* ]')
if mn_rom then
table.insert(textShow, ( not mn_t_rom and " <small>(<i>" or "\n*: <small>(<i>], ") .. ']</i>)</small>: ')
table.insert(textShow, Consolas(mn_pron.poj_display(mn_pron.poj_check_invalid(mn_rom))))
add_audio_show(textShow, mn_audio, 'nan')
end
if mn_t_rom then
table.insert(textShow, (mn_rom and '\n*:' or '') .. ' <small>(<i>], ]</i>)</small>: ')
table.insert(textShow, Consolas(mn_pron.pengim_display(mn_t_rom)))
add_audio_show(textShow, mn_t_audio, 'nan-teochew')
end
end
table.insert(textHide, '\n* ]')
if mn_rom or mn_audio then
table.insert(textHide, mn_pron.generate_all(mn_rom))
-- add_audio(textHide, mn_audio, 'nan')
if args then table.insert(textHide, makeNote(args)) end
end
if mn_t_rom or mn_t_audio then
table.insert(textHide, '\n** <small>(<i>]</i>)</small>')
table.insert(textHide, '\n*** <small><i>]</i></small>: ')
table.insert(textHide, Consolas(mn_pron.pengim_display(mn_t_rom)))
table.insert(textHide, '\n*** <small><i>]-like</i></small>: ')
table.insert(textHide, Consolas(mn_pron.pengim_to_pojlike_conv(mn_t_rom)))
table.insert(textHide, '\n*** <small>Sinolojik ] <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 then table.insert(textHide, makeNote(args)) end
end
end
if w_rom or w_audio then
local w_pron = require("Modül:wuu-söyleniş")
if w_rom then
table.insert(textShow, '\n* ] <small>(<i>]</i>)</small>: ')
table.insert(textShow, Consolas(w_pron.rom(w_rom)))
end
add_audio_show(textShow, w_audio, 'wuu')
table.insert(textHide, '\n* ]')
table.insert(textHide, '\n** <small>(<i>]</i>)</small>')
table.insert(textHide, '\n*** <small><i>]</i></small>: ')
table.insert(textHide, Consolas(w_pron.rom(w_rom)))
table.insert(textHide, '\n*** <small>Sinolojik ] <sup>(])</sup></small>: ')
table.insert(textHide, format_IPA('/' .. w_pron.ipa_conv(w_rom) .. '/'))
-- add_audio(textHide, w_audio, 'wuu')
if args then table.insert(textHide, makeNote(args)) end
end
if x_rom or x_audio then
local x_pron = require("Modül:hsn-söyleniş")
if x_rom then
table.insert(textShow, '\n* ] <small>(<i>]</i>)</small>: ')
table.insert(textShow, Consolas(x_pron.rom(x_rom)))
end
add_audio_show(textShow, x_audio, 'hsn')
table.insert(textHide, '\n* ]')
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>]</i></small>: ')
table.insert(textHide, Consolas(x_pron.rom(x_rom)))
table.insert(textHide, '\n*** <small>Sinolojik ] <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>Sinolojik ] <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 then table.insert(textHide, makeNote(args)) end
end
-- combine textShow and textHide into text
text = {
table.concat(textShow),
'\n<div class="vsHide">\n----\n',
table.concat(textHide),
'</div></div>'
}
--if not c_rom then table.insert(text, "]") end
--Part 3 "Lehçe verileri"
if dial ~= "h" and is_single_hanzi then
local success, m_dial = pcall(mw.loadData, "Modül:zh/veri/lehçe-söyl/" .. pagename)
if success then
local dialPron = {}
local temporary = {}
if dial and find(dial, "^+$") then
for element in mw.text.gsplit(dial, ",") do
table.insert(dialPron, m_dial)
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) do
table.insert(temporary, object)
end
end
local rand = mw.ustring.gsub("-" .. table.concat(temporary), "", mw.ustring.codepoint('%1'))
table.insert(text,
'\n----\n<div class="vsSwitcher" data-toggle-category="Söylenişleri" style="background-color:#FAFFFA">\n* ' ..
'<span style="color:#3366bb">Lehçe verileri</span>' ..
'<span class="vsToggleElement" style="float:right; padding:0 0; font-size:90%"></span>\n' ..
'<div class="vsHide">'
)
table.insert(text, '\n{| class="wikitable" ' ..
'id="' .. 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">="edit"})), ' düzenle]</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, "Çeşit\n!", headclr, "Konum"}),
table.concat({"rowspan=17 ", mclr, "Mandarin dili\n!", mclr, "]\n|", mclr}),
table.concat({mclr, "]\n|", mclr}),
table.concat({mclr, "]\n|", mclr}),
table.concat({mclr, "]\n|", mclr}),
table.concat({mclr, "]\n|", mclr}),
table.concat({mclr, "]\n|", mclr}),
table.concat({mclr, "]\n|", mclr}),
table.concat({mclr, "]\n|", mclr}),
table.concat({mclr, "]\n|", mclr}),
table.concat({mclr, "]\n|", mclr}),
table.concat({mclr, "]\n|", mclr}),
table.concat({mclr, "]\n|", mclr}),
table.concat({mclr, "]\n|", mclr}),
table.concat({mclr, "]\n|", mclr}),
table.concat({mclr, "]\n|", mclr}),
table.concat({mclr, "]\n|", mclr}),
table.concat({mclr, "]\n|", mclr}),
table.concat({"rowspan=3 ", jclr, "Jin Çincesi\n!", jclr, "]\n|", jclr}),
table.concat({jclr, "]\n|", jclr}),
table.concat({jclr, "]\n|", jclr}),
table.concat({"rowspan=4 ", wclr, "Wu Çincesi\n!", wclr, "]\n|", wclr}),
table.concat({wclr, "]\n|", wclr}),
table.concat({wclr, "]\n|" , wclr}),
table.concat({wclr, "]\n|", wclr}),
table.concat({"rowspan=2 ", huclr, "Hui\n!", huclr, "]\n|", huclr}),
table.concat({huclr, "]\n|", huclr}),
table.concat({"rowspan=2 ", xclr, "Hunan dili\n!", xclr, "]\n|", xclr}),
table.concat({xclr, "]\n|", xclr}),
table.concat({gclr, "Gan dili\n!", gclr, "]\n|", gclr}),
table.concat({"rowspan=2 ", haclr, "Hakka Çincesi\n!", haclr, "]\n|", haclr}),
table.concat({haclr, "]\n|", haclr}),
table.concat({"rowspan=3 ", cclr, "Kantonca\n!", cclr, "]\n|", cclr}),
table.concat({cclr, "]\n|", cclr}),
table.concat({cclr, "]\n|", cclr}),
table.concat({"rowspan=5 ", minclr, "Min\n!", minclr, "] (Min Nan dili)\n|", minclr}),
table.concat({minclr, "] (Min Dong dili)\n|", minclr}),
table.concat({minclr, "] (Min Bei dili)\n|", minclr}),
table.concat({minclr, "] (Min Nan dili)\n|", minclr}),
table.concat({minclr, "] (Min Nan dili)\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, "()()", "%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)
end
if locationNo == 1 then
local situation = dialPron
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))
table.insert(text, locEnd)
table.insert(text, fmtDial(dialPron, locationNo))
table.insert(text, "</span>")
end
end
end
table.insert(text, "\n|}</div></div>")
end
end
--Part 4 "Middle Chinese & Old Chinese"
local mc_preview, oc_preview
local m_ltc_pron = require("Modül:ltc-söyleniş")
local m_och_pron = require("Modül:och-söyleniş")
-- !!!
-- The following function modifies the tables generated by mod:ltc-söyleniş and mod:och-söyleniş, shifting them
-- from using "mw-collapsible" to using "vsSwitcher", because the former
-- can not collapse on the mobile site and makes Chinese entries a mess.
-- It is supposed to be a temporary solution.
-- !!!
local function shiftCustomtoggle2Vsswitcher(s)
local result
result, _ = s:gsub(
'\n* <div title="expand" class="mw%-customtoggle+">',
'\n<div class="vsSwitcher" data-toggle-category="Söylenişleri">\n* '
):gsub(
'<span style="float:right; border:1px solid #ccc; border%-radius:1px; padding:0 0; font%-size:90%%">▼</span>(.-)</div>\n{| class="wikitable',
'<span class="vsToggleElement" style="float:right; padding:0 0; font-size:90%%"></span>%1\n<div class="vsHide">\n{| class="wikitable'
):gsub(
'{| class="wikitable mw%-collapsible mw%-collapsed" id="+"',
'{| class="wikitable"'
):gsub(
'\n|}$',
'\n|}</div></div>'
)
return result
end
if mc then
mc_preview = m_ltc_pron.retrieve_pron(pagename, false, mc, true)
if not mc_preview then
--require('Modül:debug').track('zh-söyleniş/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('Modül:debug').track('zh-söyleniş/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, shiftCustomtoggle2Vsswitcher(m_ltc_pron.ipa(mc, mc_preview)))
end
if oc then
table.insert(text, shiftCustomtoggle2Vsswitcher(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, ']')
if is_single_hanzi then
if mc_preview:find'k̚$' then
table.insert(text, ']')
elseif mc_preview:find't̚$' then
table.insert(text, ']')
elseif mc_preview:find'p̚$' then
table.insert(text, ']')
end
end
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, ']')
end
if not ine(args) then
table.insert(text, ']')
end
end
end
local conv_text = {} --categories
if namespace == "" then
local catText = args or ""
local cat_start = '[[Kategori:'
local cat_end = ']]'
if w_rom then
w_rom = gsub(w_rom, '%d', '')
end
local sortkey = require("Modül:zh-sıraanahtarı").makeSortKey(pagename)
local function add_cat(cat_table, name, cat, rom)
table.insert(cat_table, cat_start .. name .. cat .. "|" .. rom .. cat_end)
end
local cats = mw.text.split(catText, ',', true)
if pos_aliases_cat] == 'chengyu' then
table.insert(cats, 2, 'deyimler')
end
table.insert(cats, 1, "sözcükler")
for i = 1, #cats do
local cat = cats
if cat == "" then break end
cat = gsub(cat, '^ +', '')
if find(cat, ':') then
local cat_split = mw.text.split(cat, ':', true)
local lang_name = langname_abbr]
local category = pos_aliases_cat] or cat
add_cat(conv_text, 'Çince ', category, sortkey)
table.insert(conv_text,
cat_start .. lang_name .. ' ' .. category .. '|'
.. (lang_name == 'Kantonca' and c_rom or
(lang_name == 'Min Nan dili' and mn_rom or mn_t_rom or sortkey)) .. cat_end)
else
cat = pos_aliases_cat or cat
add_cat(conv_text, 'Çince ', cat, sortkey)
if m_rom then add_cat(conv_text, 'Mandarin dili ', cat, m_rom) end
if m_s_rom or m_s_audio then add_cat(conv_text, 'Mandarin dili ', cat, m_s_rom) end
if dg_rom or dg_audio then add_cat(conv_text, 'Dunganca ', cat, dg_rom) end
if c_rom then add_cat(conv_text, 'Kantonca ', cat, c_rom:gsub(']','')) end
if c_t_rom then add_cat(conv_text, 'Taishanca ', cat, c_t_rom) end
if g_rom or g_audio then add_cat(conv_text, 'Gan dili ', cat, 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, 'Hakka Çincesi ', cat, mw.ustring.gsub(mw.ustring.gsub(h_rom, 'pfs=', ''), 'gd=', ''))
end
if j_rom or j_audio then add_cat(conv_text, 'Jin Çincesi ', cat, j_rom) end
if mb_rom or mb_audio then add_cat(conv_text, 'Min Bei dili ', cat, mb_rom) end
if md_rom or md_audio then add_cat(conv_text, 'Min Dong dili ', cat, md_rom) end
if mn_rom or mn_audio then add_cat(conv_text, 'Min Nan dili ', cat, mn_rom) end
if mn_t_rom or mn_t_audio then add_cat(conv_text, 'Teochew dili ', cat, mn_t_rom) end
if w_rom or w_audio then add_cat(conv_text, 'Wu Çincesi ', cat, w_rom) end
if x_rom or x_audio then add_cat(conv_text, 'Hunan dili ', cat, x_rom) end
end
end
table.insert(conv_text, cat_start .. 'Çince IPA okunuşu olan sözcükler|' .. sortkey .. cat_end)
if is_single_hanzi then
table.insert(conv_text, cat_start .. 'Han karakterleri|' .. sortkey .. cat_end)
table.insert(conv_text, cat_start .. 'Çince Han karakterleri|' .. sortkey .. cat_end)
end
end
local output = table.concat(text) .. table.concat(conv_text)
if namespace ~= '' then
output = gsub(output, "%]+%]%]", "")
end
return require("Modül:TemplateStyles")("MediaWiki:Z_wikistyles.css") .. output .. "<div style='clear:both'></div>"
end
return export