Template:LangSwitch/doc

From OpenStreetMap Wiki
Jump to: navigation, search
Dialog-warning-yellow.svg Note: This template is used on a lot of pages. In order not to put too much load on the servers, edits should be kept to a bare minimum.
Please discuss proposed changes on the talk page first.
Editing a template causes all pages that use the template to be re-rendered. If the Template is used often, this can put a lot of load on the servers since it fills up the job queue. [statistics]

Usage

See Wikipedia:Meta:Template:LangSwitch for documentation.

The parameter |en= is mandatory for defining a default message in English (this message may be empty but the parameter must be present). If it is missing, the page will be listed in Category:Pages with missing en parameter in LangSwitch. Alternatively you may also (or instead) supply the or |default= parameter to specify a message in any language (you can still specify also a distinct |en= parameter value to provide an explicit translation in English, different from the default message which may be used to track missing translations in languages that don't automatically fallback to English).

Supported language fallback chains

This template currently supports up to 2 fallbacks per language to look for, before using the "default" fallback (if it's specified, or "en" otherwise because the default language of this wiki for untranslated contents).

When a translated resource is missing in the supplied parameters, other languages will be looked for, in the following order, from right to left. In this diagram, the initial language code to look for is not betwen parentheses "()" which are used only to indicate one of the supplied fallbacks (these languages have their own distictive entry elsewhere in the diagram without parentheses). When multiple languages have the same fallback chains, they are listed separated by commas "," but there's no fallback between each other. The effective fallbacks are indicated by following the arrows indicating the order of search:

(en) ← default ←  en  ←  en-au, en-ca, en-gb, en-nz
             ↑↖←  ar  ←  arz
             ↑      ↑↖←  fa         ←  bal, bcc, bqi, glk, mzn, ps, prs
             ↑       ↖← (fr)        ←  tzm, zgh
             ↑↖←  az  ←  azb
             ↑↖←  bg  ←  mk
             ↑↖←  bho ←  bh
             ↑↖← (bn) ←  as         ←  bn
             ↑       ↖←  bpy
             ↑↖← (cs) ←  sk         ←  cs
             ↑↖←  da  ←  jut, kl
             ↑↖←  de  ←  bar, de-ch, de-at, frr, ksh, nds, pdc, pdt, pfl, sli, stq, vmf
             ↑      ↑↖← (dsb)       ←  hsb
             ↑      ↑↖← (gsw-fr)    ←  gsw
             ↑       ↖← (hsb)       ←  dsb
             ↑↖←  es  ←  an, arn, ast, ay, ca, eu, ext, gl, gn, qu
             ↑      ↑↖← (nah)       ←  nci
             ↑       ↖← (nci)       ←  nah, nch, ngu, nhm, nhn, nlv
             ↑↖←  et  ←  liv, vep, vro
             ↑↖←  fi  ←  fit, vot
             ↑↖←  fr  ←  bm, br, co, ff, fr-ca, frc, frp, gcf, ht, lb, ln, mg, nrf, oc, pcd, sg, ty, wa, wo
             ↑       ↖← (gsw)       ←  gsw-fr
             ↑↖←  he  ←  yi
             ↑↖←  hi  ←  anp, may, sa
             ↑↖←  ik  ←  ik-cans    ←  iu 
             ↑       ↖←  ik-latn
             ↑↖←  it  ←  egl, eml, fur, lij, lmo, nap, pms, rgn, sc, scn, sdc, vec
             ↑↖←  ja  ←  ain
             ↑↖←  kn  ←  tcy
             ↑↖←  ku  ←  ckb
             ↑↖←  lt  ←  sgs
             ↑↖←  lv  ←  ltg
             ↑↖←  mr  ← (gom)       ←  kok
             ↑       ↖← (kok)       ←  gom
             ↑↖← (ms) ←  dtp
             ↑       ↖←  id         ←  ace, bjn, bug, jv, map-bms, min, su
             ↑↖←  nl  ←  af, fy, li, nds-nl, vls, zea
             ↑↖← (nb) ← (no)        ←  nn
             ↑↖←  ne  ←  new
             ↑↖← (nn) ← (no)        ←  nb
             ↑       ↖← (nb)        ←  no
             ↑↖←  pl  ←  csb, szl, wym
             ↑↖← (pt) ←  pt-br      ←  pt, pt-ao, pt-mz, mwl
             ↑↖←  ro  ←  aln, rmy, rup, ruq
             ↑↖←  ru  ←  ab, av, ba, ce, cv, crh, inh, koi, kbd, krc, kv, lbe, lez, mdf, mhr, mn, mrj, myv, os, sah, tk, tt, udm, uz, xal
             ↑      ↑↖← (be)        ←  be-tarask
             ↑      ↑↖← (be-tarask) ←  be
             ↑      ↑↖←  ka         ←  xmf
             ↑      ↑↖←  kk         ←  kaa
             ↑      ↑↖←  tg         ←  tg-cyrl, tg-latn
             ↑       ↖←  uk         ←  rue
             ↑↖← (sh) ←  hr         ←  sh
             ↑      ↑↖← (sr)        ←  sr-cyrl  ←  sr
             ↑      ↑              ↖←  sr-latn
             ↑       ↖← (sr-latn)   ←  bs
             ↑↖←  sq  ←  aln
             ↑←   th  ←  nod, sou, tts
             ↑↖←  tr  ←  diq, gag, kiu, lzz, zza
             ↑↖← (ur) ←  sd         ←  ur
             ↑       ↖←  khw
              ↖← (zh) ← (zh-hans)   ←  ii, wuu, zh, zh-cn, zh-hant, zh-sg
                     ↖← (zh-hant)   ←  gan, lzh, nan, yue, za, zh-hans, zh-hk, zh-mo, zh-tw

The fallbacks may be a bit different or more complete on Wikimedia sites, which have integrated support for Lua modules, allowing them to retrieve the language fallbacks used in Mediawiki itself. But the OSM wiki still has no support for Lua, so this is list is still completely implemented instead by this template using basic MediaWiki syntax for template transclusion.

Warning

This template still does not work as bast as initially intended if it could use {{Int:Lang}}, but which required resources in "Mediawiki:Lang/*" loaded by the wiki administrator for all supported localisations of the MediaWiki software.

For example Mediawiki:Lang should contain en (the default language code of this wiki), and its subpages Mediawiki:Lang/en, Mediawiki:Lang/fr, etc. should contain en, fr, and so on for all supported language codes).

In more recent versions, the special parser function int:Lang was treated internally by the MediaWiki extension and no longer require preloading "Mediawiki:Lang/*" resources. However the special support for this standard parser function int: has also not been enabled on this wiki.

For this purpose, Translatewiki.net created the {{UILANGCODE}} magic keyword in a local MediaWiki extension, which is still not supported in the version of Mediawiki deployed on this wiki (because it is still not integrated in core MediaWiki, see w:mw:UILANGCODE which currently points to Quick guide to editing translatewiki.net). Another proposal defines the equivalent {{USERLANGCODE}} magic keyword.

On MetaWiki and Commons, this new magic keyword is emulated using a template that still uses {{Int:Lang}} (and requires the installation of "Mediawiki:Lang/*" resources on their own wiki). Other wikis where the support of Lua modules are enabled with Scribunto can use another method, by using the exposed Mediawiki API, but this wiki still does not support Scribunto modules. Consequently, there's no reliable way of detecting the interface language selected by the user on this wiki (except by detecting the contents of some other "Mediawiki:*" resources used to translate the interface, and unreliably comparing them with known translations).

For this reason this template does not display the user's preferred language, but will display the message defined only by the language determined from the current page (by {{Langcode}}, using its namespace or a language code prefix in its title); when this language cannot be determined, it will return the default (English) message defined by the mandatory en parameter.

For the same reason, we cannot use the internal fallback chains implemented by MediaWiki for translating its UI, as it is only exposed by the Mediawiki library for Scribunto (this method is used on Wikimedia Commons and MetaWiki, using a custom module), so we have to provide our own fallback chains with this local template.

See also