Moduł:a tergo: Różnice pomiędzy wersjami

Z Wikisłownika – wolnego słownika wielojęzycznego
[wersja przejrzana][wersja przejrzana]
Usunięta treść Dodana treść
Beau (dyskusja | edycje)
Nie podano opisu zmian
m mw.site.namespaces[ 14 ].name
(Nie pokazano 2 pośrednich wersji utworzonych przez tego samego użytkownika)
Linia 1: Linia 1:
local p = {}
local p = {}

function reverse( text )
function p.reverse( text )
local s = ''
if type( text ) == 'table' and text == mw.getCurrentFrame() then
for codepoint in mw.ustring.gcodepoint( text ) do
text = text.args[ 1 ]
s = mw.ustring.char(codepoint) .. s
end
end
return s
assert( type( text ) == 'string' )
local s = {}

for codepoint in mw.ustring.gcodepoint( text ) do
table.insert( s, 1, mw.ustring.char( codepoint ) )
end
return table.concat( s )
end
end

function p.categorize( frame )
local language = frame.args[1]
function p.categorize( language, title )
local currentPage = mw.title.getCurrentTitle()
local categoryPage = mw.title.makeTitle(
mw.site.namespaces[ 14 ].name, -- Kategoria
if currentPage.namespace ~= 0 then
language .. ' (indeks a tergo)'
return ""
)
end
local categoryPage = mw.title.makeTitle( "Kategoria", language .. " (indeks a tergo)" )
if not categoryPage.exists then
if not categoryPage.exists then
return ""
return ''
end
end
return "[[" .. categoryPage.fullText .. "|" .. mw.ustring.lower( reverse( currentPage.text ) ) .. "]]"
return mw.ustring.format( '[[%s|%s]]',
categoryPage.fullText,
mw.ustring.lower( p.reverse( title ) )
)
end
end

return p
return p

Wersja z 16:01, 8 kwi 2015

Dokumentacja dla tego modułu może zostać utworzona pod nazwą Moduł:a tergo/opis

local p = {}

function p.reverse( text )
	if type( text ) == 'table' and text == mw.getCurrentFrame() then
		text = text.args[ 1 ]
	end
	
	assert( type( text ) == 'string' )
	local s = {}

	for codepoint in mw.ustring.gcodepoint( text ) do
		table.insert( s, 1, mw.ustring.char( codepoint ) )
	end
	
	return table.concat( s )
end

function p.categorize( language, title )
	local categoryPage = mw.title.makeTitle(
		mw.site.namespaces[ 14 ].name, -- Kategoria
		language .. ' (indeks a tergo)'
	)
	
	if not categoryPage.exists then
		return ''
	end
	
	return mw.ustring.format( '[[%s|%s]]',
		categoryPage.fullText,
		mw.ustring.lower( p.reverse( title ) )
	)
end

return p