ਮੌਡਿਊਲ:IPA/category documentation
Implements Template:IPA language category. require('strict')
local p = {}
local lects = mw.loadData('Module:IPA/data/export')
local mLang = require('Module:Lang')
function p.main(frame)
local args = {}
for k, v in pairs(frame:getParent().args) do
if v ~= '' then
args[k] = v
end
end
local name = mw.title.getCurrentTitle().text:sub(12, -5)
local lect, parent
local code = args.code
if not code then
for _, lect2 in ipairs(lects) do
if (lect2.name or lect2.extName) == name then
lect = lect2
parent = lect.parent
code = lect.code
break
end
end
end
if not code then
code = mLang._tag_from_name({ name })
if code:find('^<span') then
code = nil
else
for _, lect2 in ipairs(lects) do
if lect2.code == code then
lect = lect2
parent = lect.parent
break
end
end
end
end
local isCollective = name:find(' languages$') and true
local link = lect and (lect.link or lect.generatedLink or lect.extLink) or
parent and (parent.link or parent.generatedLink or parent.extLink) or
isCollective and name or
name .. ' language'
local key = lect and lect.key or parent and parent.key
local langCat, langCatCount
if code then
langCat = mLang._category_from_tag({ code })
if langCat:find('^<span') then
langCat = nil
else
langCatCount = mw.site.stats.pagesInCategory(langCat:sub(10), 'pages')
end
end
local parentName = args.parent or
parent and (parent.name or parent.extName) or
code and code:find('-') and mLang._name_from_tag({ code:gsub('%-.*', '') })
if parentName == name or
parentName and parentName:find('^<span')
then
parentName = nil
end
local cat = args.cat ~= 'no' and (
parentName and 'Pages with ' .. parentName .. ' IPA' or
'Pages with IPA'
)
local sortkey = args.sort or
name:find('^[ %l]+$') and ' ' .. name or
name
local ret = {
string.format(
'The following pages contain [[International Phonetic Alphabet|IPA]] transcriptions of [[%s|%s]] using %s. This category should never be added manually.',
link,
name,
code
and string.format('<code>{{[[Template:IPA|IPA]]|%s|...}}</code>', code)
or '[[Template:IPA]]'
)
}
if key then
table.insert(ret, string.format(
'By default, the transcriptions are linked to the [[%s]] key. Transcriptions that do not adhere to the conventions of the key must have <code>|generic=yes</code>.',
key
))
end
if isCollective then
table.insert(ret, string.format(
'The %s are a language collective. Please replace the code%s with those of more specific languages where possible.',
name,
code and ' (' .. code .. ')' or ''
))
end
if not code and args.container ~= 'yes' then
table.insert(ret, string.format(
'<small>Documentation error: language code for "%s" not found.</small>',
name
))
end
if args.content then
table.insert(ret, args.content)
end
if langCat and langCatCount ~= 0 then
table.insert(ret, string.format(
'==See also==\n*[[:%s]] (%s)',
langCat,
mw.language.new('en'):formatNum(langCatCount)
))
end
if cat then
table.insert(ret, string.format('[[Category:%s|%s]]', cat, sortkey))
end
return table.concat(ret, '\n\n')
end
return p
|
Index:
pl ar de en es fr it arz nl ja pt ceb sv uk vi war zh ru af ast az bg zh-min-nan bn be ca cs cy da et el eo eu fa gl ko hi hr id he ka la lv lt hu mk ms min no nn ce uz kk ro simple sk sl sr sh fi ta tt th tg azb tr ur zh-yue hy my ace als am an hyw ban bjn map-bms ba be-tarask bcl bpy bar bs br cv nv eml hif fo fy ga gd gu hak ha hsb io ig ilo ia ie os is jv kn ht ku ckb ky mrj lb lij li lmo mai mg ml zh-classical mr xmf mzn cdo mn nap new ne frr oc mhr or as pa pnb ps pms nds crh qu sa sah sco sq scn si sd szl su sw tl shn te bug vec vo wa wuu yi yo diq bat-smg zu lad kbd ang smn ab roa-rup frp arc gn av ay bh bi bo bxr cbk-zam co za dag ary se pdc dv dsb myv ext fur gv gag inh ki glk gan guw xal haw rw kbp pam csb kw km kv koi kg gom ks gcr lo lbe ltg lez nia ln jbo lg mt mi tw mwl mdf mnw nqo fj nah na nds-nl nrm nov om pi pag pap pfl pcd krc kaa ksh rm rue sm sat sc trv stq nso sn cu so srn kab roa-tara tet tpi to chr tum tk tyv udm ug vep fiu-vro vls wo xh zea ty ak bm ch ny ee ff got iu ik kl mad cr pih ami pwn pnt dz rmy rn sg st tn ss ti din chy ts kcg ve
Portal di Ensiklopedia Dunia