| Module:usex Jul 11th 2013, 00:53, by DTLHS | | | | Line 1: | Line 1: | | − | local wikilinks = require(wikilinks) | + | local wikilinks = require("wikilinks") | | | | | | | | local export = {} | | local export = {} |
- This module needs documentation and categorisation. Please create the documentation page.
local wikilinks = require("wikilinks") local export = {} local translit_data = mw.loadData("Module:translations/data") local has_auto_translit = translit_data[1] local needs_translit = translit_data[2] local languages = mw.loadData("Module:languages") function export.display(frame) local args = frame:getParent().args local categories = {} local noenum = args["noenum"] or false local indent = tonumber(args["indent"]) or 0 local inline = args["inline"] or false local usex = args[1] or "" local transliteration = args["tr"] or args["transliteration"] or "" local translation = args["t"] or args["translation"] or "" local lang = args["lang"] or "und" local sc = args["sc"] or "" local ref = args["ref"] or "" local langinfo = languages[lang] or error("The language code \"" .. lang .. "\" is not valid.") if transliteration == "" and has_auto_translit[lang] then local translit_module = require("Module:" .. lang .. "-translit") transliteration = translit_module.tr(wikilinks.rl(usex)) end if transliteration == "" and needs_translit[lang] then table.insert(categories, langinfo.names[1] .. " translations lacking transliteration") end if indent < -1 then error("invalid indent") end if usex == "" then error("please add a usage example") end local result = "" if noenum == true or noenum == "1" then indent = -1 result = "\n: " .. result end local usex_expanded = frame:expandTemplate{ title = "lang", args = {lang, usex, sc = sc }} if inline == true or inline == "1" then result = result .. usex_expanded .. ref if translation ~= "" then result = result .. " — " .. translation end return result end result = result .. usex_expanded .. ref if transliteration ~= "" then result = result .. "\n" .. string.rep("#", indent + 1) .. ":: " .. transliteration end if translation ~= "" then result = result .. "\n" .. string.rep("#", indent + 1) .. ":: " .. translation end for key, cat in ipairs(categories) do result = result .. "\n[[Category:" .. cat .. "]]" end return result end return export |