FANDOM


-- 中英文名称转换模块
 
local p = {}
 
local dictionary = mw.loadData('Module:UserDict')
--local InGameGlossaryRule = mw.loadData('Module:Translate/ingamerule')
 
-- 单个词语转换
function p.ToChinese(frame)
	local src = frame.args[1]
	return dictionary.Text[src] or src
end
 
-- 反向转换
function p.ToEnglish(frame)
	local src = frame.args[1]
	return dictionary.i.text[src] or src
end
 
function p.toEnglish(src)
	if type(src) ~= 'string' then
		return src
	end
	return dictionary.i.text[src] or src
end
 
-- 单个词语转换(不分大小写)
function p.ToChineseCI(frame)
	local src = frame.args[1]
	local lcsrc = string.lower(src)
	return dictionary.lc.text[lcsrc] or src
end
 
function p.toChineseCI(src)
	if type(src) ~= 'string' then
		return src
	end
	local lcsrc = string.lower(src)
	return dictionary.lc.text[lcsrc] or src
end
 
-- 转换分类名(不分大小写)
function p.ToChineseCat(frame)
	local src = frame.args[1]
	local lcsrc = string.lower(src)
	return dictionary.lc.category[lcsrc] or dictionary.lc.text[lcsrc] or src
end
 
function p.toChineseCat(src)
	if type(src) ~= 'string' then
		return src
	end
	local lcsrc = string.lower(src)
	return dictionary.lc.category[lcsrc] or dictionary.lc.text[lcsrc] or src
end
 
-- 显示全列表
function p.ShowWordlist()
	local wikitable = {};
	table.insert(wikitable, "{| class=\"wikitable sortable filterable\"")
	table.insert(wikitable, '|+ style="text-align:center;font-size:20px;" | 词汇表')
	table.insert(wikitable, '! class="filterable-head" | 英文 ')
	table.insert(wikitable, '! class="filterable-head" | 中文 ')
	table.insert(wikitable, "|-")
	for k,v in pairs(dictionary["Text"]) do
		table.insert(wikitable, "| "..k)
		table.insert(wikitable, "| "..v)
		table.insert(wikitable, "|-")
	end
	table.insert(wikitable,"|}")
	return table.concat(wikitable,"\n")
end
 
function p.ShowCategorylist()
	local wikitable = {};
	table.insert(wikitable, "{| class=\"wikitable sortable filterable\"")
	table.insert(wikitable, '|+ style="text-align:center;font-size:20px;" | 分类表')
	table.insert(wikitable, '! class="filterable-head" | 英文 ')
	table.insert(wikitable, '! class="filterable-head" | 中文 ')
	table.insert(wikitable, "|-")
	for k,v in pairs(dictionary["Category"]) do
		table.insert(wikitable, "| "..k)
		table.insert(wikitable, "| "..v)
		table.insert(wikitable, "|-")
	end
	table.insert(wikitable,"|}")
	return table.concat(wikitable,"\n")
end
 
function p.showInGameGlossary()
	local wikitable = {};
	table.insert(wikitable, "{| class=\"wikitable\"")
	table.insert(wikitable, '|+ style="text-align:center;font-size:20px;" | 词汇表')
	table.insert(wikitable, '! class="filterable-head" | en ')
	table.insert(wikitable, '! class="filterable-head" | zh ')
	table.insert(wikitable, "|-")
	for k,v in pairs(dictionary["Text"]) do
		table.insert(wikitable, "| "..k)
		table.insert(wikitable, "| "..applyInGameGlossaryRule(v))
		table.insert(wikitable, "|-")
	end
	table.insert(wikitable,"|}")
	return table.concat(wikitable,"\n")
end
 
function applyInGameGlossaryRule(word)
    return nil
--	for i,v in ipairs(InGameGlossaryRule) do
-- 			result = mw.ustring.gsub(result, v[2], v[3])
--	end
--	return result
end
 
return p
除非特別說明,社區內容使用CC-BY-SA 授權許可。