Moduł:Strings

Z Dead by Daylight Wiki
Przejdź do nawigacji Przejdź do wyszukiwania

--DO NOT CHANGE
require("Module:Extensions")
bar = "|" -- code for |
br = "<br>" --break
brnl = "<br>\n" --break new line
dbr = "<br><br>" -- double break
space = " "
nbsp = " " -- Non Breakable SPace
nbspC = "&nbsp;" -- Non Breakable SPace Code
hiddenChar = "‎" --hidden char that won't get rendered but behaves like the one
dot = "."
comma = ", "
colon = ":"
semi = ";"
dash = "-"
bullet = "\n* " --deprecated, do not use!
nbullet = "*" --newBullet -> please use this version, the old will be removed eventually
dbullet = "\n** " --deprecated
ndbullet = "**"
nl = "\n" --new line
dnl = "\n\n" -- double new line
tnl = "\n\n\n" --tripple new line
nlp = "\n<p>" --new line paragraph
pg = "<p>" --paragraph
ntl = "|-" -- new table line
hl = "!" -- header line
dhl = "!!" -- double header line
tl = "|" --table line
dtl = "||" -- double table line

strVars = {
	bar = bar, br = br, brnl = brnl, dbr = dbr, space = space, nbsp = nbsp, nbspC = nbspC, hiddenChar = hiddenChar, dot = dot, comma = comma, colon = colon, semi = semi, dash = dash, bullet = bullet, nbullet = nbullet, dbullet = dbullet, ndbullet = ndbullet, nl = nl, dnl = dnl, tnl = tnl, nlp = nlp, pg = pg, ntl = ntl, hl = hl, dhl = dhl, tl = tl, dtl = dtl, tag = tag, effects = effects
}

--TRANSLATE PART--
descStrings = {
	statusEffect = "Efekt",
	statusEffects = "Efekty",
--	statesOrder = "#2# #1#",
	andString = "i",
}
--TRANSLATE PART END--

--common strings
cstr = {
	category = "Kategoria:", --[[Category: ...]]
	file = "Plik:", --[[File: ...]]
	media = "Media:",
	empty = "",
	the = "",
	contact = space .. "Please contact [[User:Jouki|Jouki]]",
	gameName = "Dead by Daylight",
	
	frameless = "frameless",
	left = "left",
	center = "center",
	right = "right",

	--File Formats
	ogg = 'ogg',
	mp3 = 'mp3',
	mp4 = 'mp4',
	jpg = 'jpg',
	jpeg= 'jpeg',
	png = 'png',
	gif = 'gif',
}

types = {
	number = "number",
	string = "string",
	table = "table"
}

multinames = { --values in brackets in case of multiname
	achievement = "osiągnięcie",
	dlc = "DLC",
	killer = "zabójca",
	map = "mapa",
	realm = "lokacja",
	perk = "umiejętność",
	power = "moc",
	survivor = "ocalały"
}

--iconLinkStrings
ils = {
	-- Interaction
	basementHooks	  = "Haki w Piwnicy",
	blastMine         = "Mina",
	blastMines		  = "Miny",
	breakableWall	  = "Ściana do Zniszczenia",
	breakableWalls	  = "Ściany do Zniszczenia",
	boonTotem		  = "Dobry Totem",
	boonTotems        = "Dobre Totemy",
	chest			  = "Skrzynia",
	chests			  = "Skrzynie",
	dullTotem		  = "Zwykły Totem",
	dullTotems        = "Zwykłe Totemy",
	exitGate		  = "Brama Wyjściowa",
	exitGates		  = "Bramy Wyjściowe",
	exitGateSwitch    = "Przełącznik Bram Wyjściowych",
	exitGateSwitches  = "Przełączniki Bram Wyjściowych",
	failedSkillCheck  = "Chybiony Test Umiejętności",
	failedSkillChecks = "Chybione Testy Umiejętności",
	firecracker       = "Fajerwerek",
	firecrackers	  = "Fajerwerki",
	flashlight        = "Latarka",
	flashlights		  = "Latarki",
	flashbang         = "Granat Błyskowy (Przedmiot)",
	flashbangs		  = "Granaty Błyskowe (Przedmiot)",
	flashGrenade	  = "Granat Błyskowy (Umiejętność)",
	flashGrenades     = "Granaty Błyskowe (Umiejętność)",
	generator		  = "Generator",
	generators		  = "Generatory",
	goodSkillCheck	  = "Dobry Test Umiejętności",
	goodSkillChecks	  = "Dobre Testy Umiejętności",
	hatch			  = "Właz",
	hexTotem		  = "Przeklęty Totem",
	hexTotems		  = "Przeklęte Totemy",
	hook			  = "Hak",
	hooks			  = "Haki",
	item			  = "Przedmiot",
	items			  = "Przedmioty",
	locker			  = "Szafka",
	lockers			  = "Szafki",
	map				  = "Mapa",
	maps			  = "Mapy",
	medKit            = "Apteczka",
	medKits			  = "Apteczki",
	pallet			  = "Paleta",
	pallets			  = "Palety",
	survivor		  = "Ocalały",
	survivors		  = "Ocalali",
	skillCheck		  = "Test Umiejętności",
	skillChecks		  = "Testy Umiejętności",
	toolbox           = "Skrzynka z Narzędziami",
	toolboxes		  = "Skrzynki z Narzędziami",
	totem			  = "Totem",
	totems			  = "Totemy",
	greatSkillCheck   = "Świetny Test Umiejętności",
	greatSkillChecks  = "Świetne Testy Umiejętności",
	window			  = "Okno",
	windows			  = "Okna",
	
	-- UI (Status Effects, Auras)
	adrenaline		= "Adrenalina",
	aura			= "Aura",
	auras			= "Aury",
	bleeding		= "Krwawienie",
	blessed         = "Błogosławiony",
	blindness		= "Oślepienie",
	bloodlust		= "Żądza Krwi",
	broken			= "Okaleczenie",
	chance          = "Szansa",
	cursed			= "Przeklęty",
	deafened        = "Ogłuszony",
	deepWound		= "Głęboka Rana",
	efficiency      = "Wydajność",
	endurance		= "Wytrzymałość",
	enduranceKiller = "Wytrzymałość (Zabójca)",
	enduranceSurvivor = "Wytrzymałość (Ocalały)",
	exhausted		= "Wyczerpany",
	exhaustion		= "Wyczerpanie",
	exposed			= "Narażony",
	haemorrhage		= "Krwawienie",
	haste			= "Pośpiech",
	hearing         = "Słuch",
	hindered		= "Skrępowany",
	incapacitated	= "Unieruchomiony",
	luck			= "Szczęście",
	madness         = "Szaleństwo",
	mangled			= "Zmasakrowany",
	obsession		= "Obsesja",
	oblivious		= "Nieświadomy",
	revealed        = "Ujawniony",
	sleepPenalty    = "Kara za Sen",
	undetectable	= "Niewykrywalny",
	vision          = "Wizja",
	
	-- Killers
	killer			= "Zabójca",
	nightmare		= "Koszmar",
	
	-- Misc.
	addon			= "Dodatek",
	addons			= "Dodatki",
	altruism		= "Altruizm",
	basement		= "Piwnica",
	bloodpoints		= "Punkty Krwi",
	bpWhite         = "Punkty Krwi białe",
	boldness        = "Zuchwałość",
	brutality       = "Brutalność",
	crow			= "Wrona",
	crows			= "Wrony",
	deviousness		= "Przebiegłość",
	dyingState		= "Stan Agonii",
	entity			= "Byt",
	healthState		= "Stan Zdrowia",
	healthy			= "Zdrowy",
	hunter			= "Łowca",
	injuredState    = "Stan Ranny",
	objectives      = "Cele",
	offering		= "Dar",
	offerings		= "Dary",
	poolsOfBlood	= "Ślady Krwi",
	sacrifice       = "Ofiara",
	scratchMarks	= "Czerwone Zarysowania",
	idleCrows		= "Wrony Bezczynności",
	survival        = "Przetrwanie",
	terrorRadius	= "Zasięg Terroru",

	--Polish conjugation -Yupi
	bloodpoints2	= "Punktów Krwi",
	dyingState2	   	= "Stanie Agonii",	
	injuredState2   = "Stanie Rannym",
	survivor2	    = "Ocalałego",
	survivor3	    = "Ocalałemu",
	survivor4	    = "Ocalałym",
	survivors2	    = "Ocalałych",
	survivors3	    = "Ocalałymi",
	aura2			= "Aurę",
	entity2			= "Bytu",
	generator2		= "Generatora",
	generators2		= "Generatorów",
	map2			= "Mapę",
	haste2			= "Pośpiechu",
	scratchMarks2	= "Czerwonych Zarysowań",
	chest2			= "Skrzyni",
	chests2			= "Skrzyń",
	items2			= "Przedmiotów",
	locker2			= "Szafce",
	poolsOfBlood2	= "Śladów Krwi",
	toolbox2		= "Skrzynki z Narzędziami",
}

specialWords = {
	dot = "dot"
}

function word(wrd)
	return " {<" .. specialWords[wrd] .. ">}" --" {<dot>}"
end

function iconLink(icon, link, text)
	local utils = require("Module:Utils")
	return utils.IconLink(icon, link, text)
end

function icon(icon)
	local utils = require("Module:Utils")
	return utils.getIcon(icon)
end

function img(iconName, ...)
	return file(icon(iconName), ...)
end

function aImg(iconType, iconName, iconSize, params)
	local utils = require("Module:Utils")
	return utils.assembleImage(iconType, iconName, iconSize, params)
end

function clr(color, text)
	local utils = require("Module:Utils")
	return utils.clr(color, text)
end

function clro(text, reset)
	local utils = require("Module:Utils")
	return utils.clro(text, reset)
end

function clror(text)
	return clro(text, true)
end

function bclr(color, text)
	--local utils = require("Module:Utils")
	return b(clr(color, text))
end

function iclr(color, text)
	--local utils = require("Module:Utils")
	return i(clr(color, text))
end

function biclr(color, text) return ibclr(color, text) end
function ibclr(color, text)
	return i(b(clr(color, text)))
end

function tooltip(text, tooltip, iconless, bordeless)
	local utils = require("Module:Utils")
	return utils.tooltip(text, tooltip, iconless, bordeless)
end

function quote(text, author)
	local utils = require("Module:Utils")
	author = author or utils.resolveParameter(text, 2, true)
	text = utils.resolveParameter(text, 1) or cstr.empty
	return i(clr(9, '"' .. text .. ((author and '" — ' .. author) or '"')))
end

function states(...)
	local utils = require("Module:Utils")
	local states = {...}
	local suffix = (#states > 1 and descStrings.statusEffects) or descStrings.statusEffect
	local result = utils.getDynamicString(
		{
			skip(table.join(states, {comma, ((#states > 2 and comma) or cstr.empty) .. space .. descStrings.andString .. space}, {"ibil"})),
			skip(b(suffix))
		}
		, descStrings.statesOrder)
	return result
end

--function p.effects(_loType, loName, ...) effects(_loType, loName, ...) end
function effects(_loType, loName, ...) --this function should be called only if the loadout module is loaded
	local utils = require("Module:Utils")
	local effectsList = {...}
	local suffix = (#effectsList > 1 and descStrings.statusEffects) or descStrings.statusEffect
	local postprocessedStates = {}
	local loM = require("Module:Loadout" .. utils.lang())
	local varM = mw.loadData("Module:Datatable/Various" .. utils.lang())
	local lo = loM["get" .. utils.firstLetterUpper(_loType or cstr.empty) .. "ByName"] and loM["get" .. utils.firstLetterUpper(_loType) .. "ByName"](loName, false)
	local loCharType = lo and ((lo.charType == 'S' or lo.survivor) and ils.survivor) or ((lo.charType == 'K' or lo.killer) and ils.killer)
	for _, effect in pairs(effectsList) do
		local effObj = varM.effects[effect] or varM.effects[effect .. space .. brackets(loCharType)] or false
		local effectObjName = (varM.effects[effect] and effect) or (varM.effects[effect .. space .. brackets(loCharType)] and effect .. space .. brackets(loCharType))
		local displayName = effObj and effObj.displayName or effect
		local effectVarName = string.lower(utils.firstLetterLower(utils.capitalizeName(displayName)))
		local effectVarTechName = effObj and effObj.techName and string.lower(utils.firstLetterLower(utils.capitalizeName(effObj.techName))) or cstr.empty
		local durationValue = lo and (lo[effectVarName] or (effObj and lo[effectVarTechName])) or -1
		durationValue = tonumber(type(durationValue) == types.string and string.split(durationValue, space)[1] or durationValue) or -1
		local debugInfoObj = (effectObjName == nil and {loCharType = (loCharType or "NULL"), loName = (loName or "NULL"), effect = (effect or "NULL"), effectWithCharType = (effect or "NULL") .. space .. brackets((loCharType or "NULL"))})
		table.add(postprocessedStates, i(b(link(displayName))) .. aImg("effect", effectObjName, 48, {il = true, duration = durationValue, debugInfo = debugInfoObj}))
	end
	local result = utils.getDynamicString(
		{
			skip(table.join(postprocessedStates, {comma, ((#postprocessedStates > 2 and comma) or cstr.empty) .. space .. descStrings.andString .. space})),
			skip(b(suffix))
		}
		, descStrings.statesOrder)
	return result
end

function ibil(ilsString) --i + b + iconLink
	local utils = require("Module:Utils")
	return i(b(utils.IconLink(ilsString)))
end

function link(text, ...)
	local parameters = (#{...} > 0 and tl .. table.concat({...}, tl)) or cstr.empty --join table with | so we get |param1|param2|param3|...
	return '[[' .. text .. parameters ..']]'
end

function templateLink(text)
	return '{{' .. (text or "Error") .. '}}'
end

function quotes(text)
	return '"' .. (text or "Error") .. '"'
end

function center(text)
	return '<center>' .. (text or "Error") .. '</center>' 
end

function includeonly(text)
	return '<includeonly>' .. (text or "Error") .. '</includeonly>' 
end

function noinclude(text)
	return '<noinclude>' .. (text or "Error") .. '</noinclude>' 
end

function list(...)
	local result = cstr.empty
	local items = {...}
	for _, row in ipairs(items) do
		result = result .. nbullet .. row .. nl
	end
	return nl .. result .. nl
end

function file(filename, ...)
	local parameters = (#{...} > 0 and tl .. table.concat({...}, tl)) or cstr.empty --join table with | so we get |param1|param2|param3|...
	return link(cstr.file .. filename .. parameters)
end

function media(filename, ...)
	local parameters = (#{...} > 0 and tl .. table.concat({...}, tl)) or cstr.empty --join table with | so we get |param1|param2|param3|...
	return link(cstr.media .. filename .. parameters)
end

function category(...)
	local result = {}
	for _, cat in ipairs({...}) do
		table.insert(result, link(cstr.category .. cat))
	end
	if #result > 0 then
		return table.concat(result, nl) --nl maybe needs to be replaced with cstr.empty if nl creates new rows
	else
		return link(cstr.category .. "Category-Module-Error")
	end
end

function brackets(text)
	return '(' .. (text or "Error") .. ')'
end 

function tag(tagName, tagContent, closeTag)
	closeTag = closeTag or tagContent == true
	tagContent = (tagContent == true or tagContent == false or tagContent == nil) and cstr.empty or tagContent
	return '<' .. (closeTag and '/' or cstr.empty) .. tagName .. space .. tagContent .. '>'
end

--bold function
function b(text)
	text = stringsObjs.resolveParam(text, 1, true)
	return "<b>" .. (text or "Error") .. "</b>"
end

--italic function
function i(text)
	return "<i>" .. (text or "Error") .. "</i>"
end

function skip(text)
	return "#s#" .. (text or "Error") .. "#/s#"
end

function big(text)
	return '<big>' .. (text or "Error") .. '</big>'
end

function small(text)
	return '<small>' .. (text or "Error") .. '</small>'
end

function note(text)
	return '<span class = "noticeText">' .. (text or "Error") .. '</span>'
end

function join(...)
	require("Module:Extensions")
	return table.join(...)
end

function the(alter, spaceless)
	local langs = require("Module:Languages")
	return langs.evaluateArticle(alter, false)
	--return (langs.nonEn() and (langs.evaluateArticle(alter))) or cstr.the .. ((not langs.nonEn() and not spaceless and space) or cstr.empty)
end

function article(obj, indefinite)
	local langs = require("Module:Languages")
	return langs.evaluateArticle(obj, indefinite)
end

function ptb(content, title, patch)
	local utils = require("Module:Utils")
	return utils.ptb(content, title, patch)
end

function deletedBox(content, title, patch)
	local utils = require("Module:Utils")
	return utils.deletedBox(content, title, patch)
end

--Syntax Highlight
function sh(value, lang, inline)
	local frame = mw.getCurrentFrame()
	local shArgs = {}
	shArgs.lang = ((lang ~= cstr.empty and lang) or "lua")
	shArgs.inline = (inline == true or inline == nil) or nil --true value is just a mockup for argument being present, regardless of actual value. false => will still show inline
	return b(frame:extensionTag{ name = 'syntaxhighlight', content = value, args = shArgs })
end


--table line => creates a basic table line so it can be easily stacked
function tLine(attrs, ...)
	local values = (type(...) == "string" and {...}) or ...
	local result = cstr.empty
	local separator = (values[#values] == hl and table.remove(values)) or tl --if the last item is header separator then set it to var
	local multiLine = false --if the cell value has multiple lines then we can't use double separator such as ||
	--if separator == hl then table.remove(values) end --if the last item was a separator, then remove it from the list. It's not needed anymore
	result = result .. ntl .. nl .. separator .. ((attrs and space .. attrs .. space .. tl) or cstr.empty) .. space .. table.remove(values, 1)
	for _, value in ipairs(values) do
		if string.find(value, nl) then
			multiLine = true
			break
		end
	end
	for _, value in ipairs(values) do
		result = result .. (multiLine and (nl .. separator) or (space .. separator .. separator)) .. space .. value
	end
	return result .. nl
end

--table header line => same as table line, just for header version
function thLine(attrs, ...)
	local values = {...}
	table.insert(values, hl)
	return tLine(attrs, values)
end

function class(...)
	local values = {...}
	return (#values and 'class = ' .. quotes(join(values, space))) or cstr.empty
end

function style(...)
	local values = {...}
	return (#values and 'style = ' .. quotes(join(values, semi))) or cstr.empty
end

function colspan(value) return ' colspan = ' .. tonumber(value) .. space end
function rowspan(value) return ' rowspan = ' .. tonumber(value) .. space end

function span(content, ...)
	local classes = class(...)
	return "<span " .. classes .. ">" .. content .. "</span>"
end

function div(content, ...)
	local classes = class(...)
	return "<div " .. classes .. ">" .. content .. "</div>"
end
-----------------------------
--     Debug Functions     --
-----------------------------

--Debug Log
function lg(obj)
	mw.log(obj)
end

--Dump object
function dmp(obj)
	mw.log(mw.dumpObject(obj))
end

--raw Dump
function rdmp(obj)
	return mw.dumpObject(obj)
end

--------------------------------
--     External functions     --
--------------------------------
stringsObjs = {}

--temporary - may be moved to Utils
function stringsObjs.resolveParam(param, index, canBeNil)
	local retArg = nil
	if type(param) == types.table then
		if param.args then
			if index then
				if index == 0 then
					retArg = param.args
				else
					retArg = param.args[index]
					if retArg == nil and not canBeNil then
						return stringsObjs.getPageName()
					else
						return retArg
					end
				end
			else
				if not canBeNil then
					return stringsObjs.getPageName()
				else
					return nil
				end
			end
		else
			return param
		end
	elseif param ~= nil then
		return param
	elseif not canBeNil then
		return stringsObjs.getPageName()
	else
		return nil
	end
end

function stringsObjs.getPageName()
	local pageName = mw.title.getCurrentTitle().text
		local pageParts = string.split(pageName, '/') -- remove page suffixes such as language codes
		if #pageParts > 1 then
			_unofficialLang = pageParts[#pageParts]
			return pageParts[#pageParts - 1] --take second to last part of page name
		end
		return pageParts[1]  --if there is no other part than the name itself
end

stringsObjs.bar = bar
stringsObjs.br = br
stringsObjs.brnl = brnl
stringsObjs.space = space
stringsObjs.nbsp = nbsp
stringsObjs.nbspC = nbspC
stringsObjs.hiddenChar = hiddenChar
stringsObjs.dot = dot
stringsObjs.comma = comma
stringsObjs.colon = colon
stringsObjs.semi = semi
stringsObjs.dash = dash
stringsObjs.bullet = bullet
stringsObjs.nbullet = nbullet
stringsObjs.dbullet = dbullet
stringsObjs.ndbullet = ndbullet
stringsObjs.nl = nl
stringsObjs.dnl = dnl
stringsObjs.tnl = tnl
stringsObjs.nlp = nlp
stringsObjs.pg = pg
stringsObjs.ntl = ntl
stringsObjs.hl = hl
stringsObjs.dhl = dhl
stringsObjs.tl = tl
stringsObjs.dtl = dtl

stringsObjs.cstr = cstr
stringsObjs.types = types
stringsObjs.ils = ils
function stringsObjs.iconLink(link, icon, text) return iconLink(link, icon, text) end
function stringsObjs.icon(icon) return icon(icon) end
function stringsObjs.img(iconName, ...) return img(iconName, ...) end
function stringsObjs.aImg(iconType, iconName, iconSize, params) return aImg(iconType, iconName, iconSize, params) end
function stringsObjs.clr(color, text) return clr(color, text) end
function stringsObjs.clro(text, reset) return clro(text, reset) end
function stringsObjs.clror(text) return clror(text) end
function stringsObjs.biclr(color, text) return ibclr(color, text) end
function stringsObjs.ibclr(color, text) return ibclr(color, text) end
function stringsObjs.bclr(color, text) return bclr(color, text) end
function stringsObjs.iclr(color, text) return iclr(color, text) end
function stringsObjs.tooltip(text, tooltip, iconless) return tooltip(text, tooltip, iconless) end
function stringsObjs.quote(text, author) return quote(text, author) end
function stringsObjs.states(...) return states(...) end
function stringsObjs.effects(_loType, loName, ...) return effects(_loType, loName, ...) end
function stringsObjs.ibil(ilsString) return ibil(ilsString) end
function stringsObjs.link(text, ...) return link(text, ...) end
function stringsObjs.templateLink(text) return templateLink(text) end
function stringsObjs.quotes(text) return quotes(text) end
function stringsObjs.center(text) return center(text) end
function stringsObjs.includeonly(text) return includeonly(text) end
function stringsObjs.noinclude(text) return noinclude(text) end
function stringsObjs.list(...) return list(...) end
function stringsObjs.file(text, ...) return file(text, ...) end
function stringsObjs.media(filename, ...) return media(filename, ...) end
function stringsObjs.category(...) return category(...) end
function stringsObjs.brackets(text) return brackets(text) end
function stringsObjs.tag(tagName, tagContent, closeTag) return tag(tagName, tagContent, closeTag) end
function stringsObjs.b(text) return b(text) end
function stringsObjs.i(text) return i(text) end
function stringsObjs.skip(text) return skip(text) end
function stringsObjs.big(text) return big(text) end
function stringsObjs.small(text) return small(text) end
function stringsObjs.note(text) return note(text) end
function stringsObjs.join(...) return join(...) end
function stringsObjs.the(alter, spaceless) return the(alter, spaceless) end
function stringsObjs.article(obj, indefinite) return article(obj, indefinite) end
function stringsObjs.ptb(content, title, patch) return ptb(content, title, patch) end
function stringsObjs.deletedBox(content, title, patch) return deletedBox(content, title, patch) end
function stringsObjs.sh(value, lang, inline) return sh(value, lang, inline) end
function stringsObjs.tLine(attrs, ...) return tLine(attrs, ...) end
function stringsObjs.thLine(attrs, ...) return thLine(attrs, ...) end
function stringsObjs.class(...) return class(...) end
function stringsObjs.style(...) return style(...) end
function stringsObjs.colspan(value) return colspan(value) end
function stringsObjs.rowspan(value) return rowspan(value) end
function stringsObjs.span(content, ...) return span(content, ...) end
function stringsObjs.div(content, ...) return div(content, ...) end
return stringsObjs