Module:usex: Difference between revisions

17 bytes removed ,  11 January 2025
no edit summary
No edit summary
No edit summary
 
Line 1: Line 1:
local export = {}
local export = {}


local debug_track_module = "Module:debug/track"
local links_module = "Module:links"
local links_module = "Module:links"
local scripts_module = "Module:scripts"
local scripts_module = "Module:scripts"
Line 48: Line 47:
footer = 'e-footer'
footer = 'e-footer'
}
}
-- helper functions
local function track(page)
require(debug_track_module)("usex/" .. page)
return true
end




Line 111: Line 102:
function export.apply_subst(usex, subst, track)
function export.apply_subst(usex, subst, track)
local subbed_usex = require(links_module).remove_links(usex)
local subbed_usex = require(links_module).remove_links(usex)
local function do_track(page)
if track then
track(page)
end
return true
end


if subst then
if subst then
-- [[Special:WhatLinksHere/Wiktionary:Tracking/usex/subst]]
do_track("subst")
subst = rsplit(subst, ",")
subst = rsplit(subst, ",")
for _, subpair in ipairs(subst) do
for _, subpair in ipairs(subst) do
-- [[Special:WhatLinksHere/Wiktionary:Tracking/usex/subst-single-slash]]
-- [[Special:WhatLinksHere/Wiktionary:Tracking/usex/subst-single-slash]]
local subsplit = rsplit(subpair, rfind(subpair, "//") and "//" or do_track("subst-single-slash") and "/")
local subsplit = rsplit(subpair, rfind(subpair, "//") and "//" or "/")
subbed_usex = rsub(subbed_usex, subsplit[1], subsplit[2])
subbed_usex = rsub(subbed_usex, subsplit[1], subsplit[2])
end
end
Line 172: Line 155:
local usex = data.usex
local usex = data.usex
local sc = data.sc
local sc = data.sc
local sc_explicit = sc
local tr = data.tr
local tr = data.tr
local ts = data.ts
local ts = data.ts
Line 253: Line 237:
face = nil
face = nil
else
else
face = "usex"
face = "term"
end
end
Line 288: Line 272:
else
else
if tr then
if tr then
table.insert(categories, ("Requests for native script in %s %ss"):format(lang:getCanonicalName(),
table.insert(categories, ("Requests for %s in %s %ss"):format(
example_type))
sc_explicit and sc_explicit:getDisplayForm() or "native script",
lang:getCanonicalName(), example_type))
end
end
Line 314: Line 299:


if ref and ref ~= "" then
if ref and ref ~= "" then
track("ref")
table.insert(result, ref)
table.insert(result, ref)
end
end
Line 324: Line 308:
norm = norm
norm = norm
}
}
end
local function format_audio(audio)
if audio then
return " [[File:" .. audio .. "|25px]]"
else
return ""
end
end
end


Line 363: Line 356:
* `ref`: Reference text to display directly after the right qualifiers. (FIXME: Instead, this should be actual
* `ref`: Reference text to display directly after the right qualifiers. (FIXME: Instead, this should be actual
         references.)
         references.)
* `audio`: Name of the audio file containing the usex in spoken form.
* `orig`: Original text, if the primary text of the usex or quotation is a translation.
* `orig`: Original text, if the primary text of the usex or quotation is a translation.
* `origlang`: The language object of the original text. Mandatory if original text given. May be an etymology language.
* `origlang`: The language object of the original text. Mandatory if original text given. May be an etymology language.
Line 401: Line 395:
local quote = data.quote
local quote = data.quote
local lit = data.lit
local lit = data.lit
local audio = data.audio
local source = data.source
local source = data.source
local brackets = data.brackets
local brackets = data.brackets
Line 510: Line 505:


ins(usex_obj.usex)
ins(usex_obj.usex)
ins(format_audio(audio))


local function insert_annotations(obj)
local function insert_annotations(obj)
Line 565: Line 562:


ins(usex_obj.usex)
ins(usex_obj.usex)
ins(format_audio(audio))
local any_usex_annotations = usex_obj.tr or usex_obj.ts or usex_obj.norm or translation or lit
local any_usex_annotations = usex_obj.tr or usex_obj.ts or usex_obj.norm or translation or lit
local any_orig_annotations = orig_obj and (orig_obj.tr or orig_obj.ts or orig_obj.norm)
local any_orig_annotations = orig_obj and (orig_obj.tr or orig_obj.ts or orig_obj.norm)