Template:Dir/doc
Jump to navigation
Jump to search
![]() | This is a documentation subpage for Template:Dir. It contains usage information, categories and other content that is not part of the original template page. |
![]() | This template is used on approximately 26,000 pages. To avoid large-scale disruption and unnecessary server load, any changes to this template should first be tested in its /sandbox or /testcases subpages or in your own user subpage. The tested changes can then be added to this page in one single edit. Please consider discussing any changes on the talk page before implementing them. |
- Usage
- Outputs "
rtl
" for right-to-left languages else "ltr
". - The default returned values "
rtl
" and "ltr
" can also be customized.
- Syntax
-
{{dir}}
{{dir|lang=language-code}}
{{dir|language-code}}
- The 1st (optional) parameter language-code (whose value may be passed alternatively by name as
|lang=
) should be conforming to BCP47, as required by web standards (HTML/CSS...), rather than Wikimedia labels for designating languages in domain names (in some cases, Wikimedia language codes are not conforming and only used for interwikis and URLs; most of them are being migrated to BCP47, which is based on some parts of the ISO649 standard). - If no language-code parameter is specified, it defaults to the preferred UI language of the visitor viewing the current page, which for you is currently
en
.
- The 1st (optional) parameter language-code (whose value may be passed alternatively by name as
{{dir|lang=language-code|rtl=return value for RTL scripts|ltr=return value for LTR scripts}}
{{dir|language-code|return value for RTL scripts|return value for LTR scripts}}
{{dir|rtl=return value for RTL scripts|ltr=return value for LTR scripts}}
{{dir|2=return value for RTL scripts|3=return value for LTR scripts}}
- The 2nd and 3rd (optional) parameters allow changing the default return values for languages written in RTL and LTR scripts (respectively), whose default are "
rtl
" and "ltr
". These return values may be passed alternatively by name as|rtl=
andltr=
. - This can be used to customize CSS styles such as text alignment or floatting side or lateral margins/borders/paddings, or to change the displayed text/symbols or names of images/icons depending on the script direction.
- The 2nd and 3rd (optional) parameters allow changing the default return values for languages written in RTL and LTR scripts (respectively), whose default are "
- Note
- Currently it recognizes the following codes of languages usually written in a right-to-left script.
- All other languages will be assumed to use a left-to-right script.
Code | Language |
---|---|
aeb-arab | Tunisian Arabic (Arabic script) |
ar | Arabic |
arc | Aramaic |
arz | Egyptian Arabic |
azb | South Azerbaijani |
bcc | Southern Balochi |
bgn | Western Balochi |
bqi | Bakhtiari |
ckb | Central Kurdish |
dv | Divehi |
en-rtl | en-x-rtl |
fa | Persian |
fa-af | Dari |
glk | Gilaki |
ha | Hausa |
he | Hebrew |
khw | Khowar |
kk-arab | Kazakh (Arabic script) |
kk-cn | Kazakh (China) |
ks | Kashmiri |
ks-arab | Kashmiri (Arabic script) |
ku-arab | Kurdish (Arabic script) |
lki | Laki |
lrc | Northern Luri |
luz | Southern Luri |
mzn | Mazanderani |
nqo | N’Ko |
pnb | Western Punjabi |
prd | prd |
ps | Pashto |
sd | Sindhi |
sdh | Southern Kurdish |
skr-arab | Saraiki (Arabic script) |
ug | Uyghur |
ug-arab | Uyghur (Arabic script) |
ur | Urdu |
ydd | Eastern Yiddish |
yi | Yiddish |
- Examples
-
{{dir}}
, for the current user language which is English (English), returnsltr
.{{dir|en}}
, for English (English), returnsltr
.{{dir|lang=en}}
, for English (English), returnsltr
.{{dir|ar}}
, for Arabic (العربية), returnsrtl
.{{dir|yi}}
, for Yiddish (ייִדיש), returnsrtl
.{{dir|2=right|3=left}}
, for the current user language which is English (English), returnsleft
.{{dir|rtl=right|ltr=left}}
, for the current user language which is English (English), returnsleft
.{{dir|en|right|left}}
, for English (English), returnsleft
.{{dir|ar|right|left}}
, for Arabic (العربية), returnsright
.{{dir|yi|right|left}}
, for Yiddish (ייִדיש), returnsright
.{{dir|lang=yi|rtl=right|ltr=left}}
, for Yiddish (ייִדיש), returnsright
.
TemplateData
Outputs “rtl” for right-to-left languages, else “ltr”. The default returned values “rtl” and “ltr” can also be customized.
Parameter | Description | Type | Status | |
---|---|---|---|---|
language | lang 1 | The language to get the direction for, by default the interface language
| Line | optional |
right-to-left | rtl 2 | Return value for right-to-left languages
| Unknown | optional |
left-to-right | ltr 3 | Return value for left-to-right languages
| Unknown | optional |