Modul:Detect singular: Unterschied zwischen den Versionen

K
52 Versionen von wpen:Module:Detect_singular importiert
(modify pluralize to accept "likely" parameter (for situations where plurality is likely, but not certain))
K (52 Versionen von wpen:Module:Detect_singular importiert)
 
(4 dazwischenliegende Versionen von einem anderen Benutzer werden nicht angezeigt)
Zeile 47: Zeile 47:
end
end
s = tostring(s)
s = tostring(s)
if plainFind(s,'forcedetectsingular') then -- magic data string to return true
s = mw.text.decode(s,true)  --- replace HTML entities (to avoid spurious semicolons)
if plainFind(s,'data-plural="0"') then -- magic data string to return true
return singular
return singular
end
end
if plainFind(s,'forcedetectplural') then -- magic data string to return false
if plainFind(s,'data-plural="1"') then -- magic data string to return false
return plural
return plural
end
end
Zeile 67: Zeile 68:
end
end
-- fix for trailing br tags passed through [[template:marriage]]
-- fix for trailing br tags passed through [[template:marriage]]
-- Frietjes fix: should we use it? comment out for now
s = mw.ustring.gsub(s, '<%s*br[^>]*>%s*(</div>)', '%1')
-- s = mw.ustring.gsub(s, '<%s*br[^>]*>%s*(</div>)', '%1')
-- replace all wikilinks with fixed string
-- replace all wikilinks with fixed string
if rewriteLinks then
if rewriteLinks then
Zeile 94: Zeile 94:
args = type(args) == 'table' and args or {}
args = type(args) == 'table' and args or {}
local singularForm = args[3] or args.singular or ""
local singularForm = args[3] or args.singular or ""
local pluralForm = args[4] or args.plural or args.likely or ""
local pluralForm = args[4] or args.plural or ""
local likelyForm = args.likely or pluralForm
local likelyForm = args.likely or pluralForm
local link = args[5] or args.link
local link = args[5] or args.link