Template:Description/doc
More actions
--[[
__ __ _ _ ____ _ _ _
| \/ | ___ __| |_ _| | ___ _| _ \ ___ ___ ___ _ __(_)_ __ | |_(_) ___ _ __
| |\/| |/ _ \ / _` | | | | |/ _ (_) | | |/ _ \/ __|/ __| '__| | '_ \| __| |/ _ \| '_ \
| | | | (_) | (_| | |_| | | __/_| |_| | __/\__ \ (__| | | | |_) | |_| | (_) | | | |
|_| |_|\___/ \__,_|\__,_|_|\___(_)____/ \___||___/\___|_| |_| .__/ \__|_|\___/|_| |_|
|_|
Description is a module implementing functionality of Lua error: bad argument #1 to 'isKnownLanguageTag' (string expected, got nil).
template, which is used by
,
and other language templates.
Authors and maintainers:
- User:Jarekt
]]
local core = require('Module:Core') local p = {}
local function missing_text_error(args) -- Empty text field -> display error message and add maintenance category -- Template:Description/i18n local cat = 'Category:Language templates with no text displayed' local msg = core.formatMessage('I18n/DescriptionError.tab', 'missing text', args.user_lang) local frame = mw.getCurrentFrame() msg = mw.html.create('span'):addClass("error"):wikitext(msg) msg = '[' .. frame:callParserFunction{ name = 'fullurl', args={cat} } .. tostring(msg) .. ']' msg = mw.html.create('span'):addClass("plainlinks"):wikitext(msg) desc = core.langWrapper(args.text_lang, tostring(msg), args) local namespace = mw.title.getCurrentTitle().namespace local LUT = {[0]=1, [6]=1, [10]=1, [14]=1, [100]=1, [106]=1} if LUT[namespace]==1 then desc = desc .. '' .. cat .. '' end return desc end
function p.description(frame) local args = core.getArgs(frame) args.user_lang = args.user_lang or args.lang -- core.getArgs sets args.lang if args.text == nil then -- if no string than add error message and a category return missing_text_error(args) else return core.langWrapper(args.text_lang, args.text, args) end end
return p
Adds language name, in native language (autonym), and colon in front of the text in that language. Also adds machine-readable tags identifying the text as being in that language.
The template automatically sets the following categories:
- Category:Language templates with no text displayed (if parameter #2 is empty)
Usage
{{Description |hover= }}
Template parameters
| Parameter | Description | Default | Status | |
|---|---|---|---|---|
hover3 name | hover text 1 | description text to display | empty | required |
lang_name | language name | Name of the language in that language. This parameter is mostly needed if language code in the parameter 1 is not supported by wikimedia software, or if the language name in front of the text is wrong otherwise. | empty | optional |
ext5 | extension text | extension text shown after the language name before colon (optional, default is empty) | (empty) | optional |
inline | inline | optional boolean, false by default. When set to "true" (or "1", "yes", "on") , forces the template to be displayed inline, so that it does not break the current paragraph (i.e. that makes possible to put several descriptions side by side on a single line) | empty | optional |
Additional information
The template is intended to be used in the following namespaces: no namespace specified
The template is intended to be used by the following user groups: no user group specified
See also
== Localization ==
Add translations to Data:I18n/DescriptionError.tab