Difference between revisions 18626522 and 18626523 on frwiktionary

local languages = mw.loadData("Module:languages")
local export = {}
 
-- Create a tagged text from a given text. This is equivalent of the script templates.
function export.tag_text(text, lang, tag, class)
    return "<" .. (tag or "span") .. (class and (" class=\"" .. class .. "\"") or "")
(contracted; show full) 
function export.annotate(text, lang, tag, class, class_tr, translit, gloss, lit, gender, frame)
    text = export.tag_text(text, lang, tag, class)
 
    local annotations = {}
 
    if translit then

        translit = translit:gsub('%[%[', ''):gsub('%]%]', '') -- remove wikilinks
        table.insert(annotations, "<span lang=\"\"" .. (class_tr and (" class=\"" .. class_tr .. "\"") or "") .. ">" .. translit .. "</span>")
    end
 
    if gloss then
        table.insert(annotations, "<span class=\"mention-gloss-double-quote\">“</span><span class='mention-gloss'>" .. gloss .. "</span><span class=\"mention-gloss-double-quote\">”</span>")
    end
 
    if lit then
        table.insert(annotations, "literally <span class=\"mention-gloss-double-quote\">“</span><span class='mention-gloss'>" .. lit .. "</span><span class=\"mention-gloss-double-quote\">”</span>")
    end
 
    if #annotations > 0 then
        text = text .. "&nbsp;(" .. table.concat(annotations, ", ") .. ")"
    end
 
    if gender then
        if gender[2] or gender[3] then
            -- {{#if:{{{g|{{{g1|}}}}}}|&nbsp;{{{{{g|{{{g1|}}}}}}|{{{g2|}}}|{{{g3|}}}}}}}
            text = text .. "&nbsp;" .. frame:expandTemplate{title = gender[1], args = {gender[2], gender[3]}}
        elseif gender[1] then
            local gen = require("Module:gender and number")
            text = text .. "&nbsp;" .. gen.format_list(gender)
        end
    end
 
    return text
end
 
return export