local export = {}
local colour_1 = "#ccece6"
local colour_2 = "#E0F3F3"
local colour_3 = "#F7FCFB"
local function zh_fmt(text)
return text ~= "" and '<span class="Hani" lang="zh">' .. text .. '</span>' or ""
end
local function insert_pron(reading_temp, text, system, i, return_note, index)
reading_temp = mw.ustring.gsub(reading_temp, "() ", "%1")
part = mw.text.split(reading_temp, " ")
IPA = mw.ustring.gsub(part, "^\*", "")
table.remove(part, 1)
return ((i == 1 and (mw.ustring.len(text) == 1 or (index or 1) == 1)) and "/*" or "") .. IPA ..
(mw.ustring.len(text) == i and "/" or "") ..
((#part > 0 and return_note) and (" " .. table.concat(part, " ")) or "")
end
local function pron_table(titlechar, reading, system, reading_index, count, i)
return system == "BS"
and {
nil,
'<b>' .. zh_fmt(titlechar) .. '</b>',
reading_index .. "/" .. count,
reading,
'‹ <i>' .. mw.ustring.gsub(reading, '()', '<sup>%1</sup>') .. '</i> ›',
'<span class="IPAchar">' .. mw.ustring.gsub(insert_pron(reading, titlechar, "BS", 1, true), "ˤ", "ˁ") .. '</span>',
reading
}
or {
nil,
'<b>'..zh_fmt(titlechar)..'</b>',
reading_index .. "/" .. count,
reading,
zh_fmt(".."]]"),
zh_fmt(".."]]"),
reading,
zh_fmt(".."]]"),
'<span class="IPAchar">/*' .. reading .. '/</span>',
mw.ustring.gsub(mw.ustring.gsub(mw.ustring.gsub(reading, "(+)", zh_fmt("%1")), "(,)", "%1<br>"), "()", "]")
}
end
local function get_data(system, ch)
local module = ("Modül:zh/veri/eçin-söyl-%s/%s"):format(system, ch)
local success, data_module = pcall(mw.loadData, module)
return success and data_module
end
function export.ipa(index_text, preview)
local titlechar = mw.title.getCurrentTitle().text
local reading_index = mw.text.split(index_text, ";")
local output_text = {}
local systems = { "BS", "ZS" }
local indiv_pronunciation = { = {}, = {} }
local rand = ""
local moduleName = ""
for system_seq, system in ipairs(systems) do
for i, cp in ipairs { mw.ustring.codepoint(titlechar, 1, -1) } do
local ch = mw.ustring.char(cp)
moduleName = ch
end
end
local fields = {
= {
"]–] sistemi 1.1 " ..
"()" ..
"<div style='float: right; clear: right; font-size:60%'><span class='plainlinks'>[" ..
tostring(mw.uri.fullUrl("Modül:zh/veri/eçin-söyl-BS/"..moduleName, {="edit"})) .. " düzenle]</span></div>",
"<small>Karakter</small>",
"<small>Okunuş #</small>",
"<small>Modern<br>Beijing<br/>(Pinyin)</small>",
"<small>Orta<br>Çince</small>",
"<small>Eski<br>Çince</small>",
"<small>Türkçe</small>"
},
= {
"] sistemi (2003)" ..
"<div style='float: right; clear: right; font-size:60%'><span class='plainlinks'>[" ..
tostring(mw.uri.fullUrl("Modül:zh/veri/eçin-söyl-ZS/"..moduleName, {="edit"})) .. " düzenle]</span></div>",
"<small>Karakter</small>",
"<small>Okunuş #</small>",
"<small>No.</small>",
"<small>Fonetik<br>bileşen</small>",
"<small>Kafiye<br>grubu</small>",
"<small>Kafiye<br>altbölümü</small>",
"<small>Denk gelen<br>OÇ kafiyesi</small>",
"<small>Eski<br>Çince</small>",
"<small>Notlar</small>"
}
}
for system_seq, system in ipairs(systems) do
for i, cp in ipairs { mw.ustring.codepoint(titlechar, 1, -1) } do
local ch = mw.ustring.char(cp)
local data_module = get_data(system, ch)
if data_module then
count = 0
for index, value in ipairs(data_module) do
count = count + 1
end
reading_number = reading_index and (mw.text.split(reading_index, ',') or reading_index) or "y"
if reading_number == "y" then
for reading_index, reading in ipairs(data_module) do
table.insert(indiv_pronunciation, pron_table(ch, reading, system, reading_index, count, i))
end
elseif reading_number == "n" then
break
else
for indiv_number in mw.text.gsplit(reading_number, '\+') do
table.insert(indiv_pronunciation, pron_table(ch, data_module, system, indiv_number, count, i))
end
end
end
end
if indiv_pronunciation then
local hash, results = {}, {}
local value_eff
for _, value in ipairs(indiv_pronunciation) do
local valeur = value
table.remove(valeur, 1)
value_eff = table.concat(valeur)
if not hash then
hash = true
table.insert(value, 1, nil)
results = value
end
end
rand = rand ~= "" and rand or mw.ustring.gsub("oc-" .. value_eff, "", mw.ustring.codepoint)
local fmt = {
header = '\n{| class="wikitable mw-collapsible mw-collapsed" id="mw-customcollapsible-oc' .. rand ..
'" style="width:100%; margin:0; text-align:center; border-collapse: collapse; border-style: hidden;"',
lv1 = '\n|-\n! style="background-color:' .. colour_1 .. '" colspan=' .. #results+1 .. '|',
lv2 = '\n|-\n! style="background-color:' .. colour_2 .. '; width:8em"|',
lv3 = '\n| style="background-color:' .. colour_3 .. '"|',
closing = '\n|}',
BS_note = '\n|-\n|colspan=' .. #results+1 ..
[=[ style="text-align:left; font-size:90%"|<div class="toccolours mw-collapsible mw-collapsed">
''Baxter–Sagart sistemindeki Eski Çince çevirilerinin '''notları''':''
<div class="mw-collapsible-content">
* Parantezler "()" net olmayan ifadeleri belirtir;<br>
* Kare parantezler "" net olmayan kimlikleri belirtir, örn. * aslında *-t veya *-p olabilir;<br>
* Açılı parantez "<>" bir eki ifade eder;<br>
* Tire "-" biçimbirim sınırını ifade eder;<br>
* Nokta "." hece sınırını ifade eder.</div>
</div>]=]
}
table.insert(output_text, fmt.header)
for field_index, field in ipairs(fields) do
if mw.ustring.match(field, "small") then
local field_set = {}
for _, result in ipairs(results) do
table.insert(field_set, result)
end
if table.concat(field_set) ~= "" then
table.insert(output_text, fmt.lv2 .. field .. fmt.lv3 .. table.concat(field_set, fmt.lv3))
end
else
table.insert(output_text, fmt.lv1 .. field)
end
end
table.insert(output_text, (system == "BS" and fmt.BS_note or "") .. fmt.closing)
end
fold = '\n* <div title="expand" class="mw-customtoggle-oc' .. rand .. '"> ' ..
']<span style="float:right; border:1px solid #ccc; border-radius:1px;' ..
' padding:0 0; font-size:90%">▼</span>' .. preview .. '</div>'
end
return output_text and fold .. mw.ustring.gsub(table.concat(output_text), "%%]", "") or ""
end
function export.retrieve_pron(text, reconstruction, no_intro, index)
if type(text) == "table" then text = text.args end
text = require("Modül:bağlantılar").kaldir_baglantilari(text)
local retrieve_result = {}
local intro = no_intro and "" or "<span style=\"border-bottom: 1px dotted #000; cursor:help\" title=\"Eski Çince\">EÇ</span> "
if not reconstruction then
if index and index ~= "y" then
index_set = mw.text.split(index, ",")
end
for char_index, cp in ipairs { mw.ustring.codepoint(text, 1, -1) } do
local char_pronunciation = {}
local ch = mw.ustring.char(cp)
local data_module = get_data("ZS", ch)
if data_module then
local reading_no = index_set and index_set or "y"
if reading_no ~= "y" then
for number in mw.text.gsplit(reading_no, "+") do
table.insert(char_pronunciation, data_module)
end
else
for _, reading in ipairs(data_module) do
table.insert(char_pronunciation, reading)
end
end
else
return nil
end
table.insert(retrieve_result, table.concat(char_pronunciation, mw.ustring.len(text) == 1 and ", *" or "/"))
end
end
return intro .. (reconstruction or "*" .. table.concat(retrieve_result, " "))
end
function export.generate_show(text, index)
local index_set = mw.text.split(index, ";")
local extract_results = { = {}, = {} }
local result = {}
local position = { = 3, = 6 }
local fmt = {
beginning = {
= "\n*: <small>('']–]'')</small>: " ..
'<span style="font-size:95%">',
= "\n*: <small>('']'')</small>: " ..
'<span style="font-size:95%">',
},
ending = {
= "</span>", = "</span>"
}
}
for system_seq, system in ipairs({ "BS", "ZS" }) do
for i, cp in ipairs { mw.ustring.codepoint(text, 1, -1) } do
local char_pronunciation = {}
local ch = mw.ustring.char(cp)
local data_module = get_data(system, ch)
if data_module then
local existing_pron = {}
reading_number = index_set and (mw.text.split(index_set, ',') or index_set) or "y"
if reading_number == "y" then
index = 0
for _, reading in ipairs(data_module) do
index = index + 1
local reading_temp = reading]
if not existing_pron then
table.insert(char_pronunciation, insert_pron(reading_temp, text, system, i, false, index))
existing_pron = true
end
end
elseif reading_number == "n" then
break
else
index = 0
for indiv_number in mw.text.gsplit(reading_number, '\+') do
index = index + 1
local reading_temp = data_module]
if not existing_pron then
table.insert(char_pronunciation, insert_pron(reading_temp, text, system, i, false, index))
existing_pron = true
end
end
end
table.insert(extract_results, table.concat(char_pronunciation, mw.ustring.len(text) == 1 and ", " or "|"))
else
extract_results = {}
break
end
end
if extract_results then
table.insert(result, fmt.beginning ..
'<span class="IPAchar">' ..
table.concat(extract_results, " ") ..
'</span>' ..
fmt.ending)
end
end
text = result and mw.ustring.gsub(table.concat(result), "|%*", "|") or nil
text = text and mw.ustring.gsub(text, "/|", "|") or nil
text = text and mw.ustring.gsub(text, "|", '<span style="padding-left:2px; padding-right:2px">|</span>')
return text
end
function export.link(frame, arg)
local args = arg or frame:getParent().args
text, meaning, lit = args, args or args or nil, args or nil
local m_zh = require("Modül:zh")
return m_zh.link(frame, nil, { "*" .. text, tr = export.retrieve_pron(text, args or false, args or false, args or false), gloss = meaning, lit = lit }, mw.title.getCurrentTitle().subpageText)
end
return export