モジュール:Navseasoncats/sandbox

requirestrict
local p = {}
local horizontal = require('Module:List').horizontal
-- Note:日本語化の作業に当たっての注意点
--		数字横のハイフン除去："Straight-8", "1970s-related"のハイフンは不要
--		BC, ADの表記：紀元前は"1000 BC", 後は"AD 1000"と紀元前の書式が和英で逆
--		「年」等の表記：英語表記 "1999"には単位がない。必要箇所に追加する
-- Todo:追跡用カテゴリ名定義 (Globals)や、各コメントを和訳
--		未対応のファンクションを更新
--======================================================================**
--                     グローバル変数  Globals                              
--======================================================================**
local currtitle = mw.title.getCurrentTitle()
local nexistingcats = 0
local errors = 
local testcasecolon = 
local testcases = string.match(currtitle.subpageText, '^testcases')
if    testcases then testcasecolon = ':' end
local navborder = true
local followRs = true
local skipgaps = false
local listall = false
local tlistall = {}
local tlistallbwd = {}
local tlistallfwd = {}
local ttrackingcats = { --when reindexing, Ctrl+H 'trackcat(13,' & 'ttrackingcats16'
	, -- 1 placeholder for 
	, -- 2 placeholder for 
	, -- 3 placeholder for 
	, -- 4 placeholder for 
	, -- 5 placeholder for 
	, -- 6 placeholder for 
	, -- 7 placeholder for  --new
	, -- 8 placeholder for 
	, -- 9 placeholder for 
	, --10 placeholder for 
	, --11 placeholder for 
	, --12 placeholder for 
	, --13 placeholder for 
	, --14 placeholder for 
	, --15 placeholder for 
	, --16 placeholder for 
	, --17 placeholder for 
	, --18 placeholder for 
	, --19 placeholder for 
	, --20 placeholder for 
	, --21 placeholder for 
	, --22 placeholder for 
	, --23 placeholder for 
	, --24 placeholder for 
	, --25 placeholder for 
	, --26 placeholder for 
	, --27 placeholder for 
	, --28 placeholder for 
	, --29 placeholder for 
	, --30 placeholder for 
	, --31 placeholder for 
}
local avoidself =  (not string.match(currtitle.text, 'Navseasoncats with') and
					not string.match(currtitle.text, 'Navseasoncats.*/doc') and
					not string.match(currtitle.text, 'Navseasoncats.*/sandbox') and
					currtitle.text ~= 'Navseasoncats' and
					currtitle.nsText ~= 'User_talk' and
					currtitle.nsText ~= 'Template_talk' and
					(currtitle.nsText ~= 'Template' or testcases)) --avoid nested transclusion errors (i.e. )
--======================================================================**
--   ユーティリティ関数・カテゴリ系の関数   Utility & category functions    
--======================================================================**
--Determine if a category exists (in a function for easier localization).
local function catexists( title )
	return mw.title.new( title, 'Category' ).exists
end
--Error message handling.
function p.errorclass( msg )
	return mw.text.tag( 'span', {class='error mw-ext-cite-error'}, 'Error! '..string.gsub(msg, '&#', '&#') )
end
--Failure handling.
function p.failedcat( errors, sortkey )
	if avoidself then
		return (errors or )..'***Navseasoncats failed to generate navbox***'..
			   ..(sortkey or 'O')..'\n'
	end
	return 
end
--Tracking cat handling. -- 追跡用カテゴリの出力
--	key: 15 (when reindexing ttrackingcats{}, Ctrl+H 'trackcat(13,' & 'ttrackingcats16')
--	cat: 'Navseasoncats isolated';  to remove
--Used by main, all nav_*(), & several utility functions.
local function trackcat( key, cat )
	if avoidself and key and cat then
		if cat ~=  then
			ttrackingcatskey = ..testcasecolon..'Category:'..cat..
		else
			ttrackingcatskey = 
		end
	end
	return
end
--Check for unknown parameters.
--Used by main only.
local function checkforunknownparams( tbl )
	local knownparams = {
		'min' = 'min',
		'max' = 'max',
		'cat' = 'cat',
		'testcase' = 'testcase',
		'testcasegap' = 'testcasegap',
		'skip-gaps' = 'skip-gaps',
		'list-all-links' = 'list-all-links',
		'follow-redirects' = 'follow-redirects',
	}
	for k, _ in pairs (tbl) do
		if knownparamsk == nil then
			trackcat(3, 'Navseasoncats using unknown parameter')
			break
		end
	end
end
--Check for nav_*() navigational isolation (not necessarily an error).
--Used by all nav_*().
local function isolatedcat()
	if nexistingcats == 0 then
		trackcat(16, 'Navseasoncats isolated')
	end
end
--Returns the target of , if it exists, else returns the original cat.
--, etc., if found, are evaluated.
--Used by catlinkfollowr(), and so indirectly by all nav_*().
local function rtarget( frame, cat )
	local catcontent = mw.title.new( cat or , 'Category' ):getContent()
	if string.match( catcontent or , '