Difference between revisions of "Template:Weather inline"
Jump to navigation
Jump to search
Margotbean (talk | contribs) |
(Revamp to have all same features as Template:Season) |
||
Line 1: | Line 1: | ||
− | <includeonly>{{# | + | <includeonly><!-- |
− | | | + | // Define the list of recognized weather names |
− | | | + | // First column=icon name -> same in all languages |
− | | | + | // Second column=displayed text -> needs translation |
− | | | + | // All other values are synonyms |
− | | | + | -->{{ParseInputValues|code=weather|| |
− | | | + | ,Any, Any, All, Always, |
− | + | ,Sunny, Sun, | |
+ | ,Pollen fall, Wind, Pollen, Polleny, Windy, | ||
+ | ,Pollen spring, Wind, Springwind, | ||
+ | ,Rain, Rain, Rainy, | ||
+ | ,Thunderstorm, Storm, Stormy, | ||
+ | ,Snow, Snow, Snowy | ||
+ | }}<!-- | ||
+ | // The name of the weather wiki page | ||
+ | -->{{#arraydefine:$lang_weatherlink|Weather}}<!-- | ||
+ | |||
+ | // END OF translated text | ||
+ | |||
+ | // Check whether there's already a file link in {{{1}}}... implying this is probably a recursive call. Return immediately | ||
+ | -->{{#if:{{#pos:{{{1|}}}|{{Bracket|2}}File}}|{{{1}}}|<!-- | ||
+ | // Parse input data, then loop over all extracted entries | ||
+ | -->{{#arraydefine:$wweather|{{ParseInputValues|code=weather|{{{1|}}}|default=true}}}}<!-- | ||
+ | -->{{#arrayprint:$wweather||@weather@|<!-- | ||
+ | // Convert @weather@ (icon name) into displayed text | ||
+ | -->{{#arraydefine:$wlink_text|{{ParseInputValues|code=weather|@weather@|translate=true}}}}<!-- | ||
+ | |||
+ | // On first entry, add sort-key if requested. On other entries, add space and bullet. | ||
+ | -->{{#ifexpr:{{#arraysearch:$wweather|@weather@}}>0 | ||
+ | | •  | ||
+ | |{{#if:{{{sortkey|}}}| | ||
+ | <span class="sortkey" style="display:none;">{{#if:{{#arrayprint:$wlink_text}} | ||
+ | |{{#expr:{{ParseInputValues|code=weather|@weather@|translate=index}}+1}} | ||
+ | |0}}</span> | ||
+ | }}}}<span style="display:inline; margin-right:0; white-space: nowrap"><!-- | ||
+ | |||
+ | // Display unmatched text (detected by empty value for $wlink_text) | ||
+ | // And also handle text_only option | ||
+ | -->{{#ifeq:{{#arrayprint:$wlink_text}}| | ||
+ | | {{ucfirst:@weather@}} | ||
+ | | {{#if:{{{text_only|}}} | ||
+ | | {{#if:{{{no_translate|}}}|@weather@|{{#arrayprint:$wlink_text}}}} | ||
+ | | <!-- | ||
+ | |||
+ | // Display the normal cases: first display icon (except for Any)<!-- | ||
+ | -->{{#ifeq:@weather@|Any||[[File:@weather@.png| | ||
+ | {{#if:{{{size|}}}|{{{size}}}px}} | link={{#arrayprint:$wlink_text}} | alt=]] }}<!-- | ||
+ | |||
+ | // Add link | ||
+ | -->[[{{#arrayprint:$lang_weatherlink}}|{{#arrayprint:$wlink_text}}]]<!-- | ||
+ | -->}}}}</span>}}}}</includeonly><noinclude>{{Englishdoc}}{{#ifexist:{{FULLPAGENAME}}/doc |<nowiki/> | ||
+ | {{{{FULLPAGENAME}}/doc}} }}</noinclude> |
Revision as of 16:55, 10 September 2020
Description
This template displays the icon for the type of weather, plus a link to the associated wiki page.
Use
{{Weather inline|type of weather|width (optional)}}
Valid Parameters
There are 9 valid types of weather. All are case-insensitive.
- All / Any = Template:ParseInputValues[[File:Template:ParseInputValues.png|
| link=Template:ParseInputValues | alt=]] [[Weather|Template:ParseInputValues]]
- Sun = Template:ParseInputValues[[File:Template:ParseInputValues.png|
| link=Template:ParseInputValues | alt=]] [[Weather|Template:ParseInputValues]]
- Springwind = Template:ParseInputValues[[File:Template:ParseInputValues.png|
| link=Template:ParseInputValues | alt=]] [[Weather|Template:ParseInputValues]]
- Fallwind = Template:ParseInputValues[[File:Template:ParseInputValues.png|
| link=Template:ParseInputValues | alt=]] [[Weather|Template:ParseInputValues]]
- Rain = Template:ParseInputValues[[File:Template:ParseInputValues.png|
| link=Template:ParseInputValues | alt=]] [[Weather|Template:ParseInputValues]]
- Storm = Template:ParseInputValues[[File:Template:ParseInputValues.png|
| link=Template:ParseInputValues | alt=]] [[Weather|Template:ParseInputValues]]
- Snow = Template:ParseInputValues[[File:Template:ParseInputValues.png|
| link=Template:ParseInputValues | alt=]] [[Weather|Template:ParseInputValues]]
- Festival = Template:ParseInputValues[[File:Template:ParseInputValues.png|
| link=Template:ParseInputValues | alt=]] [[Weather|Template:ParseInputValues]]
Width
Specify the width in pixels, and include "px".
{{Weather inline|Snow|width=24px}}
Template:ParseInputValues[[File:Template:ParseInputValues.png|
| link=Template:ParseInputValues | alt=]] [[Weather|Template:ParseInputValues]]