:LangSwitch/doc

Revi HQ
metawiki>Verdy p님의 2014년 1월 18일 (토) 00:06 판

Usage

Returns a value depending on a given language, using reasonnable fallbacks if the contents of the switch does not directly map a value for that language.

The given language to test, if it's not specified, is the user interface language of the viewing user.

The language of the mapped value to return when there's no match in the switch for the fiven language or its fallbacks, is English (en) unless another default language is specified.

Parameters

  • uselang=language-code (optional) — the switch by default will return a value according to the viewing user, this parameter allows changing this behavior.
  • language-code=mapped value — maps the language to a value.
    The language-code set by the defaultparameter below (or en if it's not mapped) should have a mapping. Otherwise, the return value will display this default language-code within triple braces.
  • default=language-code (optional) — allows to specify which language to use when reasonnable fallbacks have failed. If its value matches a given item defined in the switch, the value mapped to this item will be returned when no other languages in the switch match; if the default is not specified, or does not match any item in the switch, the value mapped to English (the default language of this wiki) will be returned.
    Note that the language-code indicated here may be arbitrary and can be a pseudo-language to specify a different value, even if it displays a message in English (or in any language).

Examples

Switch according to the language of the viewing user (currently for you, uselang=틀:Uselang)
  • '''{{LangSwitch |ar=AR|de=DE|es=ES|en=EN|fr=FR|nl=NL|pt=PT|ru=RU|tr=TR|zh=ZH}}''' gives 모듈:Fallback 26번째 줄에서 Lua 오류: langSwitch error: no default.
  • '''{{LangSwitch|default=gd |gd=GD|glk=GLK|other=''edit''}}''' gives gd
  • '''{{LangSwitch|default=other |gd=GD|glk=GLK|other=''edit''}}''' gives other
  • '''{{LangSwitch|default=n/a |gd=GD|glk=GLK|other=''edit''}}''' gives n/a
  • '''{{LangSwitch|default= |gd=GD|glk=GLK|other=''edit''}}''' gives '
Switch according to the language of the content of the current page (in this page, it is 틀:Pagelang) :
  • '''{{LangSwitch|uselang={{pagelang}} |ar=AR|de=DE|es=ES|en=EN|fr=FR|nl=NL|pt=PT|ru=RU|tr=TR|zh=ZH}}''' gives 모듈:Fallback 26번째 줄에서 Lua 오류: langSwitch error: no default.
  • '''{{LangSwitch|uselang={{pagelang}}|default=gd |gd=GD|glk=GLK|other=EN [translate this]}}''' gives gd
  • '''{{LangSwitch|uselang={{pagelang}}|default=other |gd=GD|glk=GLK|other=EN [translate this]}}''' gives other
  • '''{{LangSwitch|uselang={{pagelang}}|default=n/a |gd=GD|glk=GLK|other=EN [translate this]}}''' gives n/a
  • '''{{LangSwitch|uselang={{pagelang}}|default= |gd=GD|glk=GLK|other=EN [translate this]}}''' gives '
Switch according to the language of a specific language
  • '''{{LangSwitch|uselang=gsw |ar=AR|de=DE|es=ES|en=EN|fr=FR|nl=NL|pt=PT|ru=RU|tr=TR|zh=ZH}}''' gives 모듈:Fallback 26번째 줄에서 Lua 오류: langSwitch error: no default.(note the fallback)
  • '''{{LangSwitch|uselang=gsw-fr |ar=AR|de=DE|es=ES|en=EN|fr=FR|nl=NL|pt=PT|ru=RU|tr=TR|zh=ZH}}''' gives 모듈:Fallback 26번째 줄에서 Lua 오류: langSwitch error: no default.(note the different fallback)
  • '''{{LangSwitch|uselang=gsw-ch |ar=AR|de=DE|es=ES|en=EN|fr=FR|nl=NL|pt=PT|ru=RU|tr=TR|zh=ZH}}''' gives 모듈:Fallback 26번째 줄에서 Lua 오류: langSwitch error: no default.(note the different fallback)
  • '''{{LangSwitch|uselang=gsw-de |ar=AR|de=DE|es=ES|en=EN|gsw-ch=GSW-CH|fr=FR|nl=NL|pt=PT|ru=RU|tr=TR|zh=ZH}}''' gives 모듈:Fallback 26번째 줄에서 Lua 오류: langSwitch error: no default.(note the different fallback)
  • '''{{LangSwitch|uselang=gsw|default=gd |gd=GD|glk=GLK|other=EN [translate this]}}''' gives gd
  • '''{{LangSwitch|uselang=gsw|default=other |gd=GD|glk=GLK|other=EN [translate this]}}''' gives other
  • '''{{LangSwitch|uselang=gsw|default=n/a |gd=GD|glk=GLK|other=EN [translate this]}}''' gives n/a
  • '''{{LangSwitch|uselang=gsw|default= |gd=GD|glk=GLK|other=EN [translate this]}}''' gives '