This is an archive copy of wikilivres.ca as of 18 February 2017 (from the WikiTeam dump). The original site is closed.

Template:LangSwitch: Difference between revisions

Free texts and images.
Jump to navigation Jump to search
imported>Jarekt
Category:LangSwitch template without English version will be added only to pages without en or default
imported>Yann
m 29 revisions from commons:Template:LangSwitch
 
(2 intermediate revisions by 2 users not shown)
Line 1: Line 1:
<!-- Documentation of code Snippet:
1) "{{#if:{{{lang|}}}|{{{lang}}}|{{int:Lang}}}}" - is the chosen language, either set by parameter "lang=xx"
    or by language of the user "{{int:Lang}}"
2) "{{{ {{#if:{{{lang|}}}|{{{lang}}}|{{int:Lang}}}} |}}}" - is the input parameter matching the language for example {{{xx|}}}
3) Without the fallback templates the LangSwitch template would be
{{{  
{{{  
{{#switch: {{{ {{#if:{{{lang|}}}|{{{lang}}}|{{int:Lang}}}} |}}} // switch based on input parameter matching the language ie. xx
  | ~        = empty                                    // if |xx=~| than the template will return {{{empty}}} which is empty
  |          = {{#if: {{{default|}}} | default | en }}  // if xx is undefined or empty |xx=| than return {{{default}}} or {{{en}}}
  | #default = {{#if:{{{lang|}}}|{{{lang}}}|{{int:Lang}}}} // for all other cases return {{{xx|}}}
}}
|}}}
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))
-->{{{
   {{#switch: {{{ {{#if:{{{lang|}}}|{{{lang}}}|{{int:Lang}}}} |}}}  
   {{#switch: {{{ {{#if:{{{lang|}}}|{{{lang}}}|{{int:Lang}}}} |}}}  
   | ~ = empty
   | ~ = empty
Line 6: Line 20:
     |  = {{#switch: {{{ {{GetFallback2| {{#if:{{{lang|}}}|{{{lang}}}|{{int:Lang}}}} |default=default}} |}}}  
     |  = {{#switch: {{{ {{GetFallback2| {{#if:{{{lang|}}}|{{{lang}}}|{{int:Lang}}}} |default=default}} |}}}  
       | ~        = empty
       | ~        = empty
       |          = {{{default|en}}}  
       |          = {{#if: {{{default|}}} | default | en }}
       | #default = {{GetFallback2| {{#if:{{{lang|}}}|{{{lang}}}|{{int:Lang}}}} |default=default}}  
       | #default = {{GetFallback2| {{#if:{{{lang|}}}|{{{lang}}}|{{int:Lang}}}} |default=default}}  
       }}  
       }}  

Latest revision as of 11:10, 11 February 2012


Documentation


Template:LangSwitch/documentation