Anonymous

Module:Nomenclature: Difference between revisions

From Zelda Wiki, the Zelda encyclopedia
fix bug for merging name and meaning columns when the name is the same as in English
(Moved code pertaining to Translations pages to Module:Translation, for better separation of concerns. This module is now for Template:Nomenclature and its predecessor Template:Names)
(fix bug for merging name and meaning columns when the name is the same as in English)
Line 124: Line 124:
:wikitext(langText)
:wikitext(langText)
:done()
:done()
local sameNameAsEnglish = h.PrintNames(tr, cargoData, row, displayGames)
local sameNameAsEnglish = row.translation == row.term
h.PrintNames(tr, cargoData, row, displayGames, {
-- name and meaning get merged into one column if the name is the same as the English name
-- See The Legend of Zelda: Tears of the Kingdom, for example
colspan = sameNameAsEnglish and 2 or nil,
})
h.MarkRowsToSkip(cargoData, row)
h.MarkRowsToSkip(cargoData, row)
if not skipMeanings and not sameNameAsEnglish then
if not skipMeanings and not sameNameAsEnglish then
Line 148: Line 142:
end
end


function h.PrintNames(tr, cargoData, row, displayGames, options)
function h.PrintNames(tr, cargoData, row, displayGames)
-- name and meaning get merged into one column if the name is the same as the English name
-- See The Legend of Zelda: Tears of the Kingdom, for example
local names, sameNameAsEnglish = h.GetNamesAndTheirGames(cargoData, row, displayGames)
local td = tr:tag('td')
local td = tr:tag('td')
:wikitext(table.concat(h.GetNamesAndTheirGames(cargoData, row, displayGames), '<br>'))
:wikitext(table.concat(names, '<br>'))
if options.colspan then
if sameNameAsEnglish then
td:attr("colspan", options.colspan)
td:attr("colspan", 2)
end
end
return sameNameAsEnglish
end
end


function h.GetNamesAndTheirGames(cargoData, row, displayGames)
function h.GetNamesAndTheirGames(cargoData, row, displayGames)
local ret = { h.GetOneNameAndGames(cargoData, row, displayGames) }
local sameNameAsEnglish = true
local nameAndGames, name = h.GetOneNameAndGames(cargoData, row, displayGames)
local ret = {nameAndGames}
if name ~= row.term then
sameNameAsEnglish = false
end
for _, row2 in ipairs(cargoData) do
for _, row2 in ipairs(cargoData) do
if h.SameLangDifTranslations(row, row2) then
if h.SameLangDifTranslations(row, row2) then
games = h.GamesWithSameTranslation(row2, cargoData)
games = h.GamesWithSameTranslation(row2, cargoData)
ret[#ret+1] = h.GetOneNameAndGames(cargoData, row2, displayGames)
local nameAndGames, name = h.GetOneNameAndGames(cargoData, row2, displayGames)
ret[#ret+1] = name
if name ~= row.term then
sameNameAsEnglish = false
end
end
end
end
end
return ret
return ret, sameNameAsEnglish
end
end


Line 180: Line 187:
end
end
end
end
return result
return result, row.translation
end
end