Module:IPA/overview: Difference between revisions

Content deleted Content added
mNo edit summary
simpler
 
(8 intermediate revisions by the same user not shown)
Line 2:
local p = {}
 
local data = mw.title.getCurrentTitle().subpageText == 'sandbox'
and mw.loadData('Module:IPA/data/sandbox')
or mw.loadData('Module:IPA/data')
local lects = mw.loadData('Module:IPA/data/export')
 
local function addNotesaddNote(cell, notesnote)
cell:wikitext(string.format(' <small>(%s)</small>', table.concat(notes, '; 'note))
if #notes > 0 then
cell:wikitext(
string.format(' <small>(%s)</small>', table.concat(notes, '; '))
)
end
end
 
Line 55 ⟶ 48:
table.insert(cells, row:tag('td'))
end
if not lect.parent and (not (lects[i + 1] or notand lects[i + 1].diaCodeparent) then
for _ = 1, 4 do
row:tag('td'):css('background', '#ececec')
end
end
cells[1]:wikitext('<code>' .. (lect.diaCodecode:gsub('^[^-]+%-', or lect.code'') .. '</code>')
if lect.aliases then
addNotes(cells[1],local aliases = {}
for _, alias in ipairs(lect.aliases) do
string.format(
table.insert(notesaliases, notealias)
'also <code>%s</code>',
end
table.concat(lect.aliases, '</code>, <code>')
addNote(cells[1], string.format(
)
'also <code>%s</code>',
})
table.concat(lect.aliases, '</code>, <code>')
))
end
do
Line 82 ⟶ 77:
end
cells[2]:wikitext(lect.name or lect.extName)
addNotes(cells[2],if #notes) > 0 then
addNote(cells[2], table.concat(notes, '; '))
end
end
do
local notes = {}note
local intLink = lect.link or lect.generatedLink
if intLink then
if intLink == lect.extLink then
table.insert(notes,note = 'redundant')
elseif lect.extLink then
local note = string.format('overrides [[%s]]', lect.extLink)
local intTitle = mw.title.new(intLink)
intTitle = intTitle.redirectTarget or intTitle
Line 99 ⟶ 96:
note = note .. ', a different article'
end
table.insert(notes, note)
end
end
Line 105 ⟶ 101:
s = lect.generatedLink and '([[' .. s .. ']])' or '[[' .. s .. ']]'
cells[3]:wikitext(s)
if not byKey[key]note then
addNotes addNote(cells[3], notesnote)
end
end
cells[4]:wikitext(
lect.key and '[[' .. lect.key .. ']]' or
'([[' .. (lect.parent and lect.parent.key or data.defaultKey'Help:IPA') .. ']])'
)
end
Line 127 ⟶ 125:
local key = lect.key or lect.parent and lect.parent.key
if key then
local asciiKey = mw.ustring.gsub(mw.ustring.toNFD(key), '[^ -~]', '')
if not byKey[key] then
if not byKey[keyasciiKey] = {}then
table.insert(keys,byKey[asciiKey] = { name = key) }
table.insert(keys, asciiKey)
end
table.insert(byKey[keyasciiKey], {
code = lect.code,
name = lect.name or lect.extName,
Line 139 ⟶ 138:
end
table.sort(keys)
for _, keyasciiKey in ipairs(keys) do
local row = t:tag('tr')
local keyCellkeyLects = row:tag('td'):wikitext('byKey[[' .. key .. ']asciiKey]')
local keyCell = row:tag('td'):wikitext('[[' .. keyLects.name .. ']]')
local keyLects = byKey[key]
local lang
if #keyLects > 1 then
keyCell:attr('rowspan', #keyLects)
table.sort(keyLects, function (a, b) return a.name < b.name end)
local keyName = mw.ustring.gsub(keykeyLects.name, '^[^/]*/', '')
for _, lect in ipairs(keyLects) do
if lect.name == keyName then
Line 172 ⟶ 171:
end
lang = lang or keyLects[1]
local nameCellprev = row:tag('td'):wikitext({
string.format('[[%s|%s]]',name lang.link,= lang.name),
count = 1,
)
cell = row:tag('td'):wikitext(
local nameRowspan = 1
string.format('[[%s|%s]]', lectlang.link, lectlang.name)
)
})
row:tag('td'):wikitext('<code>' .. lang.code .. '</code>')
for i_, lect in ipairs(keyLects) do
if lect ~= lang then
local subRow = t:tag('tr')
local prev = i == 1 and lang or keyLects[i - 1]
if prev.name == lect.name then
nameRowspanprev.count = nameRowspanprev.count + 1
nameCellprev.cell:attr('rowspan', nameRowspanprev.count)
else
nameRowspanprev = 1{
name = lect.name,
nameCell = subRow:tag('td'):wikitext(
count = 1,
string.format('[[%s|%s]]', lect.link, lect.name)
nameCell cell = subRow:tag('td'):wikitext(
)
string.format('[[%s|%s]]', lect.link, lect.name)
)
)}
end
subRow:tag('td'):wikitext('<code>' .. lect.code .. '</code>')
Line 196 ⟶ 200:
return tostring(t)
end
 
 
return p