FANDOM


-- used within [[Template:Language list]] - see docs there for usage info
-- <nowiki>
local exports = {}
 
function exports.makeLanguageList(frame)
    local templateArgs = frame:getParent().args
    local listNode = mw.html.create('ul'):addClass('language-list')
    local link = templateArgs.link
 
    -- style as plain list - ideally, styling would be done in MediaWiki:Common.css
    listNode:css('list-style', 'none')
 
    -- add collapsible classes if requested
    if templateArgs.collapse == 'yes' then
        listNode:addClass('mw-collapsible'):addClass('mw-collapsed')
    end
 
    for index, value in ipairs(templateArgs) do
        value = mw.text.trim(value)
        local listItemNode = listNode:tag('li')
        local languageName = mw.language.fetchLanguageName(value)
        local text = (languageName ~= '' and languageName) or value
 
        -- use either a specific or generic link
        -- if generic, substitute $1 for the current language code
        if  templateArgs[value] then
            text = '[[' .. templateArgs[value] .. '|' .. text .. ']]'
        elseif link then
            text = '[[' .. mw.ustring.gsub(link, '$1', value) .. '|' .. text .. ']]'
        end
 
        listItemNode:wikitext(text)
 
        -- for recognised languages, append the language code in brackets and add category
        if languageName ~= '' then
            listItemNode:tag('span')
                :css('font-size', '0.8em')
                :wikitext(' (' .. value .. ')')
            if templateArgs.addcategory ~= 'no' then
                listItemNode:wikitext('[[Category:Translated scripts/' .. languageName .. ']]')
            end
        end
    end
 
    return tostring(listNode)
end
 
return exports

Ad blocker interference detected!


Wikia is a free-to-use site that makes money from advertising. We have a modified experience for viewers using ad blockers

Wikia is not accessible if you’ve made further modifications. Remove the custom ad blocker rule(s) and the page will load as expected.