跳转到内容

Module:首页分类:修订间差异

来自陋室
删除的内容 添加的内容
Maintenance script​(留言 | 贡献)
创建首页分类气泡模块
 
Maintenance script​(留言 | 贡献)
Support English UI language on homepage category bubbles
 
(未显示同一用户的2个中间版本)
第2行: 第2行:


local categories = {
local categories = {
⚫
{
{ title = '云计算与大数据', label = '云计算与大数据' },
title = '云计算与大数据',
⚫
{ title = 'Python 后端开发', label = 'Python 后端开发' },
label = {
⚫
{ title = 'Java 后端开发', label = 'Java 后端开发' },
zh = '云计算与大数据',
⚫
{ title = '软件测试', label = '软件测试' },
en = 'Cloud Computing & Big Data',
⚫
{ title = 'Web 前端开发', label = 'Web 前端开发' },
},
⚫
{ title = '物联网应用技术', label = '物联网应用技术' },
},
⚫
{ title = 'AIGC', label = 'AIGC' },
{
⚫
{ title = '通信技术', label = '通信技术' },
⚫
title = 'Python 后端开发',
label = {
zh = 'Python 后端开发',
en = 'Python Backend Development',
},
},
{
⚫
title = 'Java 后端开发',
label = {
zh = 'Java 后端开发',
en = 'Java Backend Development',
},
},
{
⚫
title = '软件测试',
label = {
zh = '软件测试',
en = 'Software Testing',
},
},
{
⚫
title = 'Web 前端开发',
label = {
zh = 'Web 前端开发',
en = 'Web Frontend Development',
},
},
{
⚫
title = '物联网应用技术',
label = {
zh = '物联网应用技术',
en = 'IoT Application Technology',
},
},
{
⚫
title = 'AIGC',
label = {
zh = 'AIGC',
en = 'AIGC',
},
},
{
⚫
title = '通信技术',
label = {
zh = '通信技术',
en = 'Communication Technology',
},
},
}
}


function p.bubbles()
local function getLang( frame )
local output = {
local title = mw.title.getCurrentTitle()

⚫
'<div class="mw-mainpage-link-cloud" data-source="Module:首页分类">'
if title and title.subpageText == 'en' then
⚫
}
return 'en'
end

local interfaceLang = frame:preprocess( '{{int:lang}}' )
if interfaceLang == 'en' then
return 'en'
end

return 'zh'
end

function p.bubbles( frame )
local lang = getLang( frame )
local links = {}


for _, category in ipairs( categories ) do
for _, category in ipairs( categories ) do
output[#output + 1] = string.format(
links[#links + 1] = string.format(
'[[:Category:%s|%s]]',
'[[:Category:%s|%s]]',
category.title,
category.title,
category.label
category.label[lang] or category.label.zh
)
)
end
end


⚫
return '<div class="mw-mainpage-link-cloud" data-source="Module:首页分类">' ..
output[#output + 1] = '</div>'
return table.concat( output, '\n' )
table.concat( links, ' ' ) ..
'</div>'
end
end



2026年7月17日 (五) 09:15的最新版本

此模块的文档可以在Module:首页分类/doc创建

local p = {}

local categories = {
	{
		title = '云计算与大数据',
		label = {
			zh = '云计算与大数据',
			en = 'Cloud Computing & Big Data',
		},
	},
	{
		title = 'Python 后端开发',
		label = {
			zh = 'Python 后端开发',
			en = 'Python Backend Development',
		},
	},
	{
		title = 'Java 后端开发',
		label = {
			zh = 'Java 后端开发',
			en = 'Java Backend Development',
		},
	},
	{
		title = '软件测试',
		label = {
			zh = '软件测试',
			en = 'Software Testing',
		},
	},
	{
		title = 'Web 前端开发',
		label = {
			zh = 'Web 前端开发',
			en = 'Web Frontend Development',
		},
	},
	{
		title = '物联网应用技术',
		label = {
			zh = '物联网应用技术',
			en = 'IoT Application Technology',
		},
	},
	{
		title = 'AIGC',
		label = {
			zh = 'AIGC',
			en = 'AIGC',
		},
	},
	{
		title = '通信技术',
		label = {
			zh = '通信技术',
			en = 'Communication Technology',
		},
	},
}

local function getLang( frame )
	local title = mw.title.getCurrentTitle()

	if title and title.subpageText == 'en' then
		return 'en'
	end

	local interfaceLang = frame:preprocess( '{{int:lang}}' )
	if interfaceLang == 'en' then
		return 'en'
	end

	return 'zh'
end

function p.bubbles( frame )
	local lang = getLang( frame )
	local links = {}

	for _, category in ipairs( categories ) do
		links[#links + 1] = string.format(
			'[[:Category:%s|%s]]',
			category.title,
			category.label[lang] or category.label.zh
		)
	end

	return '<div class="mw-mainpage-link-cloud" data-source="Module:首页分类">' ..
		table.concat( links, ' ' ) ..
		'</div>'
end

return p