モジュール:ConvToTalk
表示
モジュールの解説[作成]
local p = {}
--Define function to split strings
function Split(s, delimiter)
result = {};
for match in (s..delimiter):gmatch("(.-)"..delimiter) do
table.insert(result, match);
end
return result;
end
--Main template funciton
function p.Main( frame )
local pagename = frame.args['1']
local str = Split(pagename, ":")
local namespace = ""
if str[1] == "利用者" or str[1] == "利用者‐会話" or str[1] == "User" or str[1] == "User talk" then
namespace = "利用者‐会話"
elseif str[1] == "Wikipedia" or str[1] == "Wikipedia‐ノート" or str[1] == "Wikipedia talk" then
namespace = "Wikipedia‐ノート"
elseif str[1] == "WP" or str[1] == "WT" then
namespace = "WT"
elseif str[1] == "ファイル" or str[1] == "ファイル‐ノート" or str[1] == "File" or str[1] == "File talk" then
namespace = "ファイル‐ノート"
elseif str[1] == "MediaWiki" or str[1] == "MediaWiki‐ノート" or str[1] == "MediaWiki talk" then
namespace = "MediaWiki‐ノート"
elseif str[1] == "Template" or str[1] == "Template‐ノート" or str[1] == "Template talk" then
namespace = "Template‐ノート"
elseif str[1] == "Help" or str[1] == "Help‐ノート" or str[1] == "Help talk" then
namespace = "Help‐ノート"
elseif str[1] == "Category" or str[1] == "Category‐ノート" or str[1] == "Category talk" then
namespace = "Category‐ノート"
elseif str[1] == "Portal" or str[1] == "Portal‐ノート" or str[1] == "Portal talk" then
namespace = "Portal‐ノート"
elseif str[1] == "プロジェクト" or str[1] == "プロジェクト‐ノート" then
namespace = "プロジェクト‐ノート"
elseif str[1] == "モジュール" or str[1] == "モジュール‐ノート" or str[1] == "Module" or str[1] == "Module talk" then
namespace = "モジュール‐ノート"
elseif str[1] == "Gadget" or str[1] == "Gadget talk" then
namespace = "Gadget talk"
elseif str[1] == "Gadget definition" or str[1] == "Gadget definition talk" then
namespace = "Gadget definition talk"
else
namespace = "ノート"
end
pagename = pagename:gsub(str[1]..":", "") -- get the value of parameter 1 following the namespace-separating colon
return namespace .. ":" .. pagename
end
return p