模块:Phrases

来自「荏苒之境」
Sicusa留言 | 贡献2025年8月23日 (六) 16:48的版本

此模块的文档可以在模块:Phrases/doc创建

local translation = require("Module:Template translation")
local cargo = mw.ext.cargo

local phrases = {}

phrases.show = function(frame)
	local table_name = frame.args.table
	local theme = frame.args.theme
	
	local parent_frame = frame:getParent()
	local language = translation.getTitleLanguage(parent_frame:getTitle())
	if language == nil or language == "" then
		language = "zh-cn"
	end
	
	local t = {"<ul>"}
	for _, phrase in ipairs(parent_frame.args) do
		cargo.store(table_name, {
			Language = language,
			Phrase = phrase,
			Theme = theme
		})
		t[#t+1] = "<li>"
		t[#t+1] = frame:preprocess(phrase)
		t[#t+1] = "</li>"
	end
	
	t[#t+1] = "</ul>"
	return table.concat(t)
end

return phrases