Editing
Module
:
Cat see also
Jump to navigation
Jump to search
Warning:
You are not logged in. Your IP address will be publicly visible if you make any edits. If you
log in
or
create an account
, your edits will be attributed to your username, along with other benefits.
Anti-spam check. Do
not
fill this in!
require('strict') local p = {} function p.main(frame) local args = require('Module:Arguments').getArgs(frame) frame = mw.getCurrentFrame() -- Special case when the first given link in parameter is 'V', and -- the current page name starts by 'V' or 'In' if args[1] == 'V' then local title = mw.title.getCurrentTitle().text local cwttb = mw.text.split( title, ':' ); if title:sub(1, 1) == 'V' then args[1] = 'In' .. mw.getContentLanguage():lcfirst(title) elseif title:sub(1, 1) == 'I' then args[1] = mw.getContentLanguage():ucfirst(title:sub(3)) else args[1] = nil end local cwttc = cwttb [1] if mw.ustring.sub (cwttc, -5) == ' code' then cwttc = mw.ustring.sub (cwttc, 1, #cwttc-5) end if args[9] ~= nil then args['for'] = args[9] elseif mw.ustring.sub (cwttb[1], 1, 22) == 'Valid SVG created with' then args['for'] = '[[Template:C' .. mw.ustring.sub (cwttc, 12) .. '|' .. mw.ustring.sub (cwttc, 24) .. ']]' elseif mw.ustring.sub (cwttb[1], 1, 24) == 'Invalid SVG created with' then args['for'] = '[[Template:C' .. mw.ustring.sub (cwttc, 14) .. '|' .. mw.ustring.sub (cwttc, 26) .. ']]' end end -- filter the list of links in parameters local links = {} local linkformat = '<span lang="en" dir="ltr">[[:' .. (args.iw or args.SISTER or '') .. 'Category:%s|%s]]</span>' for i, v in ipairs(args) do -- discard HTML comments and opening or closing "nowiki" tags in values, -- then normalize and trim whitespaces v = v :gsub('<!%-%-.-%-%->', '') :gsub('<nowiki *>', ''):gsub('</nowiki *>', ''):gsub('<nowiki */>', '') :gsub('_', ' '):gsub('%s+', ' '):gsub('^%s*(.-)%s*$', '%1') -- do not insert any link for empty values if v ~= '' then local html = args["h" .. tostring(i)] if html ~= nil and html ~= '' then table.insert(links, linkformat:format(v, '<' .. html .. '>' .. v .. '</' .. html .. '>')) else table.insert(links, linkformat:format(v, v)) end end end -- do not return any box if the filtered list of links is now empty if #links == 0 then return '' end -- find the localized template to format the box and message containing the list if not args.lang or not mw.language.isSupportedLanguage(args.lang) then -- use page language instead of user language on pages translated using the Translate extension if frame:callParserFunction('#translation', '') ~= '' then args.lang = frame:preprocess('{{PAGELANGUAGE}}') else args.lang = frame:callParserFunction('Int', 'Lang') end end local fallbacks = mw.language.getFallbacksFor(args.lang) table.insert(fallbacks, 1, args.lang) for _, lang in ipairs(fallbacks) do if mw.title.new('Template:Cat see also/i18n/' .. lang).exists then args.lang = lang break end end -- prepare the formating of the list according to target language args.list = require('Module:Linguistic').conj(links, args.lang, 'and') args.length = #links -- format the box and its message continaing the list return frame:expandTemplate{ title = 'Template:Cat see also/i18n/' .. args.lang, args = args } end return p
Summary:
Please note that all contributions to Islamical Commons may be edited, altered, or removed by other contributors. If you do not want your writing to be edited mercilessly, then do not submit it here.
You are also promising us that you wrote this yourself, or copied it from a public domain or similar free resource (see
commons:Copyrights
for details).
Do not submit copyrighted work without permission!
Cancel
Editing help
(opens in new window)
Page included on this page:
Module:Cat see also/doc
(
edit
)
Navigation menu
Personal tools
Not logged in
Talk
Contributions
Create account
Log in
associated-pages
Module
Discussion
English
Views
Read
Edit source
View history
More
Search
Navigation
Main page
welcome
Community portal
village pump
participate
Upload file
Recent changes
latestfiles
Random File
contact
Special pages
Tools
What links here
Related changes
Upload file
Page information