Diferencia entre revisiones de «Plantilla:LangSwitch»

De Wikimedia Small Projects
(fix of faulty logic (at least I hope so))
(add comments)
Línea 1: Línea 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

Revisión del 02:55 19 abr 2011


[ver · editar · actualizar]
Documentación de plantilla
Aún no se han escrito las instrucciones sobre esta plantilla. Añádelas.