模块:Phrases:修订间差异

来自「荏苒之境」
无编辑摘要
无编辑摘要
 
(未显示同一用户的27个中间版本)
第1行: 第1行:
local translation = require("Module:Template translation")
local translation = require("Module:Template translation")
local utils_str = require("Module:Utils/String")
local cargo = mw.ext.cargo
local cargo = mw.ext.cargo
local escape_sql = utils_str.escape_sql
local trim = utils_str.trim
local PHRASE_THEMES_TABLE = "PhraseThemes"


local phrases = {}
local phrases = {}


phrases.show = function(frame)
phrases.show = function(frame)
local table_name = frame.args.table
local args = frame.args
local theme = frame.args.theme
local table_name = escape_sql(args.table)
local theme_text = args.theme_text
if theme_text == "" then theme_text = nil end
local parent_frame = frame:getParent()
local parent_frame = frame:getParent()
local theme = escape_sql(trim(parent_frame.args[1]))
local language = translation.getCurrentLanguageSubpage()
local language = translation.getCurrentLanguageSubpage()
if language == nil or language == "" then
if language ~= "zh-cn" then
language = "zh-cn"
if language == nil or language == "" then
end
language = "zh-cn"
end
cargo.store("PhraseThemes", {
PhraseTable = table_name,
cargo.store(PHRASE_THEMES_TABLE, {
Theme = theme
PhraseTable = table_name,
})
Theme = theme,
local t = {"<p>", theme, ":</p><ul>"}
for _, phrase in ipairs(parent_frame.args) do
cargo.store(table_name, {
Language = language,
Language = language,
Phrase = phrase,
Translation = theme_text
Theme = theme
})
})
t[#t+1] = "<li>"
t[#t+1] = frame:preprocess(phrase)
for i, phrase in ipairs(parent_frame.args) do
t[#t+1] = "</li>"
if i ~= 1 then
cargo.store(table_name, {
Language = language,
Phrase = escape_sql(trim(phrase)),
Theme = theme,
Time = os.time()
})
end
end
end
end
local t = {}
t[#t+1] = "<ul>"
for i, phrase in ipairs(parent_frame.args) do
if i ~= 1 then
t[#t+1] = "<li>"
t[#t+1] = frame:preprocess(phrase)
t[#t+1] = "</li>"
end
end
t[#t+1] = "</ul>"
t[#t+1] = "</ul>"
return table.concat(t)
return table.concat(t)

2025年8月24日 (日) 01:48的最新版本

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

local translation = require("Module:Template translation")
local utils_str = require("Module:Utils/String")

local cargo = mw.ext.cargo
local escape_sql = utils_str.escape_sql
local trim = utils_str.trim

local PHRASE_THEMES_TABLE = "PhraseThemes"

local phrases = {}

phrases.show = function(frame)
	local args = frame.args
	local table_name = escape_sql(args.table)
	
	local theme_text = args.theme_text
	if theme_text == "" then theme_text = nil end
	
	local parent_frame = frame:getParent()
	local theme = escape_sql(trim(parent_frame.args[1]))
	
	local language = translation.getCurrentLanguageSubpage()
	if language ~= "zh-cn" then
		if language == nil or language == "" then
			language = "zh-cn"
		end
		
		cargo.store(PHRASE_THEMES_TABLE, {
			PhraseTable = table_name,
			Theme = theme,
			Language = language,
			Translation = theme_text
		})
		
		for i, phrase in ipairs(parent_frame.args) do
			if i ~= 1 then
				cargo.store(table_name, {
					Language = language,
					Phrase = escape_sql(trim(phrase)),
					Theme = theme,
					Time = os.time()
				})
			end
		end
	end
	
	local t = {}
	t[#t+1] = "<ul>"
	for i, phrase in ipairs(parent_frame.args) do
		if i ~= 1 then
			t[#t+1] = "<li>"
			t[#t+1] = frame:preprocess(phrase)
			t[#t+1] = "</li>"
		end
	end
	t[#t+1] = "</ul>"
	return table.concat(t)
end

return phrases