Template:Button

From MLB Power Pros Wiki

Revision as of 04:34, 12 February 2023 by Darkshade (Talk | contribs)
(diff) ← Older revision | Current revision (diff) | Newer revision → (diff)
Jump to: navigation, search

<mediawiki xmlns="http://www.mediawiki.org/xml/export-0.10/" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xsi:schemaLocation="http://www.mediawiki.org/xml/export-0.10/ http://www.mediawiki.org/xml/export-0.10.xsd" version="0.10" xml:lang="en">

 <siteinfo>
   <sitename>Wikimedia Commons</sitename>
   <dbname>commonswiki</dbname>
   <base>https://commons.wikimedia.org/wiki/Main_Page</base>
   <generator>MediaWiki 1.40.0-wmf.22</generator>
   <case>first-letter</case>
   <namespaces>
     <namespace key="-2" case="first-letter">Media</namespace>
     <namespace key="-1" case="first-letter">Special</namespace>
     <namespace key="0" case="first-letter" />
     <namespace key="1" case="first-letter">Talk</namespace>
     <namespace key="2" case="first-letter">User</namespace>
     <namespace key="3" case="first-letter">User talk</namespace>
     <namespace key="4" case="first-letter">Commons</namespace>
     <namespace key="5" case="first-letter">Commons talk</namespace>
     <namespace key="6" case="first-letter">File</namespace>
     <namespace key="7" case="first-letter">File talk</namespace>
     <namespace key="8" case="first-letter">MediaWiki</namespace>
     <namespace key="9" case="first-letter">MediaWiki talk</namespace>
     <namespace key="10" case="first-letter">Template</namespace>
     <namespace key="11" case="first-letter">Template talk</namespace>
     <namespace key="12" case="first-letter">Help</namespace>
     <namespace key="13" case="first-letter">Help talk</namespace>
     <namespace key="14" case="first-letter">Category</namespace>
     <namespace key="15" case="first-letter">Category talk</namespace>
     <namespace key="100" case="first-letter">Creator</namespace>
     <namespace key="101" case="first-letter">Creator talk</namespace>
     <namespace key="102" case="first-letter">TimedText</namespace>
     <namespace key="103" case="first-letter">TimedText talk</namespace>
     <namespace key="104" case="first-letter">Sequence</namespace>
     <namespace key="105" case="first-letter">Sequence talk</namespace>
     <namespace key="106" case="first-letter">Institution</namespace>
     <namespace key="107" case="first-letter">Institution talk</namespace>
     <namespace key="460" case="case-sensitive">Campaign</namespace>
     <namespace key="461" case="case-sensitive">Campaign talk</namespace>
     <namespace key="486" case="first-letter">Data</namespace>
     <namespace key="487" case="first-letter">Data talk</namespace>
     <namespace key="490" case="first-letter">GWToolset</namespace>
     <namespace key="491" case="first-letter">GWToolset talk</namespace>
     <namespace key="828" case="first-letter">Module</namespace>
     <namespace key="829" case="first-letter">Module talk</namespace>
     <namespace key="1198" case="first-letter">Translations</namespace>
     <namespace key="1199" case="first-letter">Translations talk</namespace>
     <namespace key="2300" case="case-sensitive">Gadget</namespace>
     <namespace key="2301" case="case-sensitive">Gadget talk</namespace>
     <namespace key="2302" case="case-sensitive">Gadget definition</namespace>
     <namespace key="2303" case="case-sensitive">Gadget definition talk</namespace>
     <namespace key="2600" case="first-letter">Topic</namespace>
   </namespaces>
 </siteinfo>
 <page>
   <title>Template:Button</title>
   <ns>10</ns>
   <id>21197917</id>
   <revision>
     <id>433785053</id>
     <parentid>228419836</parentid>
     <timestamp>2020-07-18T21:58:28Z</timestamp>
     <contributor>
       <username>WOSlinker</username>
       <id>528685</id>
     </contributor>
     <comment>radius direct</comment>
     <model>wikitext</model>
     <format>text/x-wiki</format>
     <text bytes="424" xml:space="preserve"><span class="nowrap" title="this is not a clickable button, it illustrates the button to look for" style="padding:.2em .6em; border:1px solid; border-color:#aaa #555 #555 #aaa; border-radius:3px; background-color:#f2f2f2; Template:Linear-gradient  ">the button</span><noinclude>

Template:Documentation </noinclude></text>

     <sha1>2zxdsb5o5crv7s9fxlrrfbii2u8hsnp</sha1>
   </revision>
 </page>
 <page>
   <title>Template:Dir</title>
   <ns>10</ns>
   <id>4508797</id>
   <revision>
     <id>699751876</id>
     <parentid>570967563</parentid>
     <timestamp>2022-10-27T23:32:02Z</timestamp>
     <contributor>
       <username>Magog the Ogre</username>
       <id>338609</id>
     </contributor>
     <comment>additions requested by Verdy_p (Special:Permalink/699751110#Updating Module:Dir/RTL overrides and Template:Dir)</comment>
     <model>wikitext</model>
     <format>text/x-wiki</format>
     <text bytes="1195" xml:space="preserve">ltr<noinclude>

Template:Documentation

</noinclude></text>

     <sha1>d6bxtsty698mvohoku22d5itays5h7n</sha1>
   </revision>
 </page>
 <page>
   <title>Module:Autotranslate</title>
   <ns>828</ns>
   <id>69441814</id>
   <revision>
     <id>326929091</id>
     <parentid>302995700</parentid>
     <timestamp>2018-11-07T19:35:28Z</timestamp>
     <contributor>
       <username>Jarekt</username>
       <id>164349</id>
     </contributor>
     <minor/>
     <comment>bad instructions in comment</comment>
     <model>Scribunto</model>
     <format>text/plain</format>
     <text bytes="2688" xml:space="preserve">  --[[
 __  __           _       _           _         _        _                       _       _       
|  \/  | ___   __| |_   _| | ___ _   / \  _   _| |_ ___ | |_ _ __ __ _ _ __  ___| | __ _| |_ ___ 
| |\/| |/ _ \ / _` | | | | |/ _ (_) / _ \| | | | __/ _ \| __| '__/ _` | '_ \/ __| |/ _` | __/ _ \
| |  | | (_) | (_| | |_| | |  __/_ / ___ \ |_| | || (_) | |_| | | (_| | | | \__ \ | (_| | ||  __/
|_|  |_|\___/ \__,_|\__,_|_|\___(_)_/   \_\__,_|\__\___/ \__|_|  \__,_|_| |_|___/_|\__,_|\__\___|

Authors and maintainers:
  • User:Zolo - original version
  • User:Jarekt

]]

-- local function to help normalize input arguments local function normalize_input_args(input_args, output_args) for name, value in pairs( input_args ) do if value ~= then -- nuke empty strings if type(name)=='string' then name=string.lower(name) end -- convert to lower case output_args[name] = value end end return output_args end

-- initialize object to be returned local p = {}

--[[ autotranslate

This function is the core part of the Autotranslate template.

Usage from a template: {{#invoke:autotranslate|autotranslate|base=|lang= }}

Parameters:

 frame.args.base - base page name
 frame.args.lang - desired language (often user's native language)
Error Handling:

]] function p.autotranslate(frame)

-- switch to lowercase parameters to make them case independent local args = {} args = normalize_input_args(frame:getParent().args, args) args = normalize_input_args(frame.args, args)

-- get language fallback list if not args.lang or not mw.language.isSupportedLanguage(args.lang) then args.lang = frame:callParserFunction( "int", "lang" ) -- get user's chosen language end local langList = mw.language.getFallbacksFor(args.lang) table.insert(langList,1,args.lang)

-- find base page local base = args.base args.base = nil assert(base and #base>0, 'Base page not provided for autotranslate' ) if not mw.ustring.find(base,':') then -- if base page does not indicate namespace base = 'Template:' .. base -- than assume it is a template end

-- find base template language subpage local page = args.default -- default page if provided or nil otherwise for _, language in ipairs(langList) do if mw.title.new(base .. '/' .. language).exists then page = base .. '/' .. language -- returns only the page break end end assert(page, string.format('No fallback page found for autotranslate (base=%s, lang=%s)', base, args.lang))

-- Transclude Template:Page with template arguments the same as the ones passed to Template:Autotranslate template. return frame:expandTemplate{ title = page, args = args} end

return p</text>

     <sha1>s8od7zfrj3v3cz5lt1l0kbteodckiag</sha1>
   </revision>
 </page>
 <page>
   <title>Template:Tlx</title>
   <ns>10</ns>
   <id>1062268</id>
   <revision>
     <id>191835619</id>
     <parentid>191820407</parentid>
     <timestamp>2016-04-01T06:12:09Z</timestamp>
     <contributor>
       <username>Logan</username>
       <id>575979</id>
     </contributor>
     <comment>reverting, as this broke the template</comment>
     <model>wikitext</model>
     <format>text/x-wiki</format>
     <text bytes="475" xml:space="preserve">{{Tlx<!--

--><!-- --><!-- --><!-- --><!-- --><!-- --><!-- --><!-- --><!-- -->}}<noinclude> Template:Documentation </noinclude></text>

     <sha1>dkyuacf9wzm1r5s8aabv2b15p4crsez</sha1>
   </revision>
 </page>
 <page>
   <title>Template:Linear-gradient</title>
   <ns>10</ns>
   <id>18008944</id>
   <revision>
     <id>355861126</id>
     <parentid>355857104</parentid>
     <timestamp>2019-06-24T00:12:14Z</timestamp>
     <contributor>
       <username>Verdy p</username>
       <id>13466</id>
     </contributor>
     <model>wikitext</model>
     <format>text/x-wiki</format>
     <text bytes="1610" xml:space="preserve"><noinclude> &lt;div style="
</noinclude>background-image:-moz-linear-gradient(<noinclude>start-position</noinclude>,<noinclude>color [stop],...</noinclude>);<noinclude>
</noinclude>background-image:o-linear-gradient(<noinclude>start-position</noinclude>,<noinclude>color [stop],...</noinclude>);<noinclude>
</noinclude>background-image:-webkit-linear-gradient(<noinclude>start-position</noinclude>,<noinclude>color [stop],...</noinclude>);<noinclude>
</noinclude>background-image:linear-gradient(<noinclude>start-position</noinclude>,<noinclude>color [stop],...</noinclude>);<noinclude>
"&gt;Lorem ipsum...&lt;/div&gt;

Template:Documentation</noinclude></text>

     <sha1>cw1va0mnzv2vi50nd5aw8vhg9rhiy9x</sha1>
   </revision>
 </page>
 <page>
   <title>Template:Transclude</title>
   <ns>10</ns>
   <id>9456560</id>
   <revision>
     <id>358320724</id>
     <parentid>35437021</parentid>
     <timestamp>2019-07-16T10:41:02Z</timestamp>
     <contributor>
       <username>4nn1l2</username>
       <id>2002620</id>
     </contributor>
     <minor/>
     <comment>Changed protection level for "Template:Transclude": downgraded protection level per consensus ([Move=Allow only template editors and administrators] (indefinite) [Edit=Allow only template editors and administrators] (indefinite))</comment>
     <model>wikitext</model>
     <format>text/x-wiki</format>
     <text bytes="400" xml:space="preserve">Template:{{{1}}}            <!-- no leading colon, eg "Foo" --><noinclude>

Template:Documentation </noinclude></text>

     <sha1>ob9m2b913drxlie5tgekieudupfrl9n</sha1>
   </revision>
 </page>
 <page>
   <title>Template:Tmpl</title>
   <ns>10</ns>
   <id>106527425</id>
   <revision>
     <id>578776649</id>
     <parentid>568786754</parentid>
     <timestamp>2021-08-06T17:03:07Z</timestamp>
     <contributor>
       <username>CptViraj</username>
       <id>7799326</id>
     </contributor>
     <minor/>
     <comment>Protected "Template:Tmpl": Widely used template: Request at COM:ANB ([Edit=Allow only template editors and administrators] (indefinite) [Move=Allow only template editors and administrators] (indefinite))</comment>
     <model>wikitext</model>
     <format>text/x-wiki</format>
     <text bytes="99" xml:space="preserve"><onlyinclude><includeonly>{{#invoke:Tmpl|renderTmpl}}</includeonly></onlyinclude>

Template:Documentation</text>

     <sha1>pd3axhqea7nbo7qxiyq3aicgysk00ym</sha1>
   </revision>
 </page>
 <page>
   <title>Module:Tmpl</title>
   <ns>828</ns>
   <id>106527281</id>
   <revision>
     <id>578776736</id>
     <parentid>568784752</parentid>
     <timestamp>2021-08-06T17:03:50Z</timestamp>
     <contributor>
       <username>CptViraj</username>
       <id>7799326</id>
     </contributor>
     <minor/>
     <comment>Protected "Module:Tmpl": High-risk Lua module: Request at COM:ANB ([Edit=Allow only template editors and administrators] (indefinite) [Move=Allow only template editors and administrators] (indefinite))</comment>
     <model>Scribunto</model>
     <format>text/plain</format>
     <text bytes="437" xml:space="preserve">-- This is a helper module for Template:tmpl

local this = {}

function this.renderTmpl(frame)

   local args = frame.args
   local pargs = (frame:getParent() or {}).args
   local result = pargs[0] or 
   for k, v in pairs(pargs) do
       local n = tonumber(k) or -1
       if (n >= 1 and n <= 9) then
           result = mw.ustring.gsub( result, '$' .. n, mw.text.trim(v) )
       end
   end
   return result

end

return this</text>

     <sha1>ep2bcs460ax2usm6nvg7v90dlm9e09v</sha1>
   </revision>
 </page>
 <page>
   <title>Template:Documentation</title>
   <ns>10</ns>
   <id>26353596</id>
   <revision>
     <id>710268397</id>
     <parentid>710061475</parentid>
     <timestamp>2022-11-27T20:49:57Z</timestamp>
     <contributor>
       <username>Tacsipacsi</username>
       <id>1998184</id>
     </contributor>
     <comment>Undo revision 710061475 by Sarang (talk): undocumented, unused parameter. This is not a sandbox, this is the LIVE template.</comment>
     <model>wikitext</model>
     <format>text/x-wiki</format>
     <text bytes="726" xml:space="preserve"><!-- {{#invoke:Autotranslate|autotranslate}} is used to avoid "Warning: This page calls Template:Autotranslate which causes a template loop (an infinite recursive call). "-->

<onlyinclude>{{#invoke:Autotranslate|autotranslate | base = Template:Documentation/i18n

|lang    = <Lang> 
|1       = Template:Button/doc
|2       =  
|content = 

}}</onlyinclude></text>

     <sha1>eci5tevagu64g1pdamaseb2nj1i28lz</sha1>
   </revision>
 </page>
 <page>
   <title>Template:Documentation/i18n/en</title>
   <ns>10</ns>
   <id>6324044</id>
   <revision>
     <id>595568821</id>
     <parentid>592024682</parentid>
     <timestamp>2021-10-04T12:10:56Z</timestamp>
     <contributor>
       <username>ExE Boss</username>
       <id>2717823</id>
     </contributor>
     <comment>Updating to match new version of source page: Use <onlyinclude> and {{tmpl}}</comment>
     <model>wikitext</model>
     <format>text/x-wiki</format>
     <text bytes="624" xml:space="preserve"><languages/>

<onlyinclude>Template:Documentation/layout</onlyinclude> Template:Translated tag</text>

     <sha1>69h44ltg592l5fip020y33w80i9cu1v</sha1>
   </revision>
 </page>
 <page>
   <title>Template:Documentation/layout</title>
   <ns>10</ns>
   <id>6324034</id>
   <revision>
     <id>595566422</id>
     <parentid>583896810</parentid>
     <timestamp>2021-10-04T11:56:10Z</timestamp>
     <contributor>
       <username>ExE Boss</username>
       <id>2717823</id>
     </contributor>
     <comment>Use Module:TNTFallback</comment>
     <model>wikitext</model>
     <format>text/x-wiki</format>
     <text bytes="3117" xml:space="preserve"><div id="template-documentation" class="template-documentation"><templatestyles src="Template:Documentation/styles.css" /><!--

--><!-- --><div class="template-documentation-heading mw-content-Template:Dir" lang="" dir="Template:Dir"><!--

 --><span class="template-documentation-title">File:Test Template Info-Icon.svg {{#invoke:TNTFallback|msg|lang=<lang>|I18n/Documentation.tab|other-namespaces-heading|fallback=}}</span><span class="mw-editsection-like plainlinks" id="doc_editlinks"><!--
 -->&#91;&nbsp;<!--
   -->[{{fullurl:Template:Transclude|action=edit&preload=Template:Documentation/preload}} {{#invoke:TNT|msg|lang=<lang>|I18n/Documentation.tab|create-link-display}}]&nbsp;· <!--
 --><nowiki/><!--
 -->{{#invoke:TNTFallback|msg|lang=<lang>|I18n/Documentation.tab|purge-link-display|fallback=}}<!--
 -->&nbsp;&#93;</span></div>

<div class="template-documentation-transcludedfrom mw-content-Template:Dir" lang="" dir="Template:Dir">{{tmpl<!-- -->|0=(text: $1) &mdash; Template:Error<!-- -->|1=[[Template:Transclude]]<!-- -->}}</div> <div class="template-documentation-content" lang="" dir="auto"> {{ Template:DocPageName }} </div> </div><noinclude> </noinclude></text>

     <sha1>osks67b6xf43g1w9fxcjodnhi4f7w2j</sha1>
   </revision>
 </page>
 <page>
   <title>Template:Documentation/styles.css</title>
   <ns>10</ns>
   <id>79561144</id>
   <revision>
     <id>362247927</id>
     <parentid>360699817</parentid>
     <timestamp>2019-08-16T10:34:50Z</timestamp>
     <contributor>
       <username>Kwj2772</username>
       <id>190102</id>
     </contributor>
     <minor/>
     <comment>Protected "Template:Documentation/styles.css": Widely used template ([Edit=Allow only template editors and administrators] (indefinite) [Move=Allow only template editors and administrators] (indefinite))</comment>
     <model>sanitized-css</model>
     <format>text/css</format>
     <text bytes="461" xml:space="preserve">.template-documentation {

margin-top: 1em; clear: both; border: 2px dotted #666; padding: 0.6em; background-color: #ecfcf4; } .template-documentation:after { content: ""; display: block; clear: both; } .template-documentation-heading { padding-bottom: 3px; border-bottom: 1px solid #a2a9b1; margin-bottom: 1ex; } .template-documentation-title { font-size: 150%; } .template-documentation-transcludedfrom { font-size: smaller; font-style: italic; }</text>

     <sha1>h868x8ure6yjgqibg8igavya6ijo6tm</sha1>
   </revision>
 </page>
 <page>
   <title>Template:Documentation subpage</title>
   <ns>10</ns>
   <id>26352739</id>
   <revision>
     <id>591762713</id>
     <parentid>587685640</parentid>
     <timestamp>2021-09-17T09:03:17Z</timestamp>
     <contributor>
       <username>ExE Boss</username>
       <id>2717823</id>
     </contributor>
     <comment>Fullfilling my edit request: Use namespaced categories (Category:Template documentation, Category:Module documentation, and Category:User documentation)</comment>
     <model>wikitext</model>
     <format>text/x-wiki</format>
     <text bytes="707" xml:space="preserve"><includeonly><!--

--></includeonly><!-- show on doc pages only --><noinclude>Template:Documentation</noinclude></text>

     <sha1>e1m6vc2tdw71dgnw3k58bhv9fdxxadi</sha1>
   </revision>
 </page>
 <page>
   <title>Module:TNTFallback</title>
   <ns>828</ns>
   <id>110706998</id>
   <revision>
     <id>699362934</id>
     <parentid>597010902</parentid>
     <timestamp>2022-10-26T16:11:23Z</timestamp>
     <contributor>
       <username>Jonesey95</username>
       <id>2266634</id>
     </contributor>
     <comment>require strict per TPER</comment>
     <model>Scribunto</model>
     <format>text/plain</format>
     <text bytes="1909" xml:space="preserve">--------------------------------------------------------------------------------

-- This module implements a wrapper for Module:TNT that allows returning -- a fallback message; used by Template:Documentation. -- -- @module TNTFallback -- @alias p -- @author User:ExE Boss -- @require Module:No globals -- @require Module:TNT


require("strict"); local TNT = require("Module:TNT");

local p = {};


-- Based on Module:TNT's `msg` function, -- but takes an optional `fallback` parameter.


function p.msg(frame) local dataset, key; local params = { n = 0 }; local lang = nil; local fallback = nil;

for k, v in pairs(frame.args) do if (k == 1) then dataset = v; elseif (k == 2) then key = v; elseif (type(k) == "number" and k > 2) then local i = k - 2; params[i] = v; params.n = math.max(params.n, i); elseif ((k == "lang") and (v ~= "_")) then lang = v; elseif ((k == "fallback") and (v ~= "")) then fallback = v; end end

local result; if (lang) then result = TNT.formatInLanguage(lang, dataset, key, unpack(params, 1, params.n)); else result = TNT.format(dataset, key, unpack(params, 1, params.n)); end

if (fallback and ( -- not translated (result and result == TNT.formatInLanguage("en", dataset, key, unpack(params, 1, params.n))) -- no message or (not result) )) then if (not lang) then if (frame:callParserFunction("int:lang") ~= "en") then return mw.message.newRawMessage(fallback, unpack(params, 1, params.n)):plain(); end elseif (lang ~= "en") then return mw.message.newRawMessage(fallback, unpack(params, 1, params.n)):plain(); end end

return result; end

return p;</text>

     <sha1>izvc5dfq9gm4cs3usy8e4s3mli1hhiu</sha1>
   </revision>
 </page>
 <page>
   <title>Module:TNT</title>
   <ns>828</ns>
   <id>54808843</id>
   <revision>
     <id>439418106</id>
     <parentid>415588695</parentid>
     <timestamp>2020-08-14T13:52:16Z</timestamp>
     <contributor>
       <username>Jarekt</username>
       <id>164349</id>
     </contributor>
     <minor/>
     <comment>Protected "Module:TNT": High-risk Lua module ([Edit=Allow only template editors and administrators] (indefinite) [Move=Allow only template editors and administrators] (indefinite))</comment>
     <model>Scribunto</model>
     <format>text/plain</format>
     <text bytes="6220" xml:space="preserve">--

-- INTRO: (!!! DO NOT RENAME THIS PAGE !!!) -- This module allows any template or module to be copy/pasted between -- wikis without any translation changes. All translation text is stored -- in the global Data:*.tab pages on Commons, and used everywhere. -- -- SEE: https://www.mediawiki.org/wiki/Multilingual_Templates_and_Modules -- -- ATTENTION: -- Please do NOT rename this module - it has to be identical on all wikis. -- This code is maintained at https://www.mediawiki.org/wiki/Module:TNT -- Please do not modify it anywhere else, as it may get copied and override your changes. -- Suggestions can be made at https://www.mediawiki.org/wiki/Module_talk:TNT -- -- DESCRIPTION: -- The "msg" function uses a Commons dataset to translate a message -- with a given key (e.g. source-table), plus optional arguments -- to the wiki markup in the current content language. -- Use lang=xx to set language. Example: -- -- {{#invoke:TNT | msg -- | I18n/Template:Graphs.tab <!-- https://commons.wikimedia.org/wiki/Data:I18n/Template:Graphs.tab --> -- | source-table <!-- uses a translation message with id = "source-table" --> -- | param1 }} <!-- optional parameter --> -- -- -- The "doc" function will generate the <templatedata> parameter documentation for templates. -- This way all template parameters can be stored and localized in a single Commons dataset. -- NOTE: "doc" assumes that all documentation is located in Data:Templatedata/* on Commons. -- -- {{#invoke:TNT | doc | Graph:Lines }} -- uses https://commons.wikimedia.org/wiki/Data:Templatedata/Graph:Lines.tab -- if the current page is Template:Graph:Lines/doc --

local p = {} local i18nDataset = 'I18n/Module:TNT.tab'

-- Forward declaration of the local functions local sanitizeDataset, loadData, link, formatMessage

function p.msg(frame) local dataset, id local params = {} local lang = nil for k, v in pairs(frame.args) do if k == 1 then dataset = mw.text.trim(v) elseif k == 2 then id = mw.text.trim(v) elseif type(k) == 'number' then table.insert(params, mw.text.trim(v)) elseif k == 'lang' and v ~= '_' then lang = mw.text.trim(v) end end return formatMessage(dataset, id, params, lang) end

-- Identical to p.msg() above, but used from other lua modules -- Parameters: name of dataset, message key, optional arguments -- Example with 2 params: format('I18n/Module:TNT', 'error_bad_msgkey', 'my-key', 'my-dataset') function p.format(dataset, key, ...) local checkType = require('libraryUtil').checkType checkType('format', 1, dataset, 'string') checkType('format', 2, key, 'string') return formatMessage(dataset, key, {...}) end


-- Identical to p.msg() above, but used from other lua modules with the language param -- Parameters: language code, name of dataset, message key, optional arguments -- Example with 2 params: formatInLanguage('es', I18n/Module:TNT', 'error_bad_msgkey', 'my-key', 'my-dataset') function p.formatInLanguage(lang, dataset, key, ...) local checkType = require('libraryUtil').checkType checkType('formatInLanguage', 1, lang, 'string') checkType('formatInLanguage', 2, dataset, 'string') checkType('formatInLanguage', 3, key, 'string') return formatMessage(dataset, key, {...}, lang) end

-- Obsolete function that adds a 'c:' prefix to the first param. -- "Sandbox/Sample.tab" -> 'c:Data:Sandbox/Sample.tab' function p.link(frame) return link(frame.args[1]) end

function p.doc(frame) local dataset = 'Templatedata/' .. sanitizeDataset(frame.args[1]) return frame:extensionTag('templatedata', p.getTemplateData(dataset)) .. formatMessage(i18nDataset, 'edit_doc', {link(dataset)}) end

function p.getTemplateData(dataset) -- TODO: add '_' parameter once lua starts reindexing properly for "all" languages local data = loadData(dataset) local names = {} for _, field in pairs(data.schema.fields) do table.insert(names, field.name) end

local params = {} local paramOrder = {} for _, row in pairs(data.data) do local newVal = {} local name = nil for pos, val in pairs(row) do local columnName = names[pos] if columnName == 'name' then name = val else newVal[columnName] = val end end if name then params[name] = newVal table.insert(paramOrder, name) end end

-- Work around json encoding treating {"1":{...}} as an [{...}] params['zzz123']=

local json = mw.text.jsonEncode({ params=params, paramOrder=paramOrder, description=data.description })

json = string.gsub(json,'"zzz123":"",?', "")

return json end

-- Local functions

sanitizeDataset = function(dataset) if not dataset then return nil end dataset = mw.text.trim(dataset) if dataset == then return nil elseif string.sub(dataset,-4) ~= '.tab' then return dataset .. '.tab' else return dataset end end

loadData = function(dataset, lang) dataset = sanitizeDataset(dataset) if not dataset then error(formatMessage(i18nDataset, 'error_no_dataset', {})) end

-- Give helpful error to thirdparties who try and copy this module. if not mw.ext or not mw.ext.data or not mw.ext.data.get then error('Missing JsonConfig extension; Cannot load https://commons.wikimedia.org/wiki/Data:' .. dataset) end

local data = mw.ext.data.get(dataset, lang)

if data == false then if dataset == i18nDataset then -- Prevent cyclical calls error('Missing Commons dataset ' .. i18nDataset) else error(formatMessage(i18nDataset, 'error_bad_dataset', {link(dataset)})) end end return data end

-- Given a dataset name, convert it to a title with the 'commons:data:' prefix link = function(dataset) return 'c:Data:' .. mw.text.trim(dataset or ) end

formatMessage = function(dataset, key, params, lang) for _, row in pairs(loadData(dataset, lang).data) do local id, msg = unpack(row) if id == key then local result = mw.message.newRawMessage(msg, unpack(params or {})) return result:plain() end end if dataset == i18nDataset then -- Prevent cyclical calls error('Invalid message key "' .. key .. '"') else error(formatMessage(i18nDataset, 'error_bad_msgkey', {key, link(dataset)})) end end

return p</text>

     <sha1>icfixo3zxiew6gqg3s5h19xr03x3wkh</sha1>
   </revision>
 </page>
 <page>
   <title>Template:Button/doc</title>
   <ns>10</ns>
   <id>21197931</id>
   <revision>
     <id>570832290</id>
     <parentid>115777626</parentid>
     <timestamp>2021-06-23T11:46:24Z</timestamp>
     <contributor>
       <username>Vis M</username>
       <id>1738683</id>
     </contributor>
     <comment>/* See also */</comment>
     <model>wikitext</model>
     <format>text/x-wiki</format>
     <text bytes="1187" xml:space="preserve">Template:Documentation subpage

<!-- Categories and interwikis go at the bottom of this page. -->

This template provides a "clickable button" formatting style for text. It is not clickable, and care should be taken when using it to avoid readers thinking the result may be. (It has an explanatory tooltip for users hovering over it, but that may not always be displayed, or only displayed after too long a delay, so that it may not show up to people trying to click it.)

Usage

Alternatively, Template:Tlx also produces button text

See also

<includeonly> <!-- Interwikis go on Wikidata, please add only Categories here --> </includeonly></text>

     <sha1>77zminfnl63ksjm32e5o0lhr9eryutu</sha1>
   </revision>
 </page>

</mediawiki>

Personal tools