https://wiktenauer.com/index.php?title=Template:LangSwitch&feed=atom&action=historyTemplate:LangSwitch - Revision history2024-03-28T11:15:36ZRevision history for this page on the wikiMediaWiki 1.34.2https://wiktenauer.com/index.php?title=Template:LangSwitch&diff=29074&oldid=prevMichael Chidester: 29 revisions2012-10-14T01:30:49Z<p>29 revisions</p>
<p><b>New page</b></p><div><!-- Documentation of code Snippet: <br />
1) "{{#if:{{{lang|}}}|{{{lang}}}|{{int:Lang}}}}" - is the chosen language, either set by parameter "lang=xx" <br />
or by language of the user "{{int:Lang}}"<br />
2) "{{{ {{#if:{{{lang|}}}|{{{lang}}}|{{int:Lang}}}} |}}}" - is the input parameter matching the language for example {{{xx|}}}<br />
3) Without the fallback templates the LangSwitch template would be <br />
{{{ <br />
{{#switch: {{{ {{#if:{{{lang|}}}|{{{lang}}}|{{int:Lang}}}} |}}} // switch based on input parameter matching the language ie. xx<br />
| ~ = empty // if |xx=~| than the template will return {{{empty}}} which is empty<br />
| = {{#if: {{{default|}}} | default | en }} // if xx is undefined or empty |xx=| than return {{{default}}} or {{{en}}}<br />
| #default = {{#if:{{{lang|}}}|{{{lang}}}|{{int:Lang}}}} // for all other cases return {{{xx|}}}<br />
}}<br />
|}}}<br />
<br />
The actual template is bit more complicated calling templates {{GetFallback}} and {{GetFallback2}} to allow language fallback. For example if desired encoding is "sr-ec" (Serbian using Cyrillic alphabet) than the fall back would be "sr" (Serbian))<br />
-->{{{ <br />
{{#switch: {{{ {{#if:{{{lang|}}}|{{{lang}}}|{{int:Lang}}}} |}}} <br />
| ~ = empty<br />
| = {{#switch: {{{ {{GetFallback| {{#if:{{{lang|}}}|{{{lang}}}|{{int:Lang}}}} |default=default}} |}}} <br />
| ~ = empty<br />
| = {{#switch: {{{ {{GetFallback2| {{#if:{{{lang|}}}|{{{lang}}}|{{int:Lang}}}} |default=default}} |}}} <br />
| ~ = empty<br />
| = {{#if: {{{default|}}} | default | en }}<br />
| #default = {{GetFallback2| {{#if:{{{lang|}}}|{{{lang}}}|{{int:Lang}}}} |default=default}} <br />
}} <br />
| #default = {{GetFallback| {{#if:{{{lang|}}}|{{{lang}}}|{{int:Lang}}}} |default=default}} <br />
}}<br />
| #default = {{#if:{{{lang|}}}|{{{lang}}}|{{int:Lang}}}} <br />
}} <br />
|}}}<includeonly>{{#ifeq:{{NAMESPACE}}|File||{{#if:{{{en|}}}{{{default|}}}{{{nocat|<noinclude>1</noinclude>}}}||[[Category:LangSwitch template without English version]]}}}}</includeonly><noinclude><br />
<br />
{{Documentation}}<br />
<br />
</noinclude></div>Michael Chidester