今天是2025年12月18日 第51周 星期四
代人,时大变了。
我们生活在大地上,但我们的梦想超越天空。
更改
跳到导航
跳到搜索
←上一编辑
模块: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
个编辑
导航菜单
个人工具
创建账户
登录
名字空间
模块
讨论
变种
视图
阅读
查看源代码
查看历史
更多
搜索
导航
首页
最近更改
随机页面
沙盒
互助客栈
QQ交流群
方针与指引
工具
上传文件
特殊页面
可打印版本