Module:GetVerseTranslations: Difference between revisions
From Bodhicitta
((by SublimeText.Mediawiker)) |
((by SublimeText.Mediawiker)) |
||
| Line 64: | Line 64: | ||
end | end | ||
outputVerseTrans = outputVerseTrans .. '</div><div class=" | outputVerseTrans = outputVerseTrans .. '</div><div class="row py-2 pb-4">' | ||
for id, transData in pairs(transTbl) do | for id, transData in pairs(transTbl) do | ||
| Line 85: | Line 85: | ||
title = 'VersionContent', | title = 'VersionContent', | ||
args = { | args = { | ||
class = '' , | |||
content = transData.english , | content = transData.english , | ||
source = transData.source, | source = transData.source, | ||
| Line 96: | Line 97: | ||
end | end | ||
outputVerseTrans = outputVerseTrans .. ' | outputVerseTrans = outputVerseTrans .. '</div>' | ||
end | end | ||
return outputVerseTrans | return outputVerseTrans | ||
Revision as of 18:24, 4 April 2025
Documentation for this module may be created at Module:GetVerseTranslations/doc
local p = {}
function p.main(frame)
local outputVerseTrans = ''
local pargs = frame:getParent().args
local verse = ''
if pargs.verse then
verse = pargs.verse
else
verse = mw.title.getCurrentTitle().subpageText
end
local TransVersesData = mw.smw.ask( '[[Category:Translation Memories]][[SegmentFormat::Root]][[RootTextVerseNumPadmaK::' .. verse .. ']]|?#-=page|?TransMemID|?RootTextChapVerseNum|?TranslationWikiPage#|?ShortTitle|?TranslationCitation|?English|?SegmentOrder|sort=TransMemID,SegmentOrder|order=asc,asc|limit=10000' )
if TransVersesData and #TransVersesData then
local transTbl = {}
local pages = ''
local englishContent = ''
local tmid = ''
for num, trVerseData in ipairs( TransVersesData ) do
tmid = trVerseData.TransMemID
if type(transTbl[tmid]) == 'table' then else
transTbl[tmid] = {}
end
if transTbl[tmid]['page'] then
pages = transTbl[tmid]['page'] .. ';' .. trVerseData.page
else
pages = trVerseData.page
end
if transTbl[tmid]['english'] then
englishContent = transTbl[tmid]['english'] .. '\n' .. trVerseData.English
else
englishContent = trVerseData.English
end
transTbl[tmid] = {
page = pages ,
shorttitle = trVerseData.ShortTitle ,
english = englishContent ,
source = trVerseData.TranslationWikiPage
}
end
outputVerseTrans = outputVerseTrans .. '<div class="visibility-controls py-2 pb-lg-3 d-flex flex-row flex-wrap justify-content-start">'
for id, transData in pairs(transTbl) do
outputVerseTrans = outputVerseTrans .. frame:expandTemplate{
title = 'SingleVisibilityToggle',
args = {
id = id .. '-translation' ,
label = transData.shorttitle ,
wikipage = transData.source
}
}
end
outputVerseTrans = outputVerseTrans .. '</div><div class="row py-2 pb-4">'
for id, transData in pairs(transTbl) do
local tmButton = frame:expandTemplate{
title = 'InternalLink',
args = {
wikipage = transData.page ,
label = 'TM <i class="fa-duotone fa-angle-right fa-sm"></i>'
}
}
tmButton = '<span class="tsdwiki-top-actions text-70 pl-4 font-style-normal">' .. tmButton .. '</span>'
local order = ''
if id == '001-Tsadra-BCA-Root-Padmakara' or id == '005-Tsadra-BCA-Root-Dunhuang' then
order = 'order-first'
end
outputVerseTrans = outputVerseTrans .. frame:expandTemplate{
title = 'VersionContent',
args = {
class = '' ,
content = transData.english ,
source = transData.source,
tmButton = tmButton,
id = id .. '-translation',
shorttitle = transData.shorttitle,
order = order
}
}
end
outputVerseTrans = outputVerseTrans .. '</div>'
end
return outputVerseTrans
end
return p