Khác biệt giữa bản sửa đổi của “Mô đun:Labelled list hatnote”
Không có tóm lược sửa đổi Thẻ: Đã bị lùi lại |
Thẻ: Lùi tất cả Đã bị lùi lại |
||
| Dòng 7: | Dòng 7: | ||
-------------------------------------------------------------------------------- | -------------------------------------------------------------------------------- | ||
local mHatnote = require(' | local mHatnote = require('Mô đun:Hatnote') | ||
local mHatlist = require(' | local mHatlist = require('Mô đun:Hatnote list') | ||
local mArguments --initialize lazily | local mArguments --initialize lazily | ||
local p = {} | local p = {} | ||
| Dòng 14: | Dòng 14: | ||
-- Defaults global to this module | -- Defaults global to this module | ||
local defaults = { | local defaults = { | ||
label = ' | label = 'Xem thêm', --Final fallback for label argument | ||
labelForm = '%s %s', | labelForm = '%s: %s', | ||
prefixes = {'label', 'label ', 'l'}, | prefixes = {'label', 'label ', 'nhãn', 'nhãn ', 'l'}, | ||
template = ' | template = 'Mô đun:Labelled list hatnote' | ||
} | } | ||
| Dòng 45: | Dòng 45: | ||
-- The main frame (template definition) takes 1 or 2 arguments, for a singular | -- The main frame (template definition) takes 1 or 2 arguments, for a singular | ||
-- and (optionally) plural label respectively: | -- and (optionally) plural label respectively: | ||
-- * {{# | -- * {{#gọi:Labelled list hatnote|labelledList|Singular label|Plural label}} | ||
-- The resulting template takes pagename & label parameters normally. | -- The resulting template takes pagename & label parameters normally. | ||
function p.labelledList (frame) | function p.labelledList (frame) | ||
mArguments = require(' | mArguments = require('Mô đun:Arguments') | ||
local labels = {frame.args[1] or defaults.label} | local labels = {frame.args[1] or defaults.label} | ||
labels[2] = frame.args[2] or labels[1] | labels[2] = frame.args[2] or labels[1] | ||
| Dòng 58: | Dòng 58: | ||
category = args.category, | category = args.category, | ||
selfref = frame.args.selfref or args.selfref, | selfref = frame.args.selfref or args.selfref, | ||
template = template | template = template | ||
} | } | ||
return p._labelledList(pages, labels, options) | return p._labelledList(pages, labels, options) | ||
end | end | ||
| Dòng 71: | Dòng 67: | ||
if #pages == 0 then | if #pages == 0 then | ||
return mHatnote.makeWikitextError( | return mHatnote.makeWikitextError( | ||
' | 'không có tên trang được chỉ định', | ||
(options.template or defaults.template) .. '# | (options.template or defaults.template) .. '#Các lỗi', | ||
options.category | options.category | ||
) | ) | ||
end | end | ||
label = (#pages == 1 and labels[1] or labels[2]) or defaults.label | label = (#pages == 1 and labels[1] or labels[2]) or defaults.label | ||
local text = string.format( | |||
options.labelForm or defaults.labelForm, | |||
label, | |||
mHatlist.andList(pages, true) | |||
) | |||
local hnOptions = { | local hnOptions = { | ||
extraclasses = options.extraclasses, | extraclasses = options.extraclasses, | ||