開啟主選單
首頁
隨機
登入
設定
關於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
次編輯