Mô đun:Yesno

番版𠓨𣅶13:06、𣈜30𣎃12𢆥2015𧵑SaigonSarang (討論 | 㨂𢵰) (1 翻版)
() ←番版𫇰 | 番版㵋一 (恪) | 番版㵋→ (恪)

Documentation for this module may be created at Module:Mô đun:Yesno/doc

-- Function allowing for consistent treatment of boolean-like wikitext input.
-- It works similarly to the template {{Có hay không}}.
return function (val, default)
	val = type(val) == 'string' and mw.ustring.lower(val) or val
	if val == nil then
		return nil
	elseif val == true 
		or val == 'yes' or val == 'có'
		or val == 'y' or val == 'c'
		or val == 'true' or val == 'thực'
		or val == 't'
		or val == 'rồi'
		or tonumber(val) == 1
	then
		return true
	elseif val == false
		or val == 'no' or val == 'không'
		or val == 'n' or val == 'ko' or val == 'k'
		or val == 'false' or val == 'sai'
		or val == 'f' or val == 's'
		or val == 'chưa'
		or tonumber(val) == 0
	then
		return false
	else
		return default
	end
end