Rye Greenwood (discussion | contributions) (Rework for correct French display) |
Rye Greenwood (discussion | contributions) (sync :: en revid:1097454::) |
||
(2 versions intermédiaires par un autre utilisateur non affichées) | |||
Ligne 1 : | Ligne 1 : | ||
<!-- |
<!-- |
||
− | // |
+ | //load localization info: |
− | -->{{ |
+ | -->{{icon-version/l10n}}<!-- |
⚫ | |||
− | -->|full=3DS version<!-- |
||
− | -->|link=3DS version<!-- |
||
⚫ | |||
− | -->{{l10n/register|3ds_version|de<!-- |
||
⚫ | |||
− | -->|full=3DS-Version<!-- |
||
− | -->|link=3DS-Version<!-- |
||
− | -->}}<!-- |
||
− | -->{{l10n/register|3ds_version|fr<!-- |
||
− | -->|short=3DS<!-- |
||
− | -->|full=Version 3DS<!-- |
||
− | -->|link=Version 3DS<!-- |
||
− | -->}}<!-- |
||
Ligne 36 : | Ligne 22 : | ||
-->{{#if:{{{nl|}}}{{{nolink|}}}|{{#vardefine:_v_link|}}}}<!-- |
-->{{#if:{{{nl|}}}{{{nolink|}}}|{{#vardefine:_v_link|}}}}<!-- |
||
-->{{#if:{{{short|}}}|{{#vardefine:_v_short|y}}}}<!-- |
-->{{#if:{{{short|}}}|{{#vardefine:_v_short|y}}}}<!-- |
||
− | //glue: |
+ | //glue: must not "short" |
-->{{#vardefine:_v_glue|{{#ifeq:{{#var:_v_icon}}{{#var:_v_text}}|yy|{{#if:{{#var:_v_short}}||{{{glue| }}}}}}}}}<!-- |
-->{{#vardefine:_v_glue|{{#ifeq:{{#var:_v_icon}}{{#var:_v_text}}|yy|{{#if:{{#var:_v_short}}||{{{glue| }}}}}}}}}<!-- |
||
//link and display: |
//link and display: |
||
− | -->{{#vardefine:_v_link_target|{{l10n| |
+ | -->{{#vardefine:_v_link_target|{{l10n|icon-version|link_3ds}}}}<!-- |
− | -->{{#vardefine: |
+ | -->{{#vardefine:_v_display_text|<!-- |
⚫ | |||
⚫ | |||
− | + | -->{{#vardefine:_v_base_text|<!-- |
|
⚫ | |||
− | -->{{#dplreplace:{{l10n|3ds_version|short}}|/(.*?)\s*3DS.*/|$1}}<!-- |
||
− | + | -->}}<!-- |
|
− | + | -->{{#if:{{#var:_v_icon}}|<!-- |
|
− | + | -->{{#if:{{{t|}}}|<!-- |
|
+ | --><span style="display:none">3DS</span>__¤__icon:3DS__¤__{{#var:_v_glue}}{{{t}}}<!-- |
||
⚫ | |||
− | --> |
+ | -->|<!-- |
+ | // replace whitespace surrounding the "3DS" part of the string by glue |
||
− | -->{{#vardefine:_v_display_text_2|<!-- replacement text for the 3DS icon (hidden "3DS" e.g. for TOC heading) or, if using no icon, complete regular text |
||
− | -->{{# |
+ | -->{{#vardefine:_v_base_text|{{#rreplace:{{#var:_v_base_text}}|/\s+3DS/|{{#var:_v_glue}}3DS}}}}<!-- |
− | -->{{# |
+ | -->{{#vardefine:_v_base_text|{{#rreplace:{{#var:_v_base_text}}|/3DS\s+/|3DS{{#var:_v_glue}}}}}}<!-- |
+ | // add a hidden 3DS for TOC heading. The "__¤__icon:3DS__¤__" part will be replaced by the icon |
||
− | + | -->{{#replace:{{#var:_v_base_text}}|3DS|<span style="display:none">3DS</span>__¤__icon:3DS__¤__}}<!-- |
|
− | -->|<!-- |
||
⚫ | |||
− | -->{{#dplreplace:{{l10n|3ds_version|full}}|/.*?(\s*)3DS(\s*).*/|<span style="display:none">$13DS$2</span>}}<!-- |
||
− | + | -->|<!-- |
|
− | --> |
+ | -->{{#var:_v_base_text}}<!-- |
⚫ | |||
⚫ | |||
− | -->}}<!-- |
||
− | -->}}<!-- |
||
− | -->{{#vardefine:_v_display_text_3|<!-- text behind the 3DS icon |
||
⚫ | |||
⚫ | |||
− | -->{{#dplreplace:{{l10n|3ds_version|short}}|/.*?3DS\s*(.*)/|$1}}<!-- |
||
− | -->|<!-- |
||
− | -->{{#dplreplace:{{l10n|3ds_version|full}}|/.*?3DS\s*(.*)/|$1}}<!-- |
||
− | -->}}<!-- |
||
− | -->}}<!-- |
||
− | -->}}<!-- |
||
⚫ | |||
− | -->{{#if:{{{t|}}}|<!-- |
||
− | -->{{#if:{{#var:_v_display_text_1}}|{{#vardefine:_v_display_text_1|{{{t}}}}}}}<!-- |
||
− | -->{{#if:{{#var:_v_display_text_3}}|{{#vardefine:_v_display_text_3|{{{t}}}}}}}<!-- |
||
-->}}<!-- |
-->}}<!-- |
||
− | |||
-- start output -- |
-- start output -- |
||
⚫ | |||
⚫ | |||
− | -->{{#if:{{#var:_v_display_text_1}}|<!-- |
||
− | -->{{#if:{{#var:_v_link}}|<!-- if need a link: |
||
⚫ | |||
⚫ | |||
− | -->{{#var:_v_display_text_1}}<!-- |
||
− | -->}}<!-- |
||
⚫ | |||
− | -->{{#var:_v_glue}}<!-- |
||
− | -->}}<!-- |
||
− | -->}}<!-- |
||
− | -->}}<!-- |
||
// ICON |
// ICON |
||
− | -->{{#if:{{#var:_v_icon}}|<!-- |
+ | -->{{#if:{{#var:_v_icon}}|{{#vardefine:_v_icon|<!-- |
//width & height, without "px". |
//width & height, without "px". |
||
-->{{#vardefine:_v_width|{{{width|}}}}}<!-- |
-->{{#vardefine:_v_width|{{{width|}}}}}<!-- |
||
Ligne 108 : | Ligne 65 : | ||
-->}}<!-- |
-->}}<!-- |
||
//output |
//output |
||
− | -->[[File:3DS.svg|{{#var:_v_width}}x{{#var:_v_height}}px|link={{#if:{{#var:_v_link}}|{{#var:_v_link_target}}}}|{{l10n| |
+ | -->[[File:3DS.svg|{{#var:_v_width}}x{{#var:_v_height}}px|link={{#if:{{#var:_v_link}}|{{#var:_v_link_target}}}}|{{l10n|icon-version|text_3ds}}]]<!-- |
− | -->}}<!-- |
+ | -->}}}}<!-- |
⚫ | |||
− | //TEXT 2: |
||
⚫ | |||
− | -->{{#var:_v_display_text_2}}<!-- |
||
− | //TEXT 3: |
||
-->{{#if:{{#var:_v_text}}|<!-- |
-->{{#if:{{#var:_v_text}}|<!-- |
||
− | -->{{#if:{{#var: |
+ | -->{{#if:{{#var:_v_icon}}|<!-- if we need to include the icon: |
+ | // split displaytext into pre- and post-icon parts. Since those parts likely begin or end with whitespace, we add Extension:ParserPower's "\0" sequence, which protects the leading/trailing whitespace from being trimmed by #if or #vardefine. The sequence is removed again by #uesc |
||
− | -->{{#if:{{#var:_v_icon}}|<!-- |
||
+ | -->{{#vardefine:_v_display_text_pre|{{#explode:{{#var:_v_display_text}}|__¤__icon:3DS__¤__|0|2}}\0}}<!-- |
||
− | -->{{#var:_v_glue}}<!-- |
||
+ | -->{{#vardefine:_v_display_text_post|\0{{#explode:{{#var:_v_display_text}}|__¤__icon:3DS__¤__|1|2}}}}<!-- |
||
⚫ | |||
+ | -->{{#if:{{#uesc:{{#var:_v_display_text_pre}}}}|[[{{#var:_v_link_target}}|{{#uesc:{{#var:_v_display_text_pre}}}}]]}}<!-- |
||
⚫ | |||
+ | -->{{#if:{{#uesc:{{#var:_v_display_text_post}}}}|[[{{#var:_v_link_target}}|{{#uesc:{{#var:_v_display_text_post}}}}]]}}<!-- |
||
+ | -->|<!-- else: no link |
||
⚫ | |||
⚫ | |||
⚫ | |||
-->}}<!-- |
-->}}<!-- |
||
− | + | -->|<!-- else: no icon |
|
− | + | -->{{#if:{{#var:_v_link}}|<!-- if we need a link: |
|
⚫ | |||
⚫ | |||
⚫ | |||
− | -->{{#var:_v_display_text_3}}<!-- |
||
− | -->}}<!-- |
+ | -->{{#var:_v_display_text}}<!-- |
− | + | -->}}<!-- |
|
⚫ | |||
-->}}<!-- |
-->}}<!-- |
||
Dernière version du 5 janvier 2021 à 18:35
An all-in-one template for display 3DS version link/text.
When a simple icon isn't enough, used to mark content as '3DS Only' within a sentence or paragraph. (use Template:Exclusive to mark 3DS exclusive pages or sections)
The "short" parameter value can be used to display "3DS" rather than "3DS version". (note that is different from {{icon|3ds}})
Usage
{{3DS version|MODE|nl/nolink=y|short=y|glue= |t=display text}}
NOTE: When there is icon in output, this template will add a hidden 3DS text after it. So this template can used in heading safely. for example =={{3DS version}}==
will display "3DS version" in TOC.
- unnamed parameter 1
Output mode, can be icon/text/short:
- icon: output icon only.
- text: output text only.
- short: output icon and short text. Note: This is different from
{{3DS version|icon}}
, since there is a hidden 3DS more, so it can be used in heading.
- nl/nolink=y/yes
Only output icon and/or text, don't make them be links.
- short=y/yes
Output short text. {{3DS version|short=y}}
has the same effect as {{3DS version|short}}
- t=display text
Customize text. Will override short=y, have no effect when mode=icon. NOTE: This will disabled the hidden 3DS output.
- glue=
Customize the glue text between icon and text. default is
- size, width, height, scale, small
Customize icon display, see {{icon}} for detail.
example
code | output | note |
---|---|---|
{{3DS version}} | Version | With a hidden "3DS" after icon. |
{{3DS version|icon}} | Without a hidden "3DS" after icon, same as {{icon|3ds}}
| |
{{3DS version|text}} | Version 3DS | No hidden text. |
{{3DS version|short}} | With a hidden "3DS" after icon. | |
{{3DS version|text|short=y}} | 3DS | |
{{3DS version|short=y}} | same as {{3DS version|short}}
| |
{{3DS version|t=sometext}} | sometext | customize display text |
{{3DS version|nl=y}} | Version | No link, With a hidden "3DS" after icon. |
{{3DS version|text|nl=y}} | Version 3DS | No link, no hidden text. |
{{3DS version|short|nl=y}} | No link, with a hidden "3DS" after icon. | |
{{3DS version|glue=-}} | Version- | With a hidden "3DS" after glue. |
{{3DS version|scale=2}} | Version | see {{icon}} |
{{3DS version|icon|small=y}} | see {{icon}} |