Jump to content
 







Main menu
   


Navigation  



Main page
Contents
Current events
Random article
About Wikipedia
Contact us
Donate
 




Contribute  



Help
Learn to edit
Community portal
Recent changes
Upload file
 








Search  

































Create account

Log in
 









Create account
 Log in
 




Pages for logged out editors learn more  



Contributions
Talk
 

















Module:Namespace detect/data






Afrikaans
Алтай тил

Ænglisc
العربية
Արեւմտահայերէն

Авар
Aymar aru
Azərbaycanca
تۆرکجه
Basa Bali

 / Bân-lâm-gú
Башҡортса
Беларуская
Беларуская (тарашкевіца)

Bikol Central
Bislama
Български
Bosanski
Brezhoneg
Català
Чӑвашла
Cebuano
Chamoru
Chavacano de Zamboanga
Chi-Chewa
ChiShona
ChiTumbuka
Dansk
الدارجة
Eesti
Ελληνικά
فارسی
Fiji Hindi
Føroyskt
Fulfulde
Gaelg
Gàidhlig
Galego


  / Gõychi Konknni
/Hak-kâ-ngî

Hausa
Հայերեն
ि
Hrvatski
Ido
Ilokano
িি ি
Bahasa Indonesia
Ирон
IsiXhosa
Íslenska
Jawa
Kabɩyɛ


Қазақша
Ikirundi
Kreyòl ayisyen
Kurdî
Ladin
Latgaļu
Latviešu
Lëtzebuergesch
Lietuvių
Magyar
Madhurâ
ि
Македонски
Malagasy

Malti

مصرى

Bahasa Melayu
 / Mìng-dĕ̤ng-nḡ
Mirandés
Мокшень
Монгол

Nāhuatl
Na Vosa Vakaviti
Nederlands
Nedersaksies


Нохчийн
Nordfriisk
Norfuk / Pitkern
Norsk bokmål
Norsk nynorsk
Occitan
ି

ि
Pangasinan
Pangcah
پنجابی

Tok Pisin
Português
Română
Русиньскый
Русский
Sakizaya

Scots
Simple English
سنڌي
Slovenščina
کوردی
Српски / srpski
Srpskohrvatski / српскохрватски
Tagalog
ி
Татарча / tatarça
 

Tetun

Thuɔŋjäŋ
Тоҷикӣ


Türkçe
Türkmençe
Удмурт
Українська
اردو
Vahcuengh
Tiếng Vit
Volapük

Winaray

Yorùbá

Zazaki

Batak Toba
 

Edit links
 









Module
Talk
 

















Read
View source
View history
 








Tools
   


Actions  



Read
View source
View history
 




General  



What links here
Related changes
Upload file
Special pages
Permanent link
Page information
Get shortened URL
Download QR code
Wikidata item
 




Print/export  



Download as PDF
Printable version
 




In other projects  



Wikimedia Commons
Wikimedia Foundation
MediaWiki
Meta-Wiki
Wikimedia Outreach
Multilingual Wikisource
Wikispecies
Wikibooks
Wikidata
Wikifunctions
Wikimania
Wikiquote
Wikisource
Wikiversity
 
















Appearance
   

 





Permanently protected module

From Wikipedia, the free encyclopedia
 

< Module:Namespace detect

This is a data page for Module:Namespace detect and Module:Category handler/shared. It is loaded by the main module using mw.loadData, which means it is only processed once per page rather than once per #invoke.

--------------------------------------------------------------------------------
--                          Namespace detect data                             --
-- This module holds data for [[Module:Namespace detect]] to be loaded per    --
-- page, rather than per #invoke, for performance reasons.                    --
--------------------------------------------------------------------------------

local cfg = require('Module:Namespace detect/config')

local function addKey(t, key, defaultKey)
 if key ~= defaultKey then
  t[#t + 1] = key
 end
end

-- Get a table of parameters to query for each default parameter name.
-- This allows wikis to customise parameter names in the cfg table while
-- ensuring that default parameter names will always work. The cfg table
-- values can be added as a string, or as an array of strings.

local defaultKeys = {
 'main',
 'talk',
 'other',
 'subjectns',
 'demospace',
 'demopage'
}

local argKeys = {}
for i, defaultKey in ipairs(defaultKeys) do
 argKeys[defaultKey] = {defaultKey}
end

for defaultKey, t in pairs(argKeys) do
 local cfgValue = cfg[defaultKey]
 local cfgValueType = type(cfgValue)
 if cfgValueType == 'string' then
  addKey(t, cfgValue, defaultKey)
 elseif cfgValueType == 'table' then
  for i, key in ipairs(cfgValue) do
   addKey(t, key, defaultKey)
  end
 end
 cfg[defaultKey] = nil -- Free the cfg value as we don't need it any more.
end

local function getParamMappings()
 --[[
 -- Returns a table of how parameter names map to namespace names. The keys
 -- are the actual namespace names, in lower case, and the values are the
 -- possible parameter names for that namespace, also in lower case. The
 -- table entries are structured like this:
 -- {
 --   [''] = {'main'},
 --   ['wikipedia'] = {'wikipedia', 'project', 'wp'},
 --   ...
 -- }
 --]]
 local mappings = {}
 local mainNsName = mw.site.subjectNamespaces[0].name
 mainNsName = mw.ustring.lower(mainNsName)
 mappings[mainNsName] = mw.clone(argKeys.main)
 mappings['talk'] = mw.clone(argKeys.talk)
 for nsid, ns in pairs(mw.site.subjectNamespaces) do
  if nsid ~= 0 then -- Exclude main namespace.
   local nsname = mw.ustring.lower(ns.name)
   local canonicalName = mw.ustring.lower(ns.canonicalName)
   mappings[nsname] = {nsname}
   if canonicalName ~= nsname then
    table.insert(mappings[nsname], canonicalName)
   end
   for _, alias in ipairs(ns.aliases) do
    table.insert(mappings[nsname], mw.ustring.lower(alias))
   end
  end
 end
 return mappings
end

return {
 argKeys = argKeys,
 cfg = cfg,
 mappings = getParamMappings()
}

Retrieved from "https://en.wikipedia.org/w/index.php?title=Module:Namespace_detect/data&oldid=948472520"

Category: 
Modules subject to page protection
Hidden category: 
Wikipedia fully protected modules
 



This page was last edited on 1 April 2020, at 06:12 (UTC).

Text is available under the Creative Commons Attribution-ShareAlike License 4.0; additional terms may apply. By using this site, you agree to the Terms of Use and Privacy Policy. Wikipedia® is a registered trademark of the Wikimedia Foundation, Inc., a non-profit organization.



Privacy policy

About Wikipedia

Disclaimers

Contact Wikipedia

Code of Conduct

Developers

Statistics

Cookie statement

Mobile view



Wikimedia Foundation
Powered by MediaWiki