跳转到内容

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

来自陋室
删除的内容 添加的内容
Maintenance script​(留言 | 贡献)
为首页分类气泡增加英文标签
Maintenance script​(留言 | 贡献)
Support English UI language on homepage category bubbles
 
第60行: 第60行:
}
}


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


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

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


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



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