Jump to content
Toggle menu
  • 8 articles
  • 75 files
  • 7 users
  • 37.8K edits
Neodyland Wiki
Toggle preferences menu
Toggle personal menu
Not logged in
Your IP address will be publicly visible if you make any edits.

Module:Description

From Neodyland Wiki
Revision as of 21:32, 26 February 2021 by commons>Jarekt
Module documentation[ create · purge ]
This documentation is transcluded from Module:Description/doc.
local core = require('Module:Core')
local p = {}

function p:langWrapper(text, textLang, inline) 
-- code equivalent to https://commons.wikimedia.org/wiki/Template:Description
	local LangName = mw.language.fetchLanguageName( textLang, textLang)
	local language = mw.language.new( textLang )
	local dir      = language:getDir()  
	local ltag = mw.html.create('span')  -- bold language name string
		:addClass('language '..textLang) -- classes: "language" and "en", "de" etc.
		:cssText('display:inline' and inline or nil)
		:tag('b')                        -- make it bold 
		:wikitext(language:ucfirst(LangName)..':')
	
	-- mw-content-rtl and mw-content-ltr are defined in (?)
	-- https://gerrit.wikimedia.org/g/mediawiki/core/+/3825c4d04d9d9701ac04bb3bc6a2f2ca43253d10/resources/src/mediawiki.skinning/content.css
	local dtag = mw.html.create('div')
		:addClass("description mw-content-"..dir) -- div.description is tracked by mw:Extension:CommonsMetadata
		:attr('dir', dir)
		:attr('lang', textLang)
		:wikitext(tostring(ltag)..text)
	return tostring(dtag)
end

function p:description(frame) 
	local args = core.getArgs(frame)
	local desc = p:langWrapper(args.text, args.textlang, args.inline)
	if args.text == nil then -- if no string than add error message and a category
		local msg  = core.formatMessage('I18n/DescriptionError.tab', 'missing text', lang)
		msg = mw.html.create('span'):addClass("error"):wikitext(msg)
		msg = '[{{fullurl:Category:Language templates with no text displayed}} ' .. tostring(msg) .. ']'
		msg = mw.html.create('span'):addClass("plainlinks"):wikitext(msg)
		desc = desc..msg
	end
	return desc
end

return p
Cookies help us deliver our services. By using our services, you agree to our use of cookies.