Module:usex: Difference between revisions

442 bytes removed ,  18 June 2023
no edit summary
No edit summary
Tag: Reverted
No edit summary
 
(7 intermediate revisions by the same user not shown)
Line 51: Line 51:


--[[
--[[
if namespace == "Reconstruction" or lang:hasType("reconstructed") then
if lang:getType() == "reconstructed" or namespace == "Reconstruction" then
error("Reconstructed languages and reconstructed terms cannot have usage examples, as we have no record of their use.")
error("Reconstructed languages and reconstructed terms cannot have usage examples, as we have no record of their use.")
end
end
Line 72: Line 72:


if not sc then
if not sc then
sc = lang:getScripts(usex)
sc = require("Module:scripts").findBestScript(usex, lang)
end
end


Line 92: Line 92:
end
end


transliteration = (lang:transliterate(subbed_usex, sc))
transliteration = lang:transliterate(subbed_usex, sc)
-- If the language doesn't have capitalization and is specified in [[Module:usex/data]], then capitalize any sentences.
if transliteration and mw.loadData("Module:usex/data").capitalize_sentences[lang:getCode()] then
transliteration = mw.ustring.gsub(transliteration, "%f[^%z%p%s](.)(.-[%.%?!‽])", function(m1, m2) return mw.ustring.upper(m1) .. m2 end)
end
end
end


Line 119: Line 114:
elseif lang:getCode() ~= "en" and lang:getCode() ~= "mul" and lang:getCode() ~= "und" then
elseif lang:getCode() ~= "en" and lang:getCode() ~= "mul" and lang:getCode() ~= "und" then
-- add trreq category if translation is unspecified and language is not english, translingual or undetermined
-- add trreq category if translation is unspecified and language is not english, translingual or undetermined
if quote then
table.insert(categories, "Requests for translations of " .. lang:getCanonicalName() .. " usage examples")
table.insert(categories, "Requests for translations of " .. lang:getCanonicalName() .. " quotations")
else
table.insert(categories, "Requests for translations of " .. lang:getCanonicalName() .. " usage examples")
end
translation = "<small>(please add an English translation of this " .. example_type .. ")</small>"
translation = "<small>(please add an English translation of this " .. example_type .. ")</small>"
end
end


if usex then
if usex then
usex = require("Module:links").embedded_language_links({term = usex, lang = lang, sc = sc}, false)
if usex:find("[[", 1, true) then
usex = require("Module:links").language_link({term = usex, lang = lang}, false)
end
local face
local face
Line 137: Line 130:
end
end
if not nocat and namespace == "" or namespace == "Contionary" then
if not nocat and (namespace == "" or namespace == "Reconstruction" or namespace == "Contionary") then
if quote then
if quote then
table.insert(categories, lang:getCanonicalName() .. " terms with quotations")
table.insert(categories, lang:getCanonicalName() .. " terms with quotations")
Line 266: Line 259:
class = class .. " " .. added_class
class = class .. " " .. added_class
end
end
result = (inline and span or div)(class, result)
result = div(class, result)
result = result .. require("Module:utilities").format_categories(categories, lang, sortkey)
result = result .. require("Module:utilities").format_categories(categories, lang, sortkey)
if noenum then
if noenum then