Module:Dict: Difference between revisions
Jump to navigation
Jump to search
mNo edit summary |
mNo edit summary |
||
Line 1: | Line 1: | ||
local exports = {} | local exports = {} | ||
local def = require("Module:Utils").def | |||
local langdata = require('Module:Data/Langs') | local langdata = require('Module:Data/Langs') | ||
local posdata = require('Module:Data/POS') | local posdata = require('Module:Data/POS') | ||
Line 13: | Line 13: | ||
local sc = frame.args["sc"] | local sc = frame.args["sc"] | ||
local ipa = frame.args["ipa"] | local ipa = frame.args["ipa"] | ||
ipa = frame:expandTemplate{ title = "IPA", args = {"/" .. ipa .. "/" }} | ipa = frame:expandTemplate{ title = "IPA", args = {"/" .. ipa .. "/" }} | ||
if ( | if def(translit, "") == "" then | ||
translit = "" | translit = "" | ||
else | else | ||
Line 37: | Line 34: | ||
exports.ex = function(frame) | exports.ex = function(frame) | ||
local lang = frame.args.lang | local lang = frame.args.lang | ||
local sc = frame.args.sc | local sc = def(frame.args.sc, langdata._getScript(lang)) | ||
local s = frame.args.s | local s = frame.args.s | ||
local ss = frame.args.ss | local ss = def(frame.args.ss, s) | ||
local t = frame.args.t | local t = frame.args.t | ||
local dictfloat = scriptdata._getDictfloat(sc) | local dictfloat = scriptdata._getDictfloat(sc) | ||
local body | local body |
Revision as of 09:04, 15 April 2025
local exports = {}
local def = require("Module:Utils").def
local langdata = require('Module:Data/Langs')
local posdata = require('Module:Data/POS')
local scriptdata = require("Module:Data/Scripts")
exports.head = function(frame)
local headword = frame.args[1]
local lang = frame.args["lang"]
local pos = frame.args["pos"]
local translit = frame.args["translit"]
local ss = frame.args["ss"]
local sc = frame.args["sc"]
local ipa = frame.args["ipa"]
ipa = frame:expandTemplate{ title = "IPA", args = {"/" .. ipa .. "/" }}
if def(translit, "") == "" then
translit = ""
else
translit = " (" .. translit .. ")"
end
local head
if sc and sc ~= "" then
head = ss ~= "" and ss or headword
head = frame:expandTemplate{ title = 'Scr', args = { sc, head, float = scriptdata._getDictfloat(sc), addclass="dict" }}
translit = scriptdata._getDictfloat(sc) == "" and " (" .. headword .. ")" or headword
else
head = "'''" .. headword .. "'''"
end
return head .. translit .. " " .. ipa .. " ''" .. pos .. ".''\n"
.. "[[Category:" .. langdata._getDisplayName(lang) .. " " .. tostring(posdata._get(pos)) .. "]]\n"
.. "[[Category:" .. tostring(langdata._getDisplayName(lang)) .. " Lemmas]]"
end
exports.ex = function(frame)
local lang = frame.args.lang
local sc = def(frame.args.sc, langdata._getScript(lang))
local s = frame.args.s
local ss = def(frame.args.ss, s)
local t = frame.args.t
local dictfloat = scriptdata._getDictfloat(sc)
local body
if dictfloat ~= "" then
body = frame:expandTemplate{title = 'Scr', args = { sc, ss, float = dictfloat, addclass="dict" }}
.. [[<table>]]
elseif sc ~= "" then
body = [[<table><tr><td>]] .. frame:expandTemplate{title = 'Scr', args = { sc, ss, float = "", addclass="dict" }} .. [[</td></tr>]]
else
body = [[<table>]]
end
body = body .. [[<tr><td>]] .. s .. [[</tr></td>]]
.. [[<tr><td>]] .. t .. [[</tr></td>]]
.. [[</table>]]
return frame:extensionTag("spoiler", body, {show="Example ▼", hide="Example ▲"})
end
return exports