Tài liệu mô đun[tạo]
-------------------------------------------------------------------------------
--              Configuration data for [[Module:Article history]]
-------------------------------------------------------------------------------

local lang = mw.language.getContentLanguage()
local Category = require('Module:Article history/Category')

-------------------------------------------------------------------------------
-- Helper functions
-------------------------------------------------------------------------------

-- Makes a link to a template page surrounded by double curly braces. A
-- workalike for the {{tl}} template.
local function makeTemplateLink(s)
	local openb = mw.text.nowiki('{{')
	local closeb = mw.text.nowiki('}}')
	return string.format('%s[[Template:%s|%s]]%s', openb, s, s, closeb)
end

-- Gets the Good Article topic for the given key. Uses
-- [[Module:Good article topics]].
local function getGoodArticleTopic(key)
	if not key then
		return nil
	end
	return require('Module:Good article topics')._main(key)
end

-- Returns the Good Article page link and display value for a given Good Article
-- key. If the key wasn't valid, the default Good Article page and display value
-- is returned instead.
local function getGoodArticleTopicLink(key)
	local topic = getGoodArticleTopic(key)
	local link, display
	if topic then
		link = 'Wikipedia:Bài viết tốt/' .. topic
		display = 'bài viết tốt bên chủ điểm ' .. topic
	else
		link = 'Wikipedia:Bài viết tốt'
		display = 'bài viết tốt'
	end
	return link, display
end

-- Wrapper function for mw.language:formatDate, going through pcall to catch
-- invalid input errors.
local function getDate(format, date)
	local success, result = pcall(lang.formatDate, lang, format, date)
	if success then
		return result
	end
end

-- Gets the date in the format YYYYMMDD, as a number. Months and dates are
-- zero-padded. Results from this function are intended to be used in date
-- calculations.
local function getYmdDate(date)
	date = getDate('Ymd', date)
	if date then
		return tonumber(date)
	else
		return nil
	end
end

-- Gets the date in the format Month d, YYYY.
local function getLongDate(date)
	return getDate('j F, Y', date)
end

-- Returns true if the given page is an existing title, and false or nil
-- otherwise
local function titleExists(page)
	local success, title = pcall(mw.title.new, page)
	return success and title.exists
end

-- Returns a truthy value if a date parameter for the given prefix has been
-- provided by the user.
local function isActiveDatedObject(articleHistoryObj, prefix)
	local args = articleHistoryObj.args
	local prefixArgs = articleHistoryObj.prefixArgs
	return args[prefix .. 'date'] or prefixArgs[prefix]
end

-- Returns a date as formatted by getLongDate. If the date is invalid, it raises
-- an error using param as the parameter name containing the invalid date.
local function validateDate(param, date, articleHistoryObj)
	local longDate = getLongDate(date)
	if longDate then
		return longDate
	else
		articleHistoryObj:raiseError(
			string.format(
				"invalid date '%s' detected in parameter '%s'",
				tostring(date),
				param
			),
			'Bản mẫu:Lịch sử bài viết#Invalid date'
		)
	end
end

-- Generates a data table for a date-related notice such as DYK and ITN. prefix
-- is the parameter prefix for that notice type (e.g. "dyk"), and suffixes is
-- an array of parameter suffixes in addition to "date" that is used by that
-- notice type (e.g. "entry" for the "dykentry" and "dyk2entry" parameters).
local function makeDateData(articleHistoryObj, prefix, suffixes)
	local args = articleHistoryObj.args
	local prefixArgs = articleHistoryObj.prefixArgs

	-- Sanity checks
	if prefixArgs[prefix] then
		for _, t in ipairs(prefixArgs[prefix]) do
			if not t.date then
				articleHistoryObj:raiseError(
					string.format(
						"an argument starting with '%s%d' was detected, " ..
							"but no '%s%ddate' parameter was specified",
						prefix, t[1],
						prefix, t[1]
					),
					'Bản mẫu:Lịch sử bài viết#No date parameter'
				)
			end
		end
	end

	local data = {}

	-- Organise the input
	local function addData(sep)
		local t = {}
		local argPrefix = prefix .. sep
		do
			local key = argPrefix .. 'date'
			t.date = validateDate(key, args[key], articleHistoryObj)
			t.month, t.day, t.year = t.date:match('(%a+) (%d+), (%d+)')
			t.day = tonumber(t.day)
			t.year = tonumber(t.year)
			t.ymdDate = getYmdDate(t.date)
		end
		for _, suffix in ipairs(suffixes) do
			local key = argPrefix .. suffix
			t[suffix] = args[key]
		end
		t.argPrefix = argPrefix
		data[#data + 1] = t
	end
	if args[prefix .. 'date'] then
		addData('')
	end
	if prefixArgs[prefix] then
		for _, prefixData in ipairs(prefixArgs[prefix]) do
			addData(tostring(prefixData[1]))
		end
	end
	if #data < 1 then
		error(string.format(
			"no data items found for prefix '%s' and parameter checks failed'",
			tostring(prefix)
		))
	end

	return data
end

-- This makes the text for Main Page features such as DYKs and ITNs for the
-- dates contained in dateData (made with the makeDateData function).
-- The parameter $1 in the blurb will be replaced with the list of dates.
local function makeDateText(dateData, blurb, wantBold)
	local bold = wantBold and "'''" or ""
	local dates, doneLinks = {}, {}
	for i, t in ipairs(dateData) do
		local date
		if t.link and not doneLinks[t.link] then
			date = string.format('[[%s|%s]]', t.link, t.date)
			doneLinks[t.link] = true
		else
			date = t.date
		end
		dates[i] = bold .. date .. bold
	end
	local dateList = mw.text.listToText(dates, ', ', ', and ')
	return mw.message.newRawMessage(blurb, dateList):plain()
end

return {

-------------------------------------------------------------------------------
--                             CONFIG TABLE START
-------------------------------------------------------------------------------

-------------------------------------------------------------------------------
-- Statuses
-- Configuration for possible current statuses of the article.
-------------------------------------------------------------------------------

-- The statuses table contain configuration tables for possible current statuses
-- of the article.
-- Each table can have the following fields:
--
-- id: the main ID for the status. This should be the same as the configuration
--    table key.
-- aliases: a table of ID aliases that can be used to access the config table.
-- icon: The status icon.
-- iconSize: The icon size, including "px" suffix. The default is defined in
--    defaultStatusIconSize.
-- iconSmallSize: The icon size if we are outputting a small template. The
--    default is defined in defaultSmallStatusIconSize.
-- iconMultiSize: The icon size if we are outputting multiple status rows. The
--    default is defaultSmallStatusIconSize.
-- text: The status text. This may be a string or a function. If it is a
--    function, it takes an article history object as input, and should return
--    the text string. If it is a string, it can have the following parameters:
--    $1 - The full page name of the article or subject page
--    $2 - The page name without the namespace name
-- categories: The categories set by the status. This may be an array of
--    category names, or a function. If it is a function, it takes an article
--    history object as the first parameter, and the current status object as
--    the second parameter, and should return an array of category objects.
-- noticeBarIcon: the icon to use for the notice bar. This can be a string, or
--    a function, or true. If it is a function it takes an article history
--    object as the first parameter, and should output the icon filename. If it
--    is true, it uses the value of icon. If it is nil then no notice bar icon
--    will be displayed.
-- noticeBarIconCaption: the caption to use for the notice bar icon. The status
--    name is used by default. This can be a string or a function. If it is a
--    function, it takes an article history object as its first parameter, and
--    should return the caption text. If this is absent, the icon caption is
--    used instead.
-- noticeBarIconSize: the size of the notice bar icon, including "px" suffix.
--    The default is set by defaultNoticeBarIconSize.

statuses = {
	FA = {
		id = 'FA',
		name = 'Bài viết chọn lọc',
		aliases = {'BVCL', 'CL'},
		icon = 'Symbol star gold.svg',
		text = function (articleHistoryObj)
			local articlePage = articleHistoryObj.currentTitle.subjectPageTitle.prefixedText
			local actions = articleHistoryObj:getActionObjects()
			local link
			for i = #actions, 1, -1 do
				local actionObj = actions[i]
				if actionObj.id == 'FAC' then
					link = actionObj.link
					break
				end
			end
			link = link or 'Wikipedia:Ứng cử viên bài viết chọn lọc/' .. articlePage
			local text = "'''%s''' là một [[Wikipedia:Bài viết chọn lọc|bài viết chọn lọc]] của Wikipedia tiếng Việt. " ..
				"Bài viết, hoặc một phiên bản trước đây, đã được cộng đồng '''''[[%s|bình chọn]]''''' " ..
				"là một trong những bài có chất lượng xuất sắc và tiêu biểu nhất của Wikipedia tiếng Việt. " ..
				"Nếu bạn có thể cập nhật hoặc nâng cao chất lượng của bài viết hơn nữa, [[Wikipedia:Hãy táo bạo|xin mời bạn!]]"
			return string.format(text, articlePage, link)
		end,
		-- categories = {'Bài viết chọn lọc'}
	},
	FFA = {
		id = 'FFA',
		name = 'Bài viết chọn lọc cũ',
		aliases = {'BVMSCL', 'BVBRSCL'},
		icon = 'Symbol star gold-stroked.svg',
		iconSize = '48px',
		text = "'''$1''' là một [[Wikipedia:Bài viết chọn lọc cũ|bài viết chọn lọc cũ]]. " ..
			"Xin vui lòng xem liên kết bên dưới mục Cột mốc của bài viết để đọc thêm trang đề cử gốc " ..
			"(đối với bài cũ hơn, kiểm tra [[Wikipedia:Ứng cử viên bài viết chọn lọc/Thành công|phần lưu trữ]]) " ..
			"và biết tại sao bài viết bị rút sao chọn lọc.",

			"and why it was removed.",
		categories = {'Bài viết mất sao chọn lọc'}
	},
	FFAC = {
		id = 'FFAC',
		name = 'Ứng cử viên bài viết chọn lọc không thành công',
		aliases = {'FACFAILED', 'UCVTB', 'UCVCLTB', 'UCVBVCLTB'},
		icon = 'Symbol unsupport star gold.svg',
		text = "'''$1''' đã từng là [[Wikipedia:Ứng cử viên bài viết chọn lọc|ứng cử viên bài viết chọn lọc]]. " ..
			"Xin mời xem liên kết phía dưới mục Cột mốc của bài viết để biết tại sao " ..
			"đề cử không thành công. Đối với ứng cử viên khác, vui lòng xem mục " ..
			"[[Wikipedia:Ứng cử viên bài viết chọn lọc/Không thành công|lưu trữ]].",
		categories = {'Ứng cử viên bài chọn lọc không thành công'}
	},
	FL = {
		id = 'FL',
		name = 'Danh sách chọn lọc',
		aliases = {'DSCL'},
		icon = 'Symbol star gold.svg',
		iconSize = '48px',
		text = function (articleHistoryObj)
			local articlePage = articleHistoryObj.currentTitle.subjectPageTitle.prefixedText
			local actions = articleHistoryObj:getActionObjects()
			local link
			for i = #actions, 1, -1 do
				local actionObj = actions[i]
				if actionObj.id == 'FLC' then
					link = actionObj.link
					break
				end
			end
			link = link or 'Wikipedia:Ứng cử viên danh sách chọn lọc/' .. articlePage
			local text = "'''%s''' là một [[Wikipedia:Danh sách chọn lọc|danh sách chọn lọc]], và " ..
				"đã được [[Wikipedia:Thành viên|cộng đồng Wikipedia tiếng Việt]] '''''[[%s|bình chọn]]''''' là một trong những " ..
				"[[Wikipedia:Danh sách|danh sách]] có chất lượng xuất sắc và tiêu biểu nhất của Wikipedia tiếng Việt. " ..
				"Nếu bạn có thể cập nhật hoặc nâng cao hơn nữa chất lượng của bài viết, [[Wikipedia:Hãy táo bạo|xin mời bạn!]]"
			return string.format(text, articlePage, link)
		end,
		categories = {'Danh sách chọn lọc'}
	},
	FFL = {
		id = 'FFL',
		name = 'Danh sách chọn lọc cũ',
		aliases = {'DSMSCL'},
		icon = 'Symbol star gold-stroked.svg',
		text = "'''$1''' là một [[Wikipedia:Danh sách chọn lọc cũ|danh sách chọn lọc cũ]]. " ..
			"Xin vui lòng xem liên kết bên dưới mục Cột mốc của bài viết để đọc thêm trang đề cử gốc " ..
			"và biết tại sao bài viết bị rút sao danh sách chọn lọc. Nếu bài viết được cải thiện để đáp ứng lại " ..
			"[[Wikipedia:Tiêu chuẩn danh sách chọn lọc|tiêu chuẩn danh sách chọn lọc]], bạn có thể " ..
			"[[Wikipedia:Ứng cử viên danh sách chọn lọc|tái đề cử]] bài viết " ..
			"trở lại [[Wikipedia:Featured list|danh sách chọn lọc]]."
	},
	FFLC = {
		id = 'FFLC',
		name = 'Ứng cử viên danh sách chọn lọc không thành công',
		aliases = {'UCDSCL-TB'},
		icon = 'Symbol unsupport star gold.svg',
		iconCaption = 'Former FLC',
		text = "'''$1''' đã từng là [[Wikipedia:Ứng cử viên danh sách chọn lọc|ứng cử viên danh sách chọn lọc]]. " ..
			"Xin mời xem liên kết phía dưới mục Cột mốc của bài viết để biết tại sao đề cử không thành công. " ..
			"Sau khi các phiếu phản đối được giải quyết hết, bạn có thể " ..
			"[[Wikipedia:Ứng cử viên danh sách chọn lọc|tái đề cử]] " ..
			"bài viết để đạt được chất lượng danh sách chọn lọc.",
		categories = {'Ứng cử viên danh sách chọn lọc thất bại'}
	},
	['FFA/GA'] = {
		id = 'FFA/GA',
		aliases = {'BVMSCL/BVT', 'BVBRSCL/BVT', 'giáng sao'},
		name = 'Bài viết chọn lọc cũ, hiện tại là bài viết tốt',
		isMulti = true,
		statuses = {'FFA', 'GA'}
	},
	['FFAC/GA'] = {
		id = 'FFAC/GA',
		aliases = {'UCVCLTB/BVT', 'UCVBVCLTB/BVT', 'UCVTB/BVT'},
		name = 'Ứng cử viên bài viết chọn lọc không thành công, hiện tại là bài viết tốt',
		isMulti = true,
		statuses = {'FFAC', 'GA'}
	},
	GA = {
		id = 'GA',
		name = 'Bài viết tốt',
		aliases = {'BVT', 'BVCLC', 'CLC'},
		icon = 'Symbol_star_2ca02c.svg',
		iconSize = '40px',
		iconMultiSize = '25px',
		text = function (articleHistoryObj)
			local link, display = getGoodArticleTopicLink(articleHistoryObj.args.topic)
			local articlePage = articleHistoryObj.currentTitle.subjectPageTitle.prefixedText
			local text = "'''%s''' là một '''''[[%s|%s]]''''' của Wikipedia tiếng Việt. " ..
			    "Bài viết, hoặc một phiên bản trước đây, đã được cộng đồng " ..
				"[[Wikipedia:Ứng cử viên bài viết tốt|bình chọn]] là bài chất lượng cao " ..
				"dựa trên [[Wikipedia:Tiêu chuẩn bài viết tốt|tiêu chuẩn bài viết tốt]]. " ..
				"Nếu bạn có thể cập nhật hoặc nâng cao hơn nữa, [[Wikipedia:Hãy táo bạo|xin mời bạn!]]"
			return string.format(text, articlePage, link, display)
		end,
	--	categories = function (articleHistoryObj)
	--		local ret = {}
	--		local title = articleHistoryObj.currentTitle
	--		if title.namespace == 1 then
			--	ret[#ret + 1] = Category.new('Bài viết chất lượng tốt')
			--	ret[#ret + 1] = Category.new('Wikipedia CD Selection-GAs')
	--			local topic = getGoodArticleTopic(articleHistoryObj.args.topic)
	--			if topic then
	--				ret[#ret + 1] = Category.new(
			--			'Bài viết tốt của chủ điểm ' .. topic,
		--				title.text
		--			)
		--		else
			--		ret[#ret + 1] = Category.new(
			--			'Bài viết tốt không có tham số chủ điểm',
			--			title.text
			--		)
		--		end
		--	end
		--	return ret
	--	end
	},
	FGAN = {
		id = 'FGAN',
		name = 'Ứng cử viên bài viết tốt không thành công',
		aliases = {'FAILEDGA', 'UCVBVTTB'},
		icon = 'Symbol unsupport star 2ca02c.svg',
		text = function (articleHistoryObj)
			local articlePage = articleHistoryObj.currentTitle.subjectPageTitle.prefixedText
			local link, display = getGoodArticleTopicLink(articleHistoryObj.args.topic)
			local text = "'''%s''' đã từng là ứng cử viên '''''[[%s|%s]]''''', " ..
				"nhưng không đáp ứng [[Wikipedia:Tiêu chuẩn bài viết tốt|tiêu chuẩn bài viết tốt]] " ..
				"ở thời điểm đó. Mời xem trang đề cử để biết cách cải thiện bài viết. " ..
				"Nếu như vấn đề đã được giải quyết, bạn có thể " ..
				"[[Wikipedia:Ứng cử viên bài viết tốt|tái đề cử]] bài viết."
			return string.format(text, articlePage, link, display)
		end,
		categories = {'Ứng cử viên bài tốt không thành công'}
	},
	DGA = {
		id = 'DGA',
		name = 'Bài viết tốt đã bị rút sao',
		aliases = {'DELISTEDGA', 'BVMSBVT'},
		icon = 'Symbol star green-2ca02c-stroked.svg',
		iconCaption = 'Bài viết tốt đã bị rút sao',
		text = function (articleHistoryObj)
			local articlePage = articleHistoryObj.currentTitle.subjectPageTitle.prefixedText
			local link, display = getGoodArticleTopicLink(articleHistoryObj.args.topic)
			local text = "'''%s''' đã từng là một '''''[[%s|%s]]''''', nhưng do thông tin " ..
				"trong bài đã lỗi thời hoặc tiêu chuẩn bài viết tốt đã nâng cao qua thời gian nên cộng đồng đã quyết định rút sao " ..
				"và gỡ nó khỏi danh sách. Nếu có thể, xin bạn hãy đọc những góp ý và giúp cải thiện bài viết nhằm đáp ứng " ..
				"[[Wikipedia:Tiêu chuẩn bài viết tốt|tiêu chuẩn của bài viết tốt]]. " ..
				"Sau khi những vấn đề đã được giải quyết, bạn có thể " ..
				"[[Wikipedia:Ứng cử viên bài viết tốt|tái đề cử]] bài viết."
			return string.format(text, articlePage, link, display)
		end,
		categories = {'Bài viết mất sao tốt'}
	},
	FFT = {
		id = 'FFT',
		name = 'Một phần của chủ điểm chọn lọc cũ',
		icon = 'Symbol star gold-stroked.svg',
		iconCaption = 'Chủ điểm chọn lọc cũ',
		text = "Bài viết này là một phần của " ..
			"''[[Wikipedia:Chủ điểm chọn lọc cũ|chủ điểm chọn lọc cũ]]''. " ..
			"Nếu như bài viết được cải thiện lại để đạt " ..
			"[[Wikipedia:Tiêu chuẩn chủ điểm chọn lọc|tiêu chuẩn chủ điểm chọn lọc]] " ..
			"thì bạn có thể [[Wikipedia:Ứng cử viên chủ điểm chọn lọc|đề cử lại]] " ..
			"chủ điểm để trở thành [[Wikipedia:Chủ điểm chọn lọc|Chủ điểm chọn lọc]]."
	},
	FFTC = {
		id = 'FFTC',
		name = 'Ứng cử viên cổng thông tin chọn lọc không thành công',
		icon = 'Symbol unsupport star gold.svg',
		text = "Bài viết này là một phần của " ..
			"[[Wikipedia:Ứng cử viên chủ điểm chọn lọc|ứng cử viên chủ điểm chọn lọc]] ''cũ''. " ..
			"Xin vui lòng xem liên kết bên dưới mục Cột mốc của bài viết để biết tại sao " ..
			"đề cử không thành công."
	},
	FPO = {
		id = 'FPO',
		name = 'Cổng thông tin chọn lọc',
		icon = 'Symbol_star_gold.svg',
		text = "'''Cổng thông tin $2''' là một [[Wikipedia:Cổng thông tin chọn lọc|cổng thông tin chọn lọc]], " ..
			"được cộng đồng Wikipedia tiếng Việt " ..
			"'''''[[Wikipedia:Ứng cử viên cổng thông tin chọn lọc/Cổng thông tin:$2|bình chọn]]''''' " ..
			"là một trong những cổng thông tin xuất sắc nhất trên [[Wikipedia tiếng Việt]]. " ..
			"Nếu bạn có thể cập nhật hoặc nâng cao hơn nữa chất lượng của cổng thông tin " ..
			"mà không làm xáo trộn công trình trước đó, xin cứ tự do đóng góp.",
		categories = function (articleHistoryObj)
			return {Category.new(
				'Cổng thông tin chọn lọc',
				articleHistoryObj.currentTitle.text
			)}
		end
	},
	FFPO = {
		id = 'FFPO',
		name = 'Cổng thông tin chọn lọc cũ',
		icon = 'Symbol star gold-stroked.svg',
		text = "Cổng thông tin này là một [[Wikipedia:Cổng thông tin chọn lọc cũ|cổng thông tin chọn lọc cũ]]. " ..
			"Xin vui lòng xem liên kết bên dưới Cột mốc của cổng thông tin để đọc " ..
			"trang đề cử cũ và biết tại sao nó bị rút sao.",
		categories = function (articleHistoryObj)
			return {Category.new(
				'Cổng thông tin chọn lọc cũ',
				articleHistoryObj.currentTitle.text
			)}
		end
	},
	FFPOC = {
		id = 'FFPOC',
		name = 'Ứng cử viên cổng thông tin chọn lọc không thành công',
		icon = 'Symbol unsupport star gold.svg',
		text = "Cổng thông tin này đã '''''từng là một''''' " ..
			"[[Wikipedia:Ứng cử viên cổng thông tin chọn lọc|ứng cử viên cổng thông tin chọn lọc]]. " ..
			"Xin vui lòng xem liên kết bên dưới Cột mốc của cổng thông tin để đọc " ..
			"trang đề cử cũ và biết tại sao đề cử không thành công.",
		categories = function (articleHistoryObj)
			return {Category.new(
				'Wikipedia featured portal candidates (contested)',
				articleHistoryObj.currentTitle.text
			)}
		end
	},
	PR = {
		-- Peer review is a valid current status, but it doesn't trigger a
		-- header row.
		id = 'PR',
		name = 'Đã bình duyệt',
		aliases = {'bình duyệt'},
		noticeBarIcon = 'Nuvola apps kedit.svg'
	},
	NA = {
		-- A valid current status, but doesn't trigger a header row.
		id = 'NA',
		noticeBarIcon = 'Nuvola apps kedit.svg'
	},
	-- The following are invalid statuses.
	FAC = {
		id = 'FAC',
		text = function (articleHistoryObj)
			articleHistoryObj:raiseError(
				string.format(
					'use the template %s to nominate an article for Featured article status',
					makeTemplateLink('fac')
				),
				'Bản mẫu:Lịch sử bài viết#Featured article candidates'
			)
		end
	},
	FAR = {
		id = 'FAR',
		text = function (articleHistoryObj)
			articleHistoryObj:raiseError(
				string.format(
					'use the template %s to nominate an article for Featured article review',
					makeTemplateLink('FAR')
				),
				'Bản mẫu:Lịch sử bài viết#Featured article review'
			)
		end
	},
	STUB = {
		id = 'STUB',
		aliases = {'START', 'B', 'A', 'sơ khai', 'sơ khởi', 'C'},
		text = function (articleHistoryObj)
			local currentStatusParam = articleHistoryObj.cfg.currentStatusParam
			articleHistoryObj:raiseError(
				string.format(
					"do not use '%s' as value of the '%s' parameter; these " ..
						'assessments are the responsibility of individual ' ..
						'WikiProjects',
					articleHistoryObj.args[currentStatusParam],
					currentStatusParam
				),
				'Bản mẫu:Lịch sử bài viết#WikiProject assessments'
			)
		end
	},
},

-- This function allows the generation of custom status ID. It takes an
-- articleHistory object as the first parameter, and should output the status
-- ID.
getStatusIdFunction = function (articleHistoryObj)
	-- Get the status ID. The status code is the code passed in from the
	-- arguments, and the ID is the value contained in the config.
	local statusCode = articleHistoryObj.args[articleHistoryObj.cfg.currentStatusParam]
	local statusId = articleHistoryObj:getStatusIdForCode(statusCode)

	-- Check for former featured articles.
	if statusId ~= 'FA'
		and statusId ~= 'FL'
		and statusId ~= 'FFA'
		and statusId ~= 'FFL'
		and statusId ~= 'FFA/GA'
	then
		local ffaObj
		local actions = articleHistoryObj:getActionObjects()
		for i = #actions, 1, -1 do
			local actionObj = actions[i]
			if actionObj.id == 'FAR' and actionObj.resultId == 'demoted' then
				ffaObj = actionObj
				break
			end
		end
		if ffaObj then
			if not statusId then
				articleHistoryObj:raiseError(
					'former featured articles should have a current status',
					'Bản mẫu:Lịch sử bài viết#Former featured articles'
				)
			elseif statusId == 'GA' then
				statusId = 'FFA/GA'
			elseif statusId == 'DGA' then
				statusId = 'FFA'
			else
				articleHistoryObj:raiseError(
					string.format(
						"'%s' không phải là trạng thái hiện tại hợp lệ của bài viết chọn lọc cũ",
						tostring(statusCode)
					),
					'Bản mẫu:Lịch sử bài viết#Former featured articles'
				)
			end
		end
	end

	return statusId
end,

-------------------------------------------------------------------------------
-- Notices
-------------------------------------------------------------------------------

-- The notices table contains configuration tables for notices about the article
-- that are unrelated to its current status.
-- Each configuration table can have the following fields:
--
-- id: the main ID for the notice. This should be the same as the configuration
--    table key.
-- isActive: a function that should return a truthy value if the notice should
--    be displayed, and a falsy value if not. (Falsy values are false and nil,
--    and truthy values are everything else.) The function takes an article
--    history object as its first parameter.
-- makeData: a function that should return a table of data to be used by other
--    functions in this notice configuration table. It can be accessed using
--    noticeObj:getData().
-- icon: the filename of the notice icon, minus the "File:" prefix.
-- iconCaption: the icon caption.
-- iconSize: The icon size, including "px" suffix. The default is defined in
--    defaultIconSize.
-- iconSmallSize: The icon size if we are outputting a small template. The
--    default is defined in defaultSmallIconSize.
-- text: The notice text. This may be a string or a function. If it is a
--    function, it takes an article history object as the first parameter, and
--    the current notice object as the second parameter, and should return the
--    text string.
-- categories: The categories set by the notice. This may be an array of
--    category names, or a function. If it is a function, it takes an article
--    history object as the first parameter, and the current notice object as
--    the second parameter, and should return an array of category objects.
-- noticeBarIcon: the icon to use for the notice bar. This can be a string, or
--    a function, or true. If it is a function it takes an article history
--    object as the first parameter, and should output the icon filename. If it
--    is true, it uses the value of icon. If it is nil then no notice bar icon
--    will be displayed.
-- noticeBarIconCaption: the caption to use for the notice bar icon. This can be
--    a string or a function. If it is a function, it takes an article history
--    object as its first parameter, and should return the caption text. If this
--    is absent, the icon caption is used instead.
-- noticeBarIconSize: the size of the notice bar icon, including "px" suffix.
--    The default is set by defaultNoticeBarIconSize.

notices = {
	{
		id = 'FT',
		isActive = function (articleHistoryObj)
			local args = articleHistoryObj.args
			local prefixArgs = articleHistoryObj.prefixArgs
			-- ftmain is included here because it leads to better error
			-- messages than leaving it out, even though ftmain by itself is
			-- invalid.
			return args.ftname or args.ftmain or prefixArgs.ft
		end,
		makeData = function (articleHistoryObj)
			local args = articleHistoryObj.args
			local prefixArgs = articleHistoryObj.prefixArgs
			local data = {}
			local getTopicStatus = require('Module:FeaturedTopicSum').status
			local yesno = require('Module:Yesno')

			local function makeTopicData(name, isMain, paramNum)
				if name then
					return {
						name = name,
						isMain = yesno(isMain) or false,
						status = getTopicStatus(name),
						paramNum = paramNum
					}
				elseif isMain then
					local num = paramNum and tostring(paramNum) or ''
					articleHistoryObj:raiseError(
						string.format(
							"parameter 'ft%smain' is set, but no featured " ..
								"topic name is set in parameter 'ft%sname'",
							num, num
						),
						'Bản mẫu:Lịch sử bài viết#Featured topic names'
					)
				else
					return nil
				end
			end
			data[#data + 1] = makeTopicData(args.ftname, args.ftmain)
			if prefixArgs.ft then
				for _, t in ipairs(prefixArgs.ft) do
					if t[1] > 1 then -- we use args.ftname instead of args.ft1name
						data[#data + 1] = makeTopicData(t.name, t.main, t[1])
					end
				end
			end

			-- Check for rogue ft.. parameters
			if #data < 1 then
				articleHistoryObj:raiseError(
					"a parameter starting with 'ft' was detected, but no " ..
						"featured topic names were specified; " ..
						"please check the parameter names",
					'Bản mẫu:Lịch sử bài viết#Featured topic names'
				)
			end

			-- Find if one of the topics is featured.
			local isInFeaturedTopic = false
			for _, topic in ipairs(data) do
				if topic.status == 'FT' then
					isInFeaturedTopic = true
					break
				end
			end
			data.isInFeaturedTopic = isInFeaturedTopic

			return data
		end,
		icon = function (articleHistoryObj, noticeObj)
			local data = noticeObj:getData(articleHistoryObj)
			if not data then
				return nil
			end
			if data.isInFeaturedTopic then
				return 'Cscr-featuredtopic.svg'
			else
				return 'Support cluster.svg'
			end
		end,
		iconCaption = function (articleHistoryObj, noticeObj)
			local data = noticeObj:getData(articleHistoryObj)
			if not data then
				return nil
			end
			if data.isInFeaturedTopic then
				return 'Featured topic star'
			else
				return 'Good topic star'
			end
		end,
		iconSize = '48px',
		iconSmallSize = '30px',
		text = function (articleHistoryObj, noticeObj)
			local data = noticeObj:getData(articleHistoryObj)
			if not data then
				return nil
			end
			local article = articleHistoryObj.currentTitle.subjectPageTitle.prefixedText

			local firstBlurb = "'''%s''' là %s '''[[Wikipedia:Chủ điểm chọn lọc/%s|%s]]''', %s."
			local otherBlurb = "Nó cũng là %s '''[[Wikipedia:Chủ điểm chọn lọc/%s|%s]]''', %s."
			local finalBlurb = "%s được bình chọn lọc một trong loạt " ..
				"bài viết xuất sắc nhất được cộng đồng thành viên Wikipedia viết nên. " ..
				"Nếu bạn có thể cập nhật hoặc cải thiện %s, [[Wikipedia:Hãy táo bạo|xin mời bạn!]]"
			local main = 'bài viết chính của'
			local notMain = 'một phần của'
			local featuredLink = 'một [[Wikipedia:Chủ điểm chọn lọc|chủ điểm chọn lọc]]'
			local featuredNoLink = 'một chủ điểm chọn lọc'
			local goodLink = 'một [[Wikipedia:Chủ điểm tốt|chủ điểm tốt]]'
			local goodNoLink = 'một chủ điểm tốt'
			local thisSingular = 'Đây là'
			local thisPlural = 'Đây là'
			local itSingular = 'nó'
			local itPlural = 'chúng'

			local hasFeaturedLink = false
			local hasGoodLink = false
			local text = {}

			-- First topic
			do
				local topic = data[1]
				local link
				if topic.status == 'FT' then
					link = featuredLink
					hasFeaturedLink = true
				else
					link = goodLink
					hasGoodLink = true
				end
				text[#text + 1] = string.format(
					firstBlurb,
					article,
					topic.isMain and main or notMain,
					topic.name,
					topic.name,
					link
				)
			end

			-- Other topics
			for i = 2, #data do
				local topic = data[i]
				local link
				if topic.status == 'FT' then
					if hasFeaturedLink then
						link = featuredNoLink
					else
						link = featuredLink
						hasFeaturedLink = true
					end
				else
					if hasGoodLink then
						link = goodNoLink
					else
						link = goodLink
						hasGoodLink = true
					end
				end
				text[#text + 1] = string.format(
					otherBlurb,
					topic.isMain and main or notMain,
					topic.name,
					topic.name,
					link
				)
			end

			-- Final blurb
			do
				local isPlural = #data > 1
				text[#text + 1] = string.format(
					finalBlurb,
					isPlural and thisPlural or thisSingular,
					isPlural and itPlural or itSingular
				)
			end

			return table.concat(text, ' ')
		end,
		categories = function (articleHistoryObj, noticeObj)
			local data = noticeObj:getData(articleHistoryObj)
			if not data then
				return nil
			end
			local status = articleHistoryObj:getStatusId()
			local article = articleHistoryObj.currentTitle.subjectPageTitle.prefixedText
			local cats = {}

			local function addCat(cat, sort)
				cats[#cats + 1] = Category.new(cat, sort)
			end

			-- Page-wide status categories
			if status == 'FA' or status == 'BVCL' then
				addCat('Bài viết thuộc chủ điểm chọn lọc đạt chất lượng BVCL')
			elseif status == 'FL' or status == 'DSCL' then
				addCat('Bài viết thuộc chủ điểm chọn lọc đạt chất lượng DSCL')
			elseif status == 'FFA/GA' or status == 'GA' or status == 'BVT' then
				addCat('Bài viết thuộc chủ điểm chọn lọc đạt chất lượng BVT')
			else
				addCat('Bài viết thuộc chủ điểm chọn lọc chưa đánh giá chất lượng')
			end

			-- Topic-specific status categories
			local function addTopicCats(catFormat)
				for _, topic in ipairs(data) do
					addCat(string.format(catFormat, topic.name))
				end
			end
			if status == 'FA' or status == 'FL' or status == 'BVCL' or status == 'DSCL' then
				addTopicCats('Nội dung chọn lọc của chủ điểm chọn lọc %s')
			elseif status == 'FFA/GA' or 'GA' or status == 'BVT' then
				addTopicCats('Nội dung tốt của chủ điểm chọn lọc %s')
			else
				addTopicCats('Chủ điểm chọn lọc %s')
			end

			-- Importance categories
			local hasTop, hasHigh, hasMid, hasLow -- These check for dupes
			for _, topic in ipairs(data) do
				local cat, sort
				if topic.status == 'FT' then
					if topic.isMain and not hasTop then
						cat = 'Bài viết thuộc chủ điểm chọn lọc đặc biệt quan trọng'
						sort = topic.name .. ' ' .. article
						hasTop = true
					elseif not topic.isMain and not hasHigh then
						cat = 'Bài viết thuộc chủ điểm chọn lọc rất quan trọng'
						hasHigh = true
					end
				else
					if topic.isMain and not hasMid then
						cat = 'Bài viết thuộc chủ điểm chọn lọc khá quan trọng'
						sort = topic.name .. ' ' .. article
						hasMid = true
					elseif not topic.isMain and not hasLow then
						cat = 'Bài viết thuộc chủ điểm chọn lọc ít quan trọng'
						hasLow = true
					end
				end
				if cat then
					addCat(cat, sort)
				end
			end

			return cats
		end
	},

	-- Main page date
	{
		id = 'MAINDATE',
		isActive = function (articleHistoryObj)
			local args = articleHistoryObj.args
			local status = articleHistoryObj:getStatusId()
			return args.maindate or status == 'FA' or status == 'FL' or status == 'BVCL' or status == 'DSCL'
		end,
		makeData = function (articleHistoryObj)
			local args = articleHistoryObj.args
			local status = articleHistoryObj:getStatusId()
			local data = {}

			local function validateMainDate(argName, dataName, dataTimestampName)
				data[dataName] = args[argName]
				if data[dataName] then
					data[dataTimestampName] = getYmdDate(data[dataName])
					if not data[dataTimestampName] then
						articleHistoryObj:raiseError(
							string.format(
								"invalid date '%s' detected in parameter '%s'",
								data[dataName],
								argName
							),
							'Bản mẫu:Lịch sử bài viết#Invalid date'
						)
					end
				end
			end

			validateMainDate('maindate', 'mainDate', 'mainDateTimestamp')
			if data.mainDate then
				validateMainDate('maindate2', 'mainDate2', 'mainDate2Timestamp')
				if data.mainDate2 and data.mainDateTimestamp >= data.mainDate2Timestamp then
					articleHistoryObj:raiseError(
						"the date in the 'maindate' parameter must be earlier than the date in the 'maindate2' parameter",
						'Bản mẫu:Lịch sử bài viết#Main Page date order'
					)
				end
			end

			data.currentTimestamp = getYmdDate()


			-- Whether the page is a list or not for the purposes of the Main
			-- Page. The first Today's Featured List was on 13 June 2011, so
			-- lists that were featured before then count as articles.
			data.isList = (status == 'FL' or status == 'FFL')
				and (not data.mainDate or data.mainDateTimestamp >= 20110613)

			return data
		end,
		icon = 'Wikipedia-logo-v2.svg',
		iconCaption = 'Main Page trophy',
		text = function (articleHistoryObj, noticeObj)
			local data = noticeObj:getData(articleHistoryObj)
			if not data or not data.mainDate then
				return nil
			end

			-- Build the blurb for all the possible combinations of past,
			-- present and future appearances of maindate and maindate2.
			local pagetype = data.isList and 'Danh sách' or 'Bài viết'
			local mainDateLong = getLongDate(data.mainDate)
			local mainDate2Long = data.mainDate2 and getLongDate(data.mainDate2)
			local todaysFA = pagetype .. " chọn lọc"

			local function makeFeaturedLink(date, display)
				return string.format(
					"[[Wikipedia:%s chọn lọc/%s|%s]]",
					pagetype,
					date,
					display or date
				)
			end

			local function isPast(timestamp)
				return timestamp < data.currentTimestamp
			end

			local function isCurrent(timestamp)
				return timestamp == data.currentTimestamp
			end

			local function isFuture(timestamp)
				return timestamp > data.currentTimestamp
			end

			if data.mainDate2 then
				if isPast(data.mainDateTimestamp) then
					if isPast(data.mainDate2Timestamp) then
						return string.format(
							"Bài viết này từng được lên [[Trang Chính]] Wikipedia tiếng Việt ở mục %s vào %s, và vào %s.",
							todaysFA,
							makeFeaturedLink(mainDateLong),
							makeFeaturedLink(mainDate2Long)
						)
					elseif isCurrent(data.mainDate2Timestamp) then
						return string.format(
							"Bài viết này hiện đang được lên [[Trang Chính]] Wikipedia tiếng Việt ở mục %s, và cũng từng được lên lại vào %s.",
							makeFeaturedLink(mainDate2Long, todaysFA),
							makeFeaturedLink(mainDateLong)
						)
					else
						return string.format(
							"Bài viết này từng được lên [[Trang Chính]] Wikipedia tiếng Việt ở mục %s vào %s, và sẽ được lên lại vào %s.",
							todaysFA,
							makeFeaturedLink(mainDateLong),
							makeFeaturedLink(mainDate2Long)
						)
					end
				elseif isCurrent(data.mainDateTimestamp) then
					if isFuture(data.mainDate2Timestamp) then
						return string.format(
							"Bài viết này hiện đang được lên [[Trang Chính]] Wikipedia tiếng Việt ở mục %s, và sẽ được lên lại vào %s.",
							makeFeaturedLink(mainDateLong, todaysFA),
							makeFeaturedLink(mainDate2Long)
						)
					else
						return nil
					end
				else
					if isFuture(data.mainDate2Timestamp) then
						return string.format(
							"Bài viết này sẽ được lên [[Trang Chính]] Wikipedia tiếng Việt ở mục %s vào %s, và được lên lại vào %s.",
							todaysFA,
							makeFeaturedLink(mainDateLong),
							makeFeaturedLink(mainDate2Long)
						)
					else
						return nil
					end
				end
			else
				if isPast(data.mainDateTimestamp) then
					return string.format(
						"Bài viết này đã từng được lên [[Trang Chính]] Wikipedia tiếng Việt ở mục %s vào %s.",
						makeFeaturedLink(mainDateLong, todaysFA),
						mainDateLong
					)
				elseif isCurrent(data.mainDateTimestamp) then
					return string.format(
						"Bài viết này hiện đang được lên [[Trang Chính]] Wikipedia tiếng Việt ở mục %s.",
						makeFeaturedLink(mainDateLong, todaysFA),
						mainDateLong
					)
				else
					return string.format(
						"Bài viết này sẽ được lên [[Trang Chính]] Wikipedia tiếng Việt ở mục %s vào %s.",
						makeFeaturedLink(mainDateLong, todaysFA),
						mainDateLong
					)
				end
			end
		end,
	--	categories = function (articleHistoryObj, noticeObj)
	--		local data = noticeObj:getData(articleHistoryObj)
	--		if not data then
	--			return nil
	--		end
	--		local status = articleHistoryObj:getStatusId()
	--		local cats = {}
--
--			local pagetype = data.isList and 'Danh sách' or 'Bài viết'
--			if data.mainDate and data.mainDateTimestamp <= data.currentTimestamp then
--				cats[#cats + 1] = Category.new(string.format(
--					'%s chọn lọc được lên trang chính',
--					pagetype
--				))
--				if data.mainDate2 and data.mainDate2Timestamp <= data.currentTimestamp then
--					cats[#cats + 1] = Category.new(string.format(
--						'%s chọn lọc được lên trang chính hai lần',
--						pagetype
--					))
--				else
--					cats[#cats + 1] = Category.new(string.format(
--						'%s chọn lọc được lên trang chính một lần',
--						pagetype
--					))
--				end
--			elseif status == 'FA' or status == 'FL' or data.mainDate then
--				cats[#cats + 1] = Category.new(string.format(
--					'%s chọn lọc chưa được lên trang chính',
--					pagetype
--				))
--			end
--			return cats
--		end
	}
},

-------------------------------------------------------------------------------
-- Actions
-------------------------------------------------------------------------------

-- The actions table contains configuration tables for actions such as featured
-- article candidacies and peer review, etc.
-- Each configuration table can have the following fields:
--
-- id: the main ID for the action. This should be the same as the configuration
--    table key.
-- name: the name of the action. This can be a string or a function. If it is
--    a function, it takes an article history object as its first parameter and
--    the action object as its second parameter, and should return the name.
-- results: a table of possible results for the action. Keys in the table should
--    be a result ID, e.g. "promoted" or "kept", and values should be a subtable
--    with the following fields:
--    id: the result ID. This should be the same as the table key. It will
--        also define a possible input value for the action's result parameter.
--    text: the displayed result text. This may be a string or a function. If it
--        is a function, it takes an article history object as the first
--        parameter and the current action object as the second parameter, and
--        should return the result string.
--    aliases: an array of result ID aliases. Each of these will define a valid
--        value for the action's result parameter.
-- text: The action text. This may be a string or a function. If it is a
--    function, it takes an article history object as the first parameter and
--    the current action object as the second parameter, and should return the
--    text string.
-- categories: The categories set by the notice. This may be an array of
--    category names, or a function. If it is a function, it takes an article
--    history object as the first parameter and the current action object as the
--    second parameter, and should return an array of category objects.
-- noticeBarIcon: the icon to use for the notice bar. This can be a string, or
--    a function, or true. If it is a function it takes an article history
--    object as the first parameter, and should output the icon filename. If it
--    is true, it uses the value of icon. If it is nil then no notice bar icon
--    will be displayed.
-- noticeBarIconCaption: the caption to use for the notice bar icon. This can be
--    a string or a function. If it is a function, it takes an article history
--    object as its first parameter, and should return the caption text. If this
--    is absent, the icon caption is used instead.
-- noticeBarIconSize: the size of the notice bar icon, including "px" suffix.
--    The default is set by defaultNoticeBarIconSize.

actions = {
	FAC = {
		id = 'FAC',
		name = 'Ứng cử viên bài viết chọn lọc',
		aliases = {'UCVBVCL'},
		results = {
			promoted = {
				id = 'promoted',
				text = 'Đề cử thành công',
				aliases = {'pass', 'passed', 'thành công'}
			},
			['not promoted'] = {
				id = 'not promoted',
				text = 'Đề cử không thành công',
				aliases = {'fail', 'failed', 'thất bại', 'không thành công'}
			}
		}
	},
	FAR = {
		id = 'FAR',
		name = 'Đề nghị rút sao bài viết chọn lọc',
		aliases = {'FARC', 'RSBVCL'},
		results = {
			kept = {
				id = 'kept',
				text = 'Giữ sao',
				aliases = {'pass', 'passed', 'keep', 'giữ sao'}
			},
			demoted = {
				id = 'demoted',
				text = 'Rút sao',
				aliases = {'fail', 'failed', 'remove', 'removed', 'rút sao'}
			},
			merged = {
				id = 'merged',
				text = 'Gộp',
				aliases = {'merge'}
			}
		},
		categories = function (articleHistoryObj, actionObj)
			local ret = {}
			local result = actionObj.resultId
			if result == 'demoted' or result == 'merged' then
				local status = articleHistoryObj:getStatusId()
				local sortKey = articleHistoryObj.currentTitle.subjectPageTitle.prefixedText
				if status == 'FA' or status == 'FL' or status == 'BVCL' or status == 'DSCL' then
					sortKey = '#' .. sortKey
				end
				ret[#ret + 1] = Category.new(
					'Bài viết mất sao chọn lọc',
					sortKey
				)
			end
			return ret
		end
	},
	BP = {
		id = 'BP',
		name = 'Bài viết xuất sắc',
		aliases = {'BVXS'},
		results = {
			nominated = {
				id = 'nominated',
				text = 'Được đề cử',
				aliases = {'pass', 'promoted', 'nom', 'đề cử', 'được đề cử'}
			}
		}
	},
	RBP = {
		id = 'RBP',
		name = 'Làm mới bài viết xuất sắc',
		aliases = {'LMBVXS'},
		results = {
			kept = {
				id = 'kept',
				text = 'Giữ',
				aliases = {'pass', 'passed', 'keep', 'giữ', 'thông qua'}
			},
			['not kept'] = {
				id = 'not kept',
				text = 'Không giữ',
				aliases = {'fail', 'failed', 'remove', 'removed', 'demoted', 'gỡ', 'xóa', 'không giữ'}
			}
		},
		categories = function (articleHistoryObj, actionObj)
			local ret = {}
			if actionObj.resultId == 'not kept' then
				ret[#ret + 1] = Category.new(
					'Bài viết xuất sắc cũ',
					articleHistoryObj.currentTitle.text
				)
			end
			return ret
		end
	},
	FLC = {
		id = 'FLC',
		name = 'Ứng cử viên danh sách chọn lọc',
		aliases = {'UCVDSCL'},
		results = {
			promoted = {
				id = 'promoted',
				text = 'Đề cử thành công',
				aliases = {'pass', 'passed', 'thành công'}
			},
			['not promoted'] = {
				id = 'not promoted',
				text = 'Đề cử không thành công',
				aliases = {'fail', 'failed', 'thất bại', 'không thành công'}
			}
		}
	},
	FLR = {
		id = 'FLR',
		name = 'Đề nghị rút sao danh sách chọn lọc',
		aliases = {'RSDSCL'},
		results = {
			kept = {
				id = 'kept',
				text = 'Giữ sao',
				aliases = {'pass', 'passed', 'keep', 'giữ sao'}
			},
			demoted = {
				id = 'demoted',
				text = 'Rút sao',
				aliases = {'fail', 'failed', 'remove', 'removed', 'rút sao'}
			},
			merged = {
				id = 'merged',
				text = 'Gộp',
				aliases = {'merge', 'gộp'}
			}
		},
		categories = function (articleHistoryObj, actionObj)
			local ret = {}
			local result = actionObj.resultId
			if result == 'demoted' or result == 'merged' then
				local sortKey
				if articleHistoryObj:getStatusId() == 'FL' then
					sortKey = '#' .. articleHistoryObj.currentTitle.subjectPageTitle.prefixedText
				else
					sortKey = articleHistoryObj.currentTitle.text
				end
				ret[#ret + 1] = Category.new(
					'Danh sách mất sao chọn lọc',
					sortKey
				)
			end
			return ret
		end
	},
	FTC = {
		id = 'FTC',
		name = 'Ứng cử viên chủ điểm chọn lọc',
		aliases = {'UCVCDCL'},
		results = {
			promoted = {
				id = 'promoted',
				text = 'Đề cử thành công',
				aliases = {'pass', 'passed', 'thành công'}
			},
			['not promoted'] = {
				id = 'not promoted',
				text = 'Đề cử không thành công',
				aliases = {'fail', 'failed', 'thất bại', 'không thành công'}
			}
		}
	},
	FTR = {
		id = 'FTR',
		name = 'Đề nghị rút sao chủ điểm chọn lọc',
		aliases = {'RSCDCL'},
		results = {
			kept = {
				id = 'kept',
				text = 'Giữ sao',
				aliases = {'pass', 'passed', 'keep', 'giữ sao'}
			},
			demoted = {
				id = 'demoted',
				text = 'Rút sao',
				aliases = {'fail', 'failed', 'remove', 'removed', 'rút sao'}
			},
			merged = {
				id = 'merged',
				text = 'Gộp',
				aliases = {'merge', 'gộp'}
			}
		}
	},
	FPOC = {
		id = 'FPOC',
		name = 'Ứng cử viên cổng thông tin chọn lọc',
		aliases = {'UCVCTTCL'},
		results = {
			promoted = {
				id = 'promoted',
				text = 'Đề cử thành công',
				aliases = {'pass', 'passed', 'thành công'}
			},
			['not promoted'] = {
				id = 'not promoted',
				text = 'Đề cử không thành công',
				aliases = {'fail', 'failed', 'thất bại', 'không thành công'}
			}
		}
	},
	FPOR = {
		id = 'FPOR',
		name = 'Đề nghị rút sao cổng thông tin chọn lọc',
		aliases = {'RSCTTCL'},
		results = {
			kept = {
				id = 'kept',
				text = 'Giữ sao',
				aliases = {'pass', 'passed', 'keep', 'giữ sao'}
			},
			demoted = {
				id = 'demoted',
				text = 'Rút sao',
				aliases = {'fail', 'failed', 'remove', 'removed', 'rút sao'}
			},
			merged = {
				id = 'merged',
				text = 'Gộp',
				aliases = {'merge', 'gộp'}
			}
		}
	},
	GAN = {
		id = 'GAN',
		name = 'Ứng cử viên bài viết tốt',
		aliases = {'GAC', 'UCVBVT'},
		results = {
			listed = {
				id = 'listed',
				text = 'Đề cử thành công',
				aliases = {'pass', 'passed', 'promoted', 'thành công'}
			},
			['not listed'] = {
				id = 'not listed',
				text = 'Đề cử không thành công',
				aliases = {'fail', 'failed', 'not promoted', 'thất bại', 'không thành công'}
			}
		},
		categories = function (articleHistoryObj, actionObj)
			local ret = {}
			if actionObj.resultId == 'not listed' then
				local status = articleHistoryObj:getStatusId()
				if status ~= 'FA'
					and status ~= 'GA'
					and status ~= 'FFA'
				then
					ret[#ret + 1] = Category.new(
						'Ứng cử viên bài viết tốt cũ',
						articleHistoryObj.currentTitle.text
					)
				end
			end
			return ret
		end
	},
	GAR = {
		id = 'GAR',
		name = 'Đề nghị rút sao bài viết tốt',
		aliases = {'RSBVT'},
		results = {
			kept = {
				id = 'kept',
				text = 'Giữ sao',
				aliases = {'pass', 'passed', 'keep', 'giữ sao'}
			},
			delisted = {
				id = 'delisted',
				text = 'Rút sao',
				aliases = {'fail', 'failed', 'rút sao'}
			},
			listed = {
				id = 'listed',
				text = 'Gắn sao'
			},
			['not listed'] = {
				id = 'not listed',
				text = 'Không gắn sao'
			}
		},
		categories = function (articleHistoryObj, actionObj)
			local ret = {}
			if actionObj.resultId == 'delisted' then
				local status = articleHistoryObj:getStatusId()
				if status ~= 'FA'
					and status ~= 'GA'
				then
					ret[#ret + 1] = Category.new(
						'Bài viết mất sao tốt',
						articleHistoryObj.currentTitle.text
					)
				end
			end
		end
	},
	GTC = {
		id = 'GTC',
		name = 'Ứng cử viên chủ điểm tốt',
		aliases = {'UCVCDT'},
		results = {
			promoted = {
				id = 'promoted',
				text = 'Đề cử thành công',
				aliases = {'pass', 'passed', 'thành công'}
			},
			['not promoted'] = {
				id = 'not promoted',
				text = 'Đề cử không thành công',
				aliases = {'fail', 'failed', 'thất bại', 'không thành công'}
			}
		}
	},
	GTR = {
		id = 'GTR',
		name = 'Đề nghị rút sao chủ điểm tốt',
		aliases = {'RSCDT'},
		results = {
			kept = {
				id = 'kept',
				text = 'Giữ sao',
				aliases = {'pass', 'passed', 'keep', 'giữ sao'}
			},
			demoted = {
				id = 'demoted',
				text = 'Rút sao',
				aliases = {'fail', 'failed', 'remove', 'removed', 'rút sao'}
			},
			merged = {
				id = 'merged',
				text = 'Gộp',
				aliases = {'merge', 'gộp'}
			}
		}
	},
	PR = {
		id = 'PR',
		name = 'Bình duyệt',
		aliases = {'bình duyệt', 'BD'},
		results = {
			reviewed = {
				id = 'reviewed',
				text = 'Đã bình duyệt',
				aliases = {'_BLANK'}
			},
			['not reviewed'] = {
				id = 'not reviewed',
				text = 'Chưa được bình duyệt',
			}
		},
	--	categories = {'Old requests for peer review'}
	},
	WPR = {
		id = 'WPR',
		name = function (articleHistoryObj, actionObj)
			local names = {
				approved = 'Phiên bản được duyệt trong dự án',
				copyedited = 'Hiệp hội biên tập bản sao',
				collaboration = 'Hợp tác dự án',
				maindate = "Bài viết chọn lọc"
			}
			local result = actionObj.resultId
			return result and names[result] or 'Bình duyệt trong dự án'
		end,
		results = {
			approved = {
				id = 'approved',
				text = function(articleHistoryObj, actionObj)
					if actionObj.oldid then
						local url = mw.uri.fullUrl(
							articleHistoryObj.currentTitle.prefixedText,
							{diff = 'cur', oldid = actionObj.oldid}
						)
						return string.format(
							'[%s %s]',
							tostring(url),
							'Diff to current version'
						)
					else
						error(string.format(
							"No oldid detected for the approved version; " ..
								"please set the 'action%doldid' parameter " ..
								"or give the 'action%dresult' parameter a " ..
								"different value.",
							actionObj.paramNum,
							actionObj.paramNum
						))
					end
				end,
				aliases = {'approved version'}
			},
			copyedited = {
				id = 'copyedited',
				text = 'Đã được chỉnh sửa bản sao',
				aliases = {'copyedit', 'proofread', 'chỉnh sửa bản sao'}
			},
			maindate = {
				id = 'maindate',
				text = 'Trang Chính'
			},
			collaborated = {
				id = 'collaborated',
				text = 'Đã được hợp tác',
				aliases = {'cotw', 'collaboration', 'hợp tác'}
			},
			reviewed = {
				id = 'reviewed',
				text = 'Đã được kiểm tra',
				aliases = {'_BLANK'}
			}
		},
		categories = function (articleHistoryObj, actionObj)
			local ret = {}
			local result = actionObj.resultId
			if result == 'copyedited' then
				-- ret[1] = Category.new('Articles copy edited by the Guild of Copy Editors')
			end
			return ret
		end
	},
	WAR = {
		id = 'WAR',
		name = 'Bình duyệt chất lượng A trong dự án',
		results = {
			approved = {
				id = 'approved',
				text = 'Duyệt',
				aliases = {'pass', 'passed', 'thành công', 'duyệt'}
			},
			['not approved'] = {
				id = 'not approved',
				text = 'Chưa được duyệt',
				aliases = {'fail', 'failed', 'not reviewed', 'thất bại', 'không thành công', 'chưa được duyệt'}
			},
			reviewed = {
				id = 'reviewed',
				text = 'Đã được kiểm tra',
				aliases = {'_BLANK'}
			},
			kept = {
				id = 'kept',
				text = 'Giữ',
				aliases = {'keep', 'giữ'}
			},
			demoted = {
				id = 'demoted',
				text = 'Hạ chất lượng',
				aliases = {'demote', 'hạ chất lượng'}
			}
		}
	},
	AFD = {
		id = 'AFD',
		name = 'Biểu quyết xoá bài',
		aliases = {'BQXB'},
		results = {
			kept = {
				id = 'kept',
				text = 'Giữ',
				aliases = {'withdrawn', 'keep', 'giữ'}
			},
			deleted = {
				id = 'deleted',
				text = 'Xóa',
				aliases = {'delete', 'xóa'}
			},
			merged = {
				id = 'merged',
				text = 'Gộp',
				aliases = {'merge', 'gộp'}
			},
			['no consensus'] = {
				id = 'no consensus',
				text = 'Không có đồng thuận'
			},
			['speedily kept'] = {
				id = 'speedily kept',
				text = 'Giữ nhanh',
				aliases = {'speedy keep', 'giữ nhanh'}
			},
			['speedily deleted'] = {
				id = 'speedily deleted',
				text = 'Xóa nhanh',
				aliases = {'speedy delete', 'xóa nhanh'}
			},
			redirected = {
				id = 'redirected',
				text = 'Đổi hướng',
				aliases = {'redirect', 'đổi hướng'}
			},
			renamed = {
				id = 'renamed',
				text = 'Di chuyển',
				aliases = {'rename', 'move', 'moved', 'di chuyển', 'đổi tên'}
			},
		}
	},
	MFD = {
		id = 'MFD',
		name = 'Biểu quyết xóa trang thuộc không gian khác',
		results = {
			kept = {
				id = 'kept',
				text = 'Giữ',
				aliases = {'withdrawn', 'keep', 'giữ'}
			},
			deleted = {
				id = 'deleted',
				text = 'Xóa',
				aliases = {'delete', 'xóa'}
			},
			merged = {
				id = 'merged',
				text = 'Gộp',
				aliases = {'merge', 'gộp'}
			},
			['no consensus'] = {
				id = 'no consensus',
				text = 'Không có đồng thuận'
			},
			['speedily kept'] = {
				id = 'speedily kept',
				text = 'Giữ nhanh',
				aliases = {'speedy keep', 'giữ nhanh'}
			},
			['speedily deleted'] = {
				id = 'speedily deleted',
				text = 'Xóa nhanh',
				aliases = {'speedy delete', 'xóa nhanh'}
			},
			redirected = {
				id = 'redirected',
				text = 'Đổi hướng',
				aliases = {'redirect', 'đổi hướng'}
			},
			renamed = {
				id = 'renamed',
				text = 'Di chuyển',
				aliases = {'rename', 'move', 'moved', 'di chuyển', 'đổi tên'}
			},
		}
	},
	TFD = {
		id = 'TFD',
		name = 'Biểu quyết xóa thể loại, bản mẫu và mô đun',
		aliases = {'CFD'},
		results = {
			kept = {
				id = 'kept',
				text = 'Giữ',
				aliases = {'withdrawn', 'keep', 'giữ'}
			},
			deleted = {
				id = 'deleted',
				text = 'Xóa',
				aliases = {'delete', 'xóa'}
			},
			merged = {
				id = 'merged',
				text = 'Gộp',
				aliases = {'merge', 'gộp'}
			},
			['no consensus'] = {
				id = 'no consensus',
				text = 'Không có đồng thuận'
			},
			['speedily kept'] = {
				id = 'speedily kept',
				text = 'Giữ nhanh',
				aliases = {'speedy keep', 'giữ nhanh'}
			},
			['speedily deleted'] = {
				id = 'speedily deleted',
				text = 'Xóa nhanh',
				aliases = {'speedy delete', 'xóa nhanh'}
			},
			redirected = {
				text = 'Đổi hướng',
				aliases = {'redirect', 'đổi hướng'}
			},
			renamed = {
				id = 'renamed',
				text = 'Di chuyển',
				aliases = {'rename', 'move', 'moved', 'di chuyển', 'đổi tên'}
			},
		}
	},
	CSD = {
		id = 'CSD',
		name = 'Đề nghị xóa nhanh',
		aliases = {'TCXN', 'XN', 'DNXN', 'SPEEDY'},
		results = {
			kept = {
				id = 'kept',
				text = 'Giữ',
				aliases = {'withdrawn', 'keep', 'giữ'}
			},
			deleted = {
				id = 'deleted',
				text = 'Xóa nhanh',
				aliases = {'delete', 'speedily deleted', 'speedy delete', 'xóa', 'xóa nhanh'}
			},
			['speedily kept'] = {
				id = 'speedily kept',
				text = 'Giữ nhanh',
				aliases = {'speedy keep', 'giữ nhanh'}
			},
			redirected = {
				id = 'redirected',
				text = 'Đổi hướng',
				aliases = {'redirect', 'đổi hướng'}
			},
			prod = {
				id = 'prod',
				text = 'Chuyển thành đề nghị xóa trang',
				aliases = {'prodded', 'đề nghị'}
			},
			afd = {
				id = 'afd',
				text = 'Chuyển đến [[WP:BQXB|biểu quyết xoá bài]]',
				aliases = {'afded', 'bqxb', 'biểu quyết'}
			},
			renamed = {
				id = 'renamed',
				text = 'Di chuyển',
				aliases = {'rename', 'move', 'moved', 'di chuyển', 'đổi tên'}
			},
		}
	},
	PROD = {
		id = 'PROD',
		name = 'Đề nghị xóa trang',
		aliases = {'DNXT', 'Proposed deletion'},
		results = {
			kept = {
				id = 'kept',
				text = 'Giữ',
				aliases = {'withdrawn', 'keep', 'giữ'}
			},
			deleted = {
				id = 'deleted',
				text = 'Xóa',
				aliases = {'delete', 'xóa'}
			},
			['speedily kept'] = {
				id = 'speedily kept',
				text = 'Giữ nhanh',
				aliases = {'speedy keep', 'giữ nhanh'}
			},
			['speedily deleted'] = {
				id = 'speedily deleted',
				text = 'Xóa nhanh',
				aliases = {'speedy delete', 'xóa nhanh'}
			},
			redirected = {
				id = 'redirected',
				text = 'Đổi hướng',
				aliases = {'redirect', 'đổi hướng'}
			},
			afd = {
				id = 'afd',
				text = 'Chuyển đến [[WP:BQXB|biểu quyết xoá bài]]',
				aliases = {'afded', 'bqxb', 'biểu quyết'}
			},
			renamed = {
				id = 'renamed',
				text = 'Di chuyển',
				aliases = {'rename', 'move', 'moved', 'di chuyển', 'đổi tên'}
			},
		}
	},
	DRV = {
		id = 'DRV',
		name = 'Biểu quyết phục hồi trang',
		aliases = {'BQPHT', 'PH'},
		results = {
			endorsed = {
				id = 'endorsed',
				text = 'Phục hồi',
				aliases = {'endorse', 'phục hồi'}
			},
			relisted = {
				id = 'relisted',
				text = 'Phục hồi',
				aliases = {'relist'}
			},
			overturned = {
				id = 'overturned',
				text = 'Không phục hồi',
				aliases = {'overturn', 'không phục hồi'}
			},
			['no consensus'] = {
				id = 'no consensus',
				text = 'Không có đồng thuận',
				aliases = {'không có đồng thuận'}
			}
		}
	}
},

-------------------------------------------------------------------------------
-- Collapsible notices
-------------------------------------------------------------------------------

-- The collapsibleNotices table contains configuration tables for notices that
-- go in the collapsible part of the template, underneath the actions.
-- Each configuration table can have the following fields:
--
-- id: the main ID for the notice. This should be the same as the configuration
--    table key.
-- isActive: a function that should return a truthy value if the notice should
--    be displayed, and a falsy value if not. (Falsy values are false and nil,
--    and truthy values are everything else.) The function takes an article
--    history object as its first parameter.
-- makeData: a function that should return a table of data to be used by other
--    functions in this notice configuration table. It can be accessed using
--    noticeObj:getData().
-- icon: the filename of the notice icon, minus the "File:" prefix.
-- iconCaption: the icon caption.
-- iconSize: The icon size, including "px" suffix. The default is defined in
--    defaultIconSize.
-- iconSmallSize: The icon size if we are outputting a small template. The
--    default is defined in defaultSmallIconSize.
-- text: The notice text. This may be a string or a function. If it is a
--    function, it takes an article history object as the first parameter, and
--    the current collapsible notice object as the second parameter, and should
--    return the text string.
-- categories: The categories set by the notice. This may be an array of
--    category names, or a function. If it is a function, it takes an article
--    history object as the first parameter, and the current collapsible notice
--    object as the second parameter, and should return an array of category
--    objects.
-- noticeBarIcon: the icon to use for the notice bar. This can be a string, or
--    a function, or true. If it is a function it takes an article history
--    object as the first parameter, and should output the icon filename. If it
--    is true, it uses the value of icon. If it is nil then no notice bar icon
--    will be displayed.
-- noticeBarIconCaption: the caption to use for the notice bar icon. This can be
--    a string or a function. If it is a function, it takes an article history
--    object as its first parameter, and should return the caption text. If this
--    is absent, the icon caption is used instead.
-- noticeBarIconSize: the size of the notice bar icon, including "px" suffix.
--    The default is set by defaultNoticeBarIconSize.

collapsibleNotices = {
	-- DYK
	{
		id = 'DYK',
		icon = 'Symbol question.svg',
		aliases = {'BCB'},
		iconCaption = 'Bạn có biết?',
		iconSmallSize = '15px',
		noticeBarIcon = true,
		isActive = function (articleHistoryObj)
			return isActiveDatedObject(articleHistoryObj, 'dyk')
		end,
		makeData = function (articleHistoryObj)
			return makeDateData(articleHistoryObj, 'dyk', {'entry', 'nom'})
		end,
		text = function (articleHistoryObj, collapsibleNoticeObj)
			local data = collapsibleNoticeObj:getData(articleHistoryObj)
			if not data then
				return nil
			end
			for _, t in ipairs(data) do
				local raPage = 'Wikipedia:Recent additions/' ..
					getDate('Y/F#j F Y', t.date)
				if not titleExists(raPage) then
					raPage = 'Wikipedia:Recent additions'
				end
				t.link = raPage
			end
			local fact = 'ý trong bài viết này'
			if data[1].nom then
				fact = '[[' .. data[1].nom .. '|' .. fact .. ']]'
			end
			local blurb = "Một " .. fact .. " đã được đưa lên " ..
				"[[Trang Chính]] Wikipedia tiếng Việt trong mục " ..
				"''\"[[Wikipedia:Bạn có biết|Bạn có biết]]\"'' " ..
				"của tuần từ $1."
			return makeDateText(data, blurb, true)
		end,
		collapsibleText = function (articleHistoryObj, collapsibleNoticeObj)
			local data = collapsibleNoticeObj:getData(articleHistoryObj)
			if not data then
				return nil
			end
			local ctext = {}
			if #data == 1 and data[1].entry then
				ctext[#ctext + 1] = string.format(
					"Nội dung như sau: ''Bạn có biết %s''",
					data[1].entry
				)
			else
				local entries = {}
				local lastEntryDate
				for _, t in ipairs(data) do
					entries[#entries + 1] = t.entry
					lastEntryDate = t.date
				end
				if #entries == 1 then
					ctext[#ctext + 1] = string.format(
						"Nội dung của %s như sau: ''Bạn có biết %s''",
						lastEntryDate, entries[1]
					)
				elseif #entries > 1 then
					ctext[#ctext + 1] = 'Nội dung như sau:\n'
					local list = mw.html.create('ul')
					for _, t in ipairs(data) do
						if t.entry then
							list:tag('li'):wikitext(string.format(
								"%s: ''Bạn có biết %s''",
								t.date, t.entry
							))
						end
					end
					ctext[#ctext + 1] = tostring(list)
				end
			end
			if #ctext > 0 then
				return table.concat(ctext)
			else
				return nil
			end
		end,
		categories = function (articleHistoryObj, collapsibleNoticeObj)
			local cats = {}
			local status = articleHistoryObj:getStatusId()
			local cat
			if status == 'FA' or status == 'BVCL' then
				cat = 'Bài viết chọn lọc mục Bạn có biết'
			elseif status == 'FL' or status == 'DSCL' then
				cat = 'Danh sách chọn lọc mục Bạn có biết'
			elseif status == 'GA' or status == 'FFA/GA' or status == 'BVT' then
				cat = 'Bài viết tốt mục Bạn có biết'
			else
				cat = 'Bài viết mục Bạn có biết'
			end
			cats[1] = Category.new(cat)
			return cats
		end
	},

	-- ITN
	{
		id = 'ITN',
		isActive = function (articleHistoryObj)
			return isActiveDatedObject(articleHistoryObj, 'itn')
		end,
		makeData = function (articleHistoryObj)
			return makeDateData(articleHistoryObj, 'itn', {'link'})
		end,
		icon = 'Globe current.svg',
		iconCaption = 'Tin tức Wikipedia',
		noticeBarIcon = true,
		noticeBarIconSize = '20px',
		text = function (articleHistoryObj, collapsibleNoticeObj)
			local data = collapsibleNoticeObj:getData(articleHistoryObj)
			if not data then
				return nil
			end
			local dates = {}
			for _, t in ipairs(data) do
				local date = {}
				if t.link then
					date.link = t.link
				elseif t.ymdDate >= 20090101 then
					date.link = string.format(
						'Wikipedia:ITN archives/%d/%s',
						t.year,
						t.month
					)
				elseif t.ymdDate >= 20050101 then
					date.link = string.format(
						'Portal:Current events/%d %s %d',
						t.year,
						t.month,
						t.day
					)
				end
				date.date = t.date
				dates[#dates + 1] = date
			end
			local intro
			if #data > 1 then
				intro = 'Nhiều tin tức trong bài này'
			else
				intro = 'Một tin tức trong bài này'
			end
			local blurb = intro ..
				" đã xuất hiện trên [[Trang Chính]] Wikipedia trong mục " ..
				"''\"[[Bản mẫu:Tin tức|Tin tức]]\"'' vào $1."
			return makeDateText(dates, blurb)
		end,
		categories = function (articleHistoryObj, collapsibleNoticeObj)
			local cats = {}
			cats[1] = Category.new('Bài viết mục Tin tức Wikipedia')
			return cats
		end
	},

	-- On This Day
	{
		id = 'OTD',
		aliases = {'NNNX'},
		isActive = function (articleHistoryObj)
			return isActiveDatedObject(articleHistoryObj, 'otd')
		end,
		makeData = function (articleHistoryObj)
			return makeDateData(articleHistoryObj, 'otd', {'link', 'oldid'})
			-- TODO: remove 'link' after it is no longer needed for tracking
		end,
		icon = 'Nuvola apps date.svg',
		iconCaption = 'Ngày này năm xưa',
		noticeBarIcon = true,
		noticeBarIconSize = '20px',
		text = function (articleHistoryObj, collapsibleNoticeObj)
			local data = collapsibleNoticeObj:getData(articleHistoryObj)
			if not data then
				return nil
			end
			local dates = {}
			for _, t in ipairs(data) do
				local date = {}
				date.date = t.date
				date.link = t.link
				if t.oldid then
					-- TODO: Move this inside the main module
					local oldid = tonumber(t.oldid)
					if oldid and
						math.floor(oldid) == oldid and
						oldid > 0 and
						oldid < math.huge
					then
						-- If the oldid is valid, it takes precedence over
						-- explicit links.
						date.link = 'Special:PermaLink/' .. t.oldid
					else
						collapsibleNoticeObj:addWarning(
							string.format(
								"invalid oldid '%s' detected in parameter '%s'; " ..
									"if an oldid is specified it must be a positive integer",
								t.oldid,
								t.argPrefix .. 'oldid'
							),
							'Bản mẫu:Lịch sử bài viết#Invalid oldid'
						)
					end
				end
				dates[#dates + 1] = date
			end
			local intro
			if #data > 1 then
				intro = 'Nhiều sự kiện có trong bài viết này'
			else
				intro = 'Một sự kiện có trong bài viết này'
			end
			local blurb = intro ..
				"  đã xuất hiện trên [[Trang Chính]] trong mục " ..
				"''\"[[Wikipedia:Ngày này năm xưa|Ngày này năm xưa]]\"'' " ..
				"vào ngày $1."
			return makeDateText(dates, blurb)
		end,
		categories = function (articleHistoryObj, collapsibleNoticeObj)
			local cats = {}
			cats[1] = Category.new('Bài viết mục Ngày này năm xưa')
			local data = collapsibleNoticeObj:getData(articleHistoryObj)
			if data then
				for _, t in ipairs(data) do
					if t.link then
						cats[#cats + 1] = Category.new(
							'Article history templates with linked otd dates'
						)
						break
					end
				end
			end
			return cats
		end
	},

	-- Article Collaboration and Improvement Drive
	{
		id = 'ACID',
		isActive = function (articleHistoryObj)
			return articleHistoryObj.args.aciddate
		end,
		icon = 'Article Collaboration and Improvement Drive.svg',
		iconCaption = 'Article Collaboration and Improvement Drive',
		noticeBarIcon = true,
		noticeBarIconSize = '20px',
		text = function (articleHistoryObj)
			local args = articleHistoryObj.args
			local blurb = 'This article was on the ' ..
				'[[WP:ACID|Article Collaboration and Improvement Drive]] ' ..
				'for the week of %s.'
			local date = validateDate('aciddate', args.aciddate)
			return string.format(blurb, date)
		end
	},

	-- League of Copy Editors
	{
		id = 'LOCE',
		isActive = function (articleHistoryObj)
			return articleHistoryObj.args.loceNotAnActiveOption
		end,
		icon = 'LoCiconRevised.png',
		iconCaption = 'League of Copyeditors',
		iconSize = '25px',
		noticeBarIcon = true,
		text = 'Bài viết này, hay một phần của bài, được [[WP:GOCE|các thành viên trong Hiệp hội biên tập bản sao]] ' ..
			'điều chỉnh về mặt văn phong, ngữ pháp và định dạng nhằm đáp ứng đầy đủ [[WP:CNBS|tiêu chuẩn Wikipedia]].'
	}
},

-------------------------------------------------------------------------------
-- Notice bar icons
-------------------------------------------------------------------------------

-- This table holds configuration tables for notice bar icons that don't appear
-- as part of a row. Other notice bar icons are handled in the statuses,
-- notices, actions, and collapsibleNotices tables.
-- It accepts the following fields:
-- isActive: a function that should return a truthy value if the notice should
--    be displayed, and a falsy value if not. (Falsy values are false and nil,
--    and truthy values are everything else.) The function takes an article
--    history object as its first parameter.
-- icon: the filename of the notice bar icon, minus the "File:" prefix.

noticeBarIcons = {
	-- Peer review, or NA status
	{
		isActive = function (articleHistoryObj)
			local status = articleHistoryObj:getStatusId()
			-- @XXX: This is what the template does, but we should take into
			-- account peer review actions as well.
			return not status or status == 'PR' or status == 'NA'
		end,
		icon = 'Nuvola apps kedit.svg'
	},

	-- Wikipedia 1.0
	{
		isActive = function (articleHistoryObj)
			return articleHistoryObj.args['v1.0NotAnActiveOption']
		end,
		icon = 'WP1 0 Icon.svg'
	}
},

-------------------------------------------------------------------------------
-- Extra categories
-------------------------------------------------------------------------------

-- This table contains categories that don't appear as part of a row. It is an
-- array of functions; each function takes an article history object as input
-- and must return an array of category objects as output.

extraCategories = {
	-- Four award
	function (articleHistoryObj)
		local yesno = require('Module:Yesno')
		local ret = {}
		local isFour = yesno(articleHistoryObj.args.four)
		if isFour then
			ret[#ret + 1] = Category.new('Wikipedia four award articles')
		elseif isFour == false then
			ret[#ret + 1] = Category.new('Wikipedia articles rejected for Four awards')
		elseif articleHistoryObj:getStatusId() == 'FA' then
			local isDYK = false
			for _, obj in ipairs(articleHistoryObj:getCollapsibleNoticeObjects()) do
				if obj.id == 'DYK' then
					isDYK = true
					break
				end
			end
			if isDYK then
				for _, obj in ipairs(articleHistoryObj:getActionObjects()) do
					if obj.id == 'GAN' and obj.resultId == 'listed' then
						ret[#ret + 1] = Category.new('Possible Wikipedia four award articles')
						break
					end
				end
			end
		end
		return ret
	end,

	-- Deletion to Quality award
	function (articleHistoryObj)
		local ret = {}
		local status = articleHistoryObj:getStatusId()
		if status == 'FA' or status == 'FL' or status == 'GA' or status == 'BVCL' or status == 'DSCL' or status == 'BVT' then
			local iAfd = 0
			local hasAfd = false
			local actionObjects = articleHistoryObj:getActionObjects()
			for i, obj in ipairs(actionObjects) do
				if obj.id == 'AFD' then
					iAfd = i
					hasAfd = true
					break
				end
			end
			if hasAfd then
				local function hasNomination(id, result)
					for i = iAfd + 1, #actionObjects do
						local obj = actionObjects[i]
						if obj.id == id and obj.resultId == result then
							return true
						end
					end
					return false
				end
				if status == 'GA' and hasNomination('GAN', 'listed') or
					status == 'FL' and hasNomination('FLC', 'promoted') or
					status == 'FA' and hasNomination('FAC', 'promoted')
				then
					ret[#ret + 1] = Category.new('Deletion to Quality Award candidates')
				end
			end
		end
		return ret
	end,

	-- Track small banners
	function (articleHistoryObj)
		local ret = {}
		if articleHistoryObj.isSmall then
			table.insert(ret, Category.new('Small article history templates'))
		end
		return ret
	end,
},

-------------------------------------------------------------------------------
-- Parameters
-------------------------------------------------------------------------------

-- The parameter values used to generate the page actions. These are used as
-- Lua patterns, so any of the magic characters *+-.^$%[] should be escaped
-- with a preceding % symbol.
actionParamPrefix = 'action',
actionParamSuffixes = {
	[''] = 'code',
	date = 'date',
	link = 'link',
	result = 'resultCode',
	oldid = 'oldid'
},

-- The parameter used to set the current status.
currentStatusParam = 'currentstatus',

-------------------------------------------------------------------------------
-- Other settings
-------------------------------------------------------------------------------

-- If this number or fewer of collapsible rows are present (including actions
-- and collapsible notices) they will not be collapsed. If this is set to the
-- string "all", all rows will always be visible. Otherwise, the input must be
-- a number. The default is three rows.
uncollapsedRows = 3,

-- The default size for icons. The default is 30px.
defaultIconSize = '30px',

-- The default size for icons for small templates. The default is 15px.
defaultSmallIconSize = '15px',

-- The default size for status icons. The default is 50px.
defaultStatusIconSize = '50px',

-- The default size for status icons for small templates. The default is 30px.
defaultSmallStatusIconSize = '30px',

-- The default size for notice bar icons. The default is 15px.
defaultNoticeBarIconSize = '15px',

-- The default size for collapsible status icons. The default is 50px.
defaultCollapsibleNoticeIconSize = '20px',

-- The default size for collapsible status icons for small templates. The
-- default is 30px.
defaultSmallCollapsibleNoticeIconSize = '20px',

-------------------------------------------------------------------------------
-- Messages
-------------------------------------------------------------------------------

msg = {

-- The heading for the collapsible table of actions if we are in the main
-- namespace or the talk namespace.
['milestones-header'] = 'Cột mốc của bài viết',

-- The heading for the collapsible table of actions if we are in a different
-- namespace.
-- $1 - the subject namespace name.
['milestones-header-other-ns'] = 'Cột mốc của $1',

-- The milestones date header.
['milestones-date-header'] = 'Ngày',

-- The milestones process header.
['milestones-process-header'] = 'Quá trình',

-- The milestones result header.
['milestones-result-header'] = 'Kết quả',

-- The format to display the action dates in. The syntax is the same as the
-- #time parser function.
['action-date-format'] = 'j F, Y',

-- The category to use if any errors are detected.
['error-category'] = 'Article history templates with errors',

-- Define boilerplate text for error messages and warnings, both with and
-- without help links.
-- $1 - the error message
-- $2 - a link to a help page and section for the error
['error-message-help'] = 'Lỗi: $1 ([[$2|trợ giúp]]).',
['error-message-nohelp'] = 'Lỗi: $1.',
['warning-help'] = 'Cảnh báo: $1 ([[$2|trợ giúp]]).',
['warning-nohelp'] = 'Cảnh báo: $1.',

-- Error for row objects that should output notice bar icons but for which no
-- icon values could be found.
['row-error-missing-icon'] = "notice bar icon config set to 'true' but no " ..
	'image could be found',

-- A help link for row-error-missing-icon
['row-error-missing-icon-help'] = 'Bản mẫu:Lịch sử bài viết#Missing icon',

-- Error for action objects that aren't passed a code.
-- $1 - the parameter name for the code
['action-error-no-code'] = "no action code found in the '$1' parameter; " ..
	"please add a code or remove other parameters starting with '$1'",

-- A help link for action-error-no-code
['action-error-no-code-help'] = 'Bản mẫu:Lịch sử bài viết#Action codes',

-- Error for action objects that are passed an invalid code.
-- $1 - the code that the user input
-- $2 - the parameter name for the code
['action-error-invalid-code'] = "invalid action code '$1' passed to the '$2' parameter",

-- A help link for action-error-invalid-code
['action-error-invalid-code-help'] = 'Bản mẫu:Lịch sử bài viết#Action codes',

-- Error for action objects with blank result parameters, where result
-- parameters are required for the action's ID.
-- $1 - the action ID
-- $2 - the result parameter name
['action-error-blank-result'] = "the '$1' action requires a result code; " ..
	"please add a result code to parameter '$2'",

-- A help link for action-error-blank-result
['action-error-blank-result-help'] = 'Bản mẫu:Lịch sử bài viết#Action results',

-- Error for action objects with invalid result parameters.
-- $1 - the result code that the user input
-- $2 - the action ID
-- $3 - the result parameter name
['action-error-invalid-result'] = "invalid result '$1' for action '$2' " ..
	"detected in parameter '$3'",

-- A help link for action-error-invalid-result
['action-error-invalid-result-help'] = 'Bản mẫu:Lịch sử bài viết#Action results',

-- Warning for action objects with invalid dates.
-- $1 - the date input by the user
-- $2 - the date parameter name
['action-warning-invalid-date'] = "invalid date '$1' detected in parameter '$2'",

-- A help link for action-warning-invalid-date
['action-warning-invalid-date-help'] = 'Bản mẫu:Lịch sử bài viết#Invalid date',

-- Error for action objects with no dates.
-- $1 - the parameter number
-- $2 - the date parameter name
-- $3 - the action parameter name
['action-warning-no-date'] = "no date specified for action $1; " ..
	"please add a date to parameter '$2' or remove the other parameters " ..
	"beginning with '$3'",

-- A help link for action-warning-no-date
['action-warning-no-date-help'] = 'Bản mẫu:Lịch sử bài viết#No date',

-- The text to display in place of the action date if it is missing.
['action-date-missing'] = '?',

-- Error for action objects with invalid oldids.
-- $1 - the oldid input by the user
-- $2 - the oldid parameter name
['action-warning-invalid-oldid'] = "invalid oldid '$1' detected in parameter '$2'; " ..
	"if an oldid is specified it must be a positive integer",

-- A help link for action-warning-invalid-oldid
['action-warning-invalid-oldid-help'] = 'Bản mẫu:Lịch sử bài viết#Invalid oldid',

-- Error for invalid current status codes.
-- $1 - the code input by the user
['articlehistory-warning-invalid-status'] = "'$1' is not a valid status code",

-- A help link for articlehistory-warning-invalid-status
['articlehistory-warning-invalid-status-help'] = 'Bản mẫu:Lịch sử bài viết#Invalid status',

-- Warning for invocations that specify a current status without specifying any
-- actions.
['articlehistory-warning-status-no-actions'] = "a current status was supplied " ..
	'without any actions',

-- A help link for articlehistory-warning-status-no-actions
['articlehistory-warning-status-no-actions-help'] = 'Bản mẫu:Lịch sử bài viết#No actions',

-- The text to display the current status at the bottom of the collapsible
-- table.
-- $1 - the current status name
['status-blurb'] = "Trạng thái hiện tại: '''$1'''",

-- The text to display at the bottom of the collapsible table if the current
-- status is unknown.
['status-unknown'] = '?',

}

-------------------------------------------------------------------------------
--                              CONFIG TABLE END
-------------------------------------------------------------------------------

}