Module:Language

local langNames = mw.loadData( Module:Language/Names ) local code = function( title ) local subPage = ( title or mw.title.getCurrentTitle ).subpageText:lower if langNames[subPage] then return subPage end end local pageSuffix = function local langCode = code if langCode then return '/' .. langCode end return '' end

local p = {}

p.link = function( f ) local args = f or {} if f == mw.getCurrentFrame then args = f:getParent.args end -- Get language suffix for links if not args[1] or args[1]:lower == 't' then return pageSuffix end local page = args[1] .. pageSuffix -- Get page name with suffix if args.dest then return page end -- Get page link with suffix and specified text return  .. ( args.o or args[2] or args[1] ) ..  end

p.name = function( f ) local args = f	if f == mw.getCurrentFrame then args = f:getParent.args end local langCode = code( args[1] and mw.title.new( args[1] ) ) or 'en' -- Get language code for specified title or current page if args.code then return langCode end local langName = langNames[langCode] -- Get language name if args.en then return langName[1] end -- Get native name return langName[2] end

return p