打开主菜单
首页
随机
登录
设置
关于Akarin
免责声明
Akarin
搜索
更改
←上一编辑
模块:Yesno
(查看源代码)
2023年12月24日 (日) 19:41的版本
添加288字节
、
2023年12月24日 (日) 19:41
小
导入1个版本
第1行:
第1行:
-- Function allowing for consistent treatment of boolean-like wikitext input.
-- Function allowing for consistent treatment of boolean-like wikitext input.
-- It works similarly to the template {{yesno}}.
-- It works similarly to the template {{yesno}}.
+
return function (val, default)
return function (val, default)
−
val = type(val) == 'string' and
mw.ustring.
lower(
val
) or val
-- put in lower case
+
-- If your wiki uses non-ascii characters for any of "yes", "no", etc., you
−
if val == nil then
+
-- should replace "val:lower()" with "mw.ustring.lower(val)" in the
−
return nil
+
-- following line.
−
elseif val ==
false
or val == '
no
' or val == '
n
' or val == '
false
' or tonumber(val) ==
0
then
+
val = type(val) == 'string' and
val:
lower() or val
−
return false
+
if val == nil then
−
elseif
val ==
true
or val == '
yes
' or val == '
y
' or val == '
true
' or tonumber(val) ==
1
then
+
return nil
−
return
true
+
elseif val ==
true
−
else
+
or val == 'yes'
−
return default
+
or val == 'y'
−
end
+
or val == 'true'
+
or val == 't'
+
or val == 'on'
+
or val == '
是
'
+
or val == '
开
'
+
or val == '
開
'
+
or tonumber(val) ==
1
+
then
+
return
true
+
elseif val == false
+
or val == 'no'
+
or val == 'n'
+
or val == '
false
'
+
or val == 'f'
+
or
val ==
'off'
+
or val == '
否
'
+
or val == '
关
'
+
or val == '
關
'
+
or tonumber(val) ==
0
+
then
+
return
false
+
else
+
return default
+
end
end
end
白龙
行政员
、
用户查核员
、importer、
界面管理员
、
结构式讨论监督员
、
管理员
1,511
个编辑