Module:ListI18n
Appearance
From mediawiki.org
This module is rated as alpha. It is ready for third party input, and may be used on a few pages to see if problems arise, but should be watched. Suggestions for new features or changes in their input and output mechanisms are welcome.
Lua module that renders language list with links by given json file.
Usage
[edit ]{{#invoke:ListI18n|main|filename.json|translatewiki=project-name}}{{#invoke:ListI18n|main|filename.json|link=filename.$lang.js}}
The above documentation is transcluded from Module:ListI18n/doc. (edit | history)
Editors can experiment in this module’s sandbox (create | mirror) and testcases (create) pages.
Subpages of this module.
Editors can experiment in this module’s sandbox (create | mirror) and testcases (create) pages.
Subpages of this module.
localgetArgs=require('Module:Arguments').getArgs localcontentLanguage=mw.message.getDefaultLanguage():getCode() localp={} localfunctionformatLink(code,link,external) localout='*'; locallanguage ifmw.language.isValidCode(code)then language=mw.language.fetchLanguageName(code,contentLanguage) else language=code; end ifexternalthen returnout..' ['..link..' '..language..']' else returnout..' [['..link..'|'..language..']]' end end localfunctionformatTranslatewiki(code,group) locallink=tostring(mw.uri.fullUrl('translatewiki:Special:Translate','action=page&group='..group..'&language='..code)) returnformatLink(code,link,true) end localfunctionformatLocal(code,link) locallink=string.gsub(link,'$lang',code) returnformatLink(code,link,false) end functionp.main(frame) localargs=getArgs(frame) returnp._main(args) end functionp._main(args) localcodes=mw.loadJsonData(args[1]) locallinks={}; fori,codeinipairs(codes)do locallink; ifargs.translatewikiandargs.translatewiki~=nilthen link=formatTranslatewiki(code,args.translatewiki) elseifargs.linkandargs.link~=nilthen link=formatLocal(code,args.link) end table.insert(links,link) end returntable.concat(links,'\n') end returnp;