Mô đun:Về-phân biệt

local mHatnote = require('Mô đun:Hatnote')
local mHatlist = require('Mô đun:Hatnote list')
local mArguments --initialize lazily
local mTableTools = require('Mô đun:TableTools')
local checkType = require('libraryUtil').checkType
local p = {}

function p.aboutDistinguish (frame)
	mArguments = require('Mô đun:Arguments')
	local args = mArguments.getArgs(frame)
	return p._aboutDistinguish(args)
end

function p._aboutDistinguish(args, options)
	-- Type checks and defaults
	checkType('_aboutDistinguish', 1, args, 'table')
	if not args[1] then
		return mHatnote.makeWikitextError(
			'không có chủ đề được nói tới nào được cung cấp',
			'Bản mẫu:Về-phân biệt',
			args.category
		)
	end
	if not args[2] then
		return mHatnote.makeWikitextError(
			'không có trang cần phân biệt nào được cung cấp',
			'Bản mẫu:Về-phân biệt',
			args.category
		)
	end
	checkType('_aboutDistinguish', 2, options, 'table', true)
	options = options or {}
	local defaultOptions = {
		defaultPageType = 'Trang',
		namespace = mw.title.getCurrentTitle().namespace,
		pageTypesByNamespace = {
			[0] = 'Bài',
			[14] = 'Thể loại'
		},
		sectionString = 'đoạn'
	}
	for k, v in pairs(defaultOptions) do
		if options[k] == nil then options[k] = v end
	end

	-- Set pieces of initial "about" string
	local pageType = (args.section and options.sectionString) or
		options.pageTypesByNamespace[options.namespace] or
		options.defaultPageType
	args = mTableTools.compressSparseArray(args)
	local about = table.remove(args, 1)

	--Get pronoun from Wikidata. Really basic, but it should work.
	local pronouns = {
		['female'] = 'Cô ấy',
		['transgender female'] = "Cô ấy",
		['male'] = 'Anh ấy',
		['transgender male'] = 'Anh ấy',
		['default'] = 'Họ'
	}
	local wde = mw.wikibase.getEntity()
	local p31 = (wde and wde:formatPropertyValues('P31').value) == 'human'
	local p21 = wde and wde:formatPropertyValues('P21').value
	local pronoun = p31 and (pronouns[p21] or pronouns['default']) or 'Nó'

	--Assemble everything together and return
	local text = string.format(
		'%s này nói về %s. %s không nên bị nhầm lẫn với %s.',
		pageType,
		about,
		pronoun,
		mHatlist.orList(args, true)
	)
	return mHatnote._hatnote(text)
end

return p
Chúng tôi bán
Bài viết liên quan
Download Game Dream League Soccer 2020
Download Game Dream League Soccer 2020
Dream League Soccer 2020 là phiên bản mới nhất của dòng game bóng đá nổi tiếng Dream League Soccer
Giới thiệu AG Mega Armor Mel - Giant Gospel Cannon
Giới thiệu AG Mega Armor Mel - Giant Gospel Cannon
Nhìn chung Mel bộ kỹ năng phù hợp trong những trận PVP với đội hình Cleaver, khả năng tạo shield
Kishou Arima: White Reaper trong Tokyo Ghoul
Kishou Arima: White Reaper trong Tokyo Ghoul
Kishou Arima (有馬 貴将, Arima Kishō) là một Điều tra viên Ngạ quỷ Cấp đặc biệt nổi tiếng với biệt danh Thần chết của CCG (CCGの死神, Shīshījī no Shinigami)
Phân loại kĩ năng trong Tensura - Tensei shitara Slime Datta Ken
Phân loại kĩ năng trong Tensura - Tensei shitara Slime Datta Ken
Trên đời này không có gì là tuyệt đối cả, nhất là với mấy cái kĩ năng có chữ "tuyệt đối" trong tên, càng tin vào "tuyệt đối", càng dễ hẹo