Template:Dir2

From Wikimedia Commons, the free media repository
Jump to navigation Jump to search

ltr

Template documentationview · edit · history · purge ]
This documentation is transcluded from Template:Dir2/doc.

No description yet available.

Usage

{{Dir2 |1= |2= |3= }}

Unlike the other version (Template:Dir) implemented using only wiki syntax and the builtin parser function #switch, this template just uses directly a Lua implementation which has several advantages, including (but not only):

  • BCP47 conformance for resolution of script variants
  • support of legacy language codes (including non BCP47 codes still used by Wikimedia and not fully migrated to BCP47-conforming codes
  • higher coverage of languages and script variants
  • reduction of the average template expansion cost (below 1ms per invokation, even when including the initial cost for instantiating a Lua VM, which is constant)
  • significant reduction of the template expansion cost in MediaWiki (this is useful where you need to use a conditional direction several thousands times on the same page (so the Lua version can be used for example to render fully translatable HTML tables with thousands cells whose text content or formatting depends on the direction of a target language)

Template parameters

ParameterDescriptionDefaultStatus
1langlanguage code to testemptyrequired
2rtltext to return if the language is written with a right-to-left script (such as Hebrew, Arabic, etc.)rtloptional
3ltrtext to return if the language is written with a left-to-right script (such as Latin, Greek, etc.)ltroptional

Additional information

The template is intended to be used in the following namespaces: no namespace specified

The template is intended to be used by the following user groups: no user group specified

Relies on:
Module:Dir

See also

  • Template:Dir (older version, used on pages with "light" translations, does not work well if it is invoked more than a few hundreds times per page via other templates)