Модул:Yesno
Документация за този модул може да бъде създадена на Модул:Yesno/doc
-- Module:Yesno
-- Imported from en.wiktionary
-- 2016-06-11 -- V2 -- last modified by DenisWasRight
-- Extended version for bg.wiktionary
-- Function allowing for consistent treatment of boolean-like wikitext input.
-- It works similarly to the template {{yesno}}.
return function (val, default)
val = type(val) == 'string' and val:ulower() or val
if val == nil then
return nil
elseif val == true
or val == 'да'
or val == 'yes'
or val == 'y'
or val == 'true'
or tonumber(val) == 1
then
return true
elseif val == false
or val == 'не'
or val == 'no'
or val == 'n'
or val == 'false'
or tonumber(val) == 0
then
return false
else
return default
end
end