Changes

Jump to navigation Jump to search
1,973 bytes added ,  11:11, 14 April 2023
m
+language and translator
Line 1: Line 1:  
local sb = {} -- functions package for HPB Scrapbooks
 
local sb = {} -- functions package for HPB Scrapbooks
   −
function sb.item_id( frame )
+
function sb.item_id2( frame )
 
local id = frame.args['volume'] .. '-' .. frame.args['page'] .. '-' .. frame.args['item']
 
local id = frame.args['volume'] .. '-' .. frame.args['page'] .. '-' .. frame.args['item']
 
     return id
 
     return id
 
end
 
end
   −
function sb.item_id2( frame )
+
local function isempty(s)
local vNum = frame.args['volume']
+
  return s == nil or s == ''
local pNum = frame.args['page']
+
end
local iNum = frame.args['item']
+
 
+
-- Create unique ID for the item, which consist of: Volume-Page-Item_on_page
if tunumber(vNum) < 10 then
+
-- ID example: 01-017-03
vStr = 0 .. tovNum
+
-- Call example: {{#invoke: SB | item_id | volume=1 | page=17 | item=3 }}
 +
-- Values: volume=1..99, page=1..999, item=1..99
 +
function sb.item_id( frame )
 +
local vNum = string.format("%.2d", frame.args['volume'])
 +
local iNum = string.format("%.2d", frame.args['item'])
 +
local p_int, p_frac = math.modf(frame.args['page'])
 +
local pNum = string.format("%.3d", p_int) 
 +
 
 +
--mw.log('int= '.. p_int .. ', frac= ' .. p_frac)
 +
if p_frac > 0 then
 +
str = tostring(p_frac)
 +
pNum = pNum .. '.' .. string.sub(str,3,5)
 +
end
 +
 
 +
local id = vNum .. '-' .. pNum .. '-' .. iNum
 +
return id
 +
end
 +
 
 +
-- Create footnote with item summary and notes by editor and archivist
 +
-- View: TITLE by AUTHOR (signed as AUTHOR_SIGNED), SOURCE_TITLE, SOURCE_DETAILS.
 +
-- Translated from LANGUAGE by TRANSLATOR. NOTES. ARCHIVIST_NOTES.
 +
function sb.footnote( frame )
 +
local str = ''
 +
 
 +
if not isempty(frame.args['title']) then
 +
str = '<i>' .. frame.args['title'] .. '</i>'
 +
end
 +
 
 +
if not isempty(frame.args['author']) then
 +
str = str .. ' by ' .. frame.args['author']
 +
else
 +
if not isempty(frame.args['title']) then
 +
str = str .. ' by unknown author'
 +
else
 +
str = str .. frame.args['type'] .. ' by unknown author'
 +
end
 +
end
 +
 
 +
if not isempty(frame.args['author_signed']) then
 +
str = str .. ' (signed as ' .. frame.args['author_signed'] .. ')'
 +
end
 +
 
 +
if not isempty(frame.args['source_title']) then
 +
str = str .. ', <i>' .. frame.args['source_title'] .. '</i>'
 +
end
 +
 
 +
if not isempty(frame.args['source_details']) then
 +
str = str .. ', ' .. frame.args['source_details']
 +
end
 +
 
 +
if not isempty(frame.args['language']) then
 +
str = str .. '. Translated from ' .. frame.args['language']
 +
if not isempty(frame.args['translator']) then
 +
str = str .. ' by ' .. frame.args['translator']
 +
end
 +
end
 +
if not isempty(frame.args['notes']) then
 +
str = str .. '. ' .. frame.args['notes']
 
end
 
end
+
 
if tonumber(iNum) < 10 then
+
if not isempty(frame.args['archivist_notes']) then
iNum = 0 .. iNum
+
str = str .. '<br>' .. frame.args['archivist_notes'] .. '. – Archivist'
 
end
 
end
     −
--local id = vNum .. '-' .. pNum .. '-' .. iNum
+
return str
local id= string.format("{0:d4}", frame.args['volume'])
  −
    return id
   
end
 
end
    +
-- This function does not work yet
 +
function sb.int2roman( arabic_number )
 +
local roman_number = arabic_number --mathroman.int2roman(arabic_number)
 +
    print (roman_number)
 +
end
    
return sb
 
return sb

Navigation menu