Module:Category main article/doc: Difference between revisions

Content deleted Content added
create
 
Create new #Text output detailing how to translate the string outputted by the module
 
(16 intermediate revisions by 13 users not shown)
Line 1:
{{high-use}}
This module produces hatnote saying "The main article for this category is x." It implements the {{tl|cat main}} template.
{{Lua|Module:Hatnote|Module:Format link|Module:Yesno|Module:TableTools|Module:Arguments}}
This module produces hatnote saying "The main article for this category is x." It implements the {{tl|catCategory main article}} template.
 
== Use from wikitext ==
 
This module should usually be used via the {{tl|catCategory main article}} template. However, it can also be used from #invoke with the syntax <code><nowiki>{{#invoke:CatCategory main article|catMain|</nowiki>''parameters''<nowiki>}}</nowiki></code>. Please see the {{tl|catCategory main article}} template documentation for available parameters.
 
== Use from other Lua modules ==
Line 9 ⟶ 11:
Load the module:
 
<sourcesyntaxhighlight lang="lua">
local mCatMain = require('Module:CatCategory main article')
</syntaxhighlight>
</source>
 
You can then use the _catMain function like this:
 
<sourcesyntaxhighlight lang="lua">
mCatMain._catMain(options, ...)
</syntaxhighlight>
</source>
 
<var>options</var> is an optional table that can be used to configure the function's output. There are two available options, "article" and "selfref".
Line 26 ⟶ 28:
 
; Example 1
<sourcesyntaxhighlight lang="lua">
mCatMain._catMain(nil, 'Foo')
</syntaxhighlight>
</source>
Produces:
:<code><nowiki><div class="hatnote relarticle mainarticle">The main article for this [[Help:Categories|category]] is '''[[Foo]]'''.</div></nowiki></code>
Line 35 ⟶ 37:
 
; Example 2
<sourcesyntaxhighlight lang="lua">
mCatMain._catMain(nil, 'Foo', 'Bar', 'Baz')
</syntaxhighlight>
</source>
Produces:
:<code><nowiki><div class="hatnote relarticle mainarticle">The main articles for this [[Help:Categories|category]] are '''[[Foo]]''', '''[[Bar]]''' and '''[[Baz]]'''.</div></nowiki></code>
Line 44 ⟶ 46:
 
; Example 3
<sourcesyntaxhighlight lang="lua">
mCatMain._catMain({article = false}, 'Foo')
</syntaxhighlight>
</source>
Produces:
:<code><nowiki><div class="hatnote relarticle mainarticle">The main page for this [[Help:Categories|category]] is '''[[Foo]]'''.</div></nowiki></code>
Line 56 ⟶ 58:
This module uses [[Module:Hatnote]] to format the hatnote text.
 
=== Text output ===
<includeonly>{{#ifeq:{{SUBPAGENAME}}|sandbox||
This module has five lines that must be translated when exported to wikis in other languages.
<!-- Categories go here and interwikis go in Wikidata. -->
 
{| class="wikitable sortable"
|-
! scope="col" | Variable
! scope="col" | Code
! scope="col" colspan="2" | Translatable text
|-
! scope="row" rowspan="3" | {{Code|pagetype}}
| {{Code|lang=html+handlebars|1=
pagetype = yesno(options.article) ~= false and 'article' or 'page'
}}
| {{Code|1=article}}
| {{Code|1=page}}
|-
| {{Code|lang=html+handlebars|1=
pagetype = mw.title.new(page).namespace == 0 and "article" or "page"
}}
| {{Code|1=article}}
| {{Code|1=page}}
|-
| {{Code|lang=html+handlebars|1=
pagetype = "article"
}}
| colspan="2" | {{Code|1=article}}
|-
! scope="row" rowspan="2" | {{Code|stringToFormat}}
| {{Code|lang=html+handlebars|1=
stringToFormat = 'The main %ss for this [[Help:Categories|category]] are %s.'
}}
| colspan="2" | {{Code|1=The main %ss for this [[Help:Categories|category]] are %s.}}
|-
| {{Code|lang=html+handlebars|1=
stringToFormat = 'The main %s for this [[Help:Categories|category]] is %s.'
}}
| colspan="2" | {{Code|1=The main %s for this [[Help:Categories|category]] is %s.}}
|}
 
<includeonly>{{#ifeq:{{SUBPAGENAME}}|sandbox other||
<!-- Categories go here and interwikis go in Wikidata. -->
[[Category:Hatnote modules]]
}}</includeonly>
<noinclude>
[[Category:Module documentation pages]]
</noinclude>