Template:Language tag/doc
Usage
This template marks text by the appropriate language (and associated qualities This template is to be used on non-English pages in line with best practice.
This template should be within either <div>
or <span>
HTML tags. Div should be used for entire pages or sections, span should be used for short elements within sentences or paragraphs.
<div {{language tag|language=|script=|country=|direction=}}>
OR
<div {{language tag|language}}>
Parameters
- language: Code for the language of the text (use ISO 639). Defaults to "en" for English.
- Also lang or the first unnamed parameter
- script: Code for the script, if different than standard (use ISO 15924)
- Also the second unnamed parameter
- country: Code for the country of origin (use ISO 3166-1). Defauklts to "GB" for the United Kingdom.
- Also the third unnamed parameter
- direction: The direction of the text. Can be either
ltr
(left-to-right) orrtl
(right-to-left). Left-to-right is default.- Also dir
- The following languages are preset within the template to
rtl
and do not necessarily need to be explicitly set tortl
(however, setting this parameter can override the automatic text direction, if desired): Arabic, Farsi, Hebrew, Western Punjabi and Urdu.
Hard coding
As an alternative to using this template, the contents can be hard-coded into the page. This template is made of of two elements, lang
and dir
.
The first, lang
sets the language (as well as the script and/or country if necessary). The additional element, xml:lang
, should also be set for the time being.
The second, dir
, sets the text direction.
For example, setting text to English would be:
<div lang="en" xml:lang="en">
Setting text to British English would be:
<div lang="en-GB" xml:lang="en-GB">
Setting text to Arabic would be:
<div lang="ar" xml:lang="ar" dir="rtl">
Setting text to Arabic transliterated into Latin script would be:
<div lang="ar-Latn" xml:lang="ar-Latn" dir="ltr">
Language tagging
The best practice for language tagging is explain at meta:Language tagging.
In summary: It is a best practice to tag a web page or a piece of text in a web page in the correct language. An HTML element should contain a lang attribute identifying the language it is written in, and also a dir attribute, identifying the writing direction. This already occurs for all Wikimedia sites but, where those sites vary from the default, it needs to be added manually.