Module:Sandbox/RexxS/GCI09

-- Module to demonstrate a MW library call for Google-Code-in-2017 -- Function langnames returns the list of languages known to MediaWiki

p = {}

p.langnames = function( frame ) local langs = mw.language.fetchLanguageNames local langlist = "" local count = 0 for key, value in pairs( langs ) do langlist = langlist .. key .. " - " .. value .. " "		count = count + 1 end return langlist .. " = " .. count .. " languages" end

p.fallbacks = function( frame ) local langcode = frame.args.langcode or "" local fblist = mw.language.getFallbacksFor( langcode ) return table.concat(fblist, ", ") end

p.showFallbacks = function( frame ) local langs = mw.language.fetchLanguageNames local langlist = "" local count = 0 for key, value in pairs( langs ) do langlist = langlist .. key .. " - " .. table.concat(mw.language.getFallbacksFor( key ), ", ") .. " "		count = count + 1 end return langlist .. " = " .. count .. " languages" end

return p