Module:Languages

function language_subpages( frame, transform ) local args, pargs = frame.args, ( frame:getParent or {} ).args or {}; local title = args.page or args[1] or pargs.page or pargs[1] or ""; local tt = type( transform ); local page = require( 'Module:Page' ); title = page.clean(title); if tt == 'function' or ( tt == 'table' and getmetatable(transform).__call ) then local fetch, pages, langcode, langname = mw.language.fetchLanguageName, {}; for pg in page.subpages( title ) do           langcode = string.lower( pg ); langname = fetch( langcode ); if langname ~= '' then table.insert( pages, transform( title, pg, langcode, langname ) ); end end return pages; end return {}; end

p = {};

function p.internal(frame) pages = language_subpages( frame, function( title, page, code, name )       return mw.ustring.format( ' %s ', code, code, code, title, page, name );   end); return table.concat( pages, ' · ' ); end

function p.external(frame) pages = language_subpages( frame, function( title, page, code, name )       return mw.ustring.format( ' [%s/%s %s] ', code, code, code, tostring( mw.uri.fullUrl( title ) ), page:gsub( ' ', '_' ), name );   end); return table.concat( pages, ' | ' ); end

return p;