Module:IPA/overview: Difference between revisions

Content deleted Content added
fix aliases
simpler
 
(6 intermediate revisions by the same user not shown)
Line 4:
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 52 ⟶ 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
local aliases = {}
Line 63 ⟶ 59:
table.insert(aliases, alias)
end
addNotesaddNote(cells[1], {string.format(
'also <code>%s</code>',
string.format(
'alsotable.concat(aliases, '</code>%s, </code>',)
))
table.concat(aliases, '</code>, <code>')
)
})
end
do
Line 83 ⟶ 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 100 ⟶ 96:
note = note .. ', a different article'
end
table.insert(notes, note)
end
end
Line 106 ⟶ 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(
Line 128 ⟶ 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(noteskeys, noteasciiKey)
end
table.insert(byKey[keyasciiKey], {
code = lect.code,
name = lect.name or lect.extName,
Line 140 ⟶ 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 173 ⟶ 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 197 ⟶ 200:
return tostring(t)
end
 
 
return p