Dir/doc
Från DAU-handboken
< Mall:Dir{{#ifeq:doc |doc
|
{{#ifeq:show |show
| Skriptfel: Modulen "Message box" finns inte.
}}{{#if: |
| {{#ifexist:Mall:Dir
| [[Category:{{#switch:Mall |Template=Template |Module=Module |User=User |#default=Wikipedia}} documentation pages]]
|
}}
}}
|
}}
- 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 {{#if: | | {{#ifeq: ⧼Lang⧽ | <Lang> | default | ⧼Lang⧽ }} }}.
- {{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= and ltr=.
- 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.
- 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 | تونسي |
ar | العربية |
arc | ܐܪܡܝܐ |
arz | مصرى |
azb | تۆرکجه |
bcc | جهلسری بلوچی |
bgn | روچ کپتین بلوچی |
bqi | بختیاری |
ckb | کوردی |
dv | ދިވެހިބަސް |
en-rtl | en-x-rtl |
fa | فارسی |
fa-af | fa-AF |
glk | گیلکی |
ha | Hausa |
he | עברית |
khw | کھوار |
kk-arab | قازاقشا (تٴوتە) |
kk-cn | قازاقشا (جۇنگو) |
ks | कॉशुर / کٲشُر |
ks-arab | کٲشُر |
ku-arab | كوردي (عەرەبی) |
lki | لەکی |
lrc | لۊری شومالی |
luz | لئری دوٙمینی |
mzn | مازِرونی |
pnb | پنجابی |
prd | prd |
ps | پښتو |
sd | سنڌي |
sdh | کوردی خوارگ |
skr-arab | سرائیکی |
ug | ئۇيغۇرچە / Uyghurche |
ug-arab | ئۇيغۇرچە |
ur | اردو |
ydd | ydd |
yi | ייִדיש |
- Examples
-
- {{dir}}, for the current user language which is {{#if: | | {{#ifeq: ⧼lang⧽ | <lang> | default | ⧼lang⧽ }} }} (<span lang="{{#if: | | {{#ifeq: ⧼Lang⧽ | <Lang> | default | ⧼Lang⧽ }} }}" dir="{{#switch:{{#if:||{{#if:{{#if: | | {{#ifeq: ⧼lang⧽ | <lang> | default | ⧼lang⧽ }} }}|{{#if: | | {{#ifeq: ⧼lang⧽ | <lang> | default | ⧼lang⧽ }} }}|⧼lang⧽}}}}
|aeb-arab|ar|arc|arz|azb|bcc|bgn|bqi|ckb|dv|en-rtl|fa|fa-af|glk|he|khw|kk-arab|kk-cn|ks|ks-arab|ku-arab|lki|lrc|luz|mzn|pnb|prd|ps|sd|sdh|skr-arab|ug|ug-arab|ur|ydd|yi ={{#if:||{{#if:||rtl}}}} |#default ={{#if:||{{#if:||ltr}}}} }}">{{#if: | | {{#ifeq: ⧼lang⧽ | <lang> | default | ⧼lang⧽ }} }}), returns {{#switch:{{#if:||{{#if:||⧼lang⧽}}}} |aeb-arab|ar|arc|arz|azb|bcc|bgn|bqi|ckb|dv|en-rtl|fa|fa-af|glk|he|khw|kk-arab|kk-cn|ks|ks-arab|ku-arab|lki|lrc|luz|mzn|pnb|prd|ps|sd|sdh|skr-arab|ug|ug-arab|ur|ydd|yi ={{#if:||{{#if:||rtl}}}} |#default ={{#if:||{{#if:||ltr}}}} }}.
- {{dir|en}}, for English (English), returns {{#switch:{{#if:||{{#if:en|en|⧼lang⧽}}}}
|aeb-arab|ar|arc|arz|azb|bcc|bgn|bqi|ckb|dv|en-rtl|fa|fa-af|glk|he|khw|kk-arab|kk-cn|ks|ks-arab|ku-arab|lki|lrc|luz|mzn|pnb|prd|ps|sd|sdh|skr-arab|ug|ug-arab|ur|ydd|yi ={{#if:||{{#if:||rtl}}}} |#default ={{#if:||{{#if:||ltr}}}} }}.
- {{dir|lang=en}}, for English (English), returns {{#switch:{{#if:en|en|{{#if:||⧼lang⧽}}}}
|aeb-arab|ar|arc|arz|azb|bcc|bgn|bqi|ckb|dv|en-rtl|fa|fa-af|glk|he|khw|kk-arab|kk-cn|ks|ks-arab|ku-arab|lki|lrc|luz|mzn|pnb|prd|ps|sd|sdh|skr-arab|ug|ug-arab|ur|ydd|yi ={{#if:||{{#if:||rtl}}}} |#default ={{#if:||{{#if:||ltr}}}} }}.
- {{dir|ar}}, for العربية (العربية), returns {{#switch:{{#if:||{{#if:ar|ar|⧼lang⧽}}}}
|aeb-arab|ar|arc|arz|azb|bcc|bgn|bqi|ckb|dv|en-rtl|fa|fa-af|glk|he|khw|kk-arab|kk-cn|ks|ks-arab|ku-arab|lki|lrc|luz|mzn|pnb|prd|ps|sd|sdh|skr-arab|ug|ug-arab|ur|ydd|yi ={{#if:||{{#if:||rtl}}}} |#default ={{#if:||{{#if:||ltr}}}} }}.
- {{dir|yi}}, for ייִדיש (ייִדיש), returns {{#switch:{{#if:||{{#if:yi|yi|⧼lang⧽}}}}
|aeb-arab|ar|arc|arz|azb|bcc|bgn|bqi|ckb|dv|en-rtl|fa|fa-af|glk|he|khw|kk-arab|kk-cn|ks|ks-arab|ku-arab|lki|lrc|luz|mzn|pnb|prd|ps|sd|sdh|skr-arab|ug|ug-arab|ur|ydd|yi ={{#if:||{{#if:||rtl}}}} |#default ={{#if:||{{#if:||ltr}}}} }}.
- {{dir|2=right|3=left}}, for the current user language which is {{#if: | | {{#ifeq: ⧼lang⧽ | <lang> | default | ⧼lang⧽ }} }} (<span lang="{{#if: | | {{#ifeq: ⧼Lang⧽ | <Lang> | default | ⧼Lang⧽ }} }}" dir="{{#switch:{{#if:||{{#if:{{#if: | | {{#ifeq: ⧼lang⧽ | <lang> | default | ⧼lang⧽ }} }}|{{#if: | | {{#ifeq: ⧼lang⧽ | <lang> | default | ⧼lang⧽ }} }}|⧼lang⧽}}}}
|aeb-arab|ar|arc|arz|azb|bcc|bgn|bqi|ckb|dv|en-rtl|fa|fa-af|glk|he|khw|kk-arab|kk-cn|ks|ks-arab|ku-arab|lki|lrc|luz|mzn|pnb|prd|ps|sd|sdh|skr-arab|ug|ug-arab|ur|ydd|yi ={{#if:||{{#if:||rtl}}}} |#default ={{#if:||{{#if:||ltr}}}} }}">{{#if: | | {{#ifeq: ⧼lang⧽ | <lang> | default | ⧼lang⧽ }} }}), returns {{#switch:{{#if:||{{#if:||⧼lang⧽}}}} |aeb-arab|ar|arc|arz|azb|bcc|bgn|bqi|ckb|dv|en-rtl|fa|fa-af|glk|he|khw|kk-arab|kk-cn|ks|ks-arab|ku-arab|lki|lrc|luz|mzn|pnb|prd|ps|sd|sdh|skr-arab|ug|ug-arab|ur|ydd|yi ={{#if:||{{#if:right|right|rtl}}}} |#default ={{#if:||{{#if:left|left|ltr}}}} }}.
- {{dir|rtl=right|ltr=left}}, for the current user language which is {{#if: | | {{#ifeq: ⧼lang⧽ | <lang> | default | ⧼lang⧽ }} }} (<span lang="{{#if: | | {{#ifeq: ⧼Lang⧽ | <Lang> | default | ⧼Lang⧽ }} }}" dir="{{#switch:{{#if:||{{#if:{{#if: | | {{#ifeq: ⧼lang⧽ | <lang> | default | ⧼lang⧽ }} }}|{{#if: | | {{#ifeq: ⧼lang⧽ | <lang> | default | ⧼lang⧽ }} }}|⧼lang⧽}}}}
|aeb-arab|ar|arc|arz|azb|bcc|bgn|bqi|ckb|dv|en-rtl|fa|fa-af|glk|he|khw|kk-arab|kk-cn|ks|ks-arab|ku-arab|lki|lrc|luz|mzn|pnb|prd|ps|sd|sdh|skr-arab|ug|ug-arab|ur|ydd|yi ={{#if:||{{#if:||rtl}}}} |#default ={{#if:||{{#if:||ltr}}}} }}">{{#if: | | {{#ifeq: ⧼lang⧽ | <lang> | default | ⧼lang⧽ }} }}), returns {{#switch:{{#if:||{{#if:||⧼lang⧽}}}} |aeb-arab|ar|arc|arz|azb|bcc|bgn|bqi|ckb|dv|en-rtl|fa|fa-af|glk|he|khw|kk-arab|kk-cn|ks|ks-arab|ku-arab|lki|lrc|luz|mzn|pnb|prd|ps|sd|sdh|skr-arab|ug|ug-arab|ur|ydd|yi ={{#if:right|right|{{#if:||rtl}}}} |#default ={{#if:left|left|{{#if:||ltr}}}} }}.
- {{dir|en|right|left}}, for English (English), returns {{#switch:{{#if:||{{#if:en|en|⧼lang⧽}}}}
|aeb-arab|ar|arc|arz|azb|bcc|bgn|bqi|ckb|dv|en-rtl|fa|fa-af|glk|he|khw|kk-arab|kk-cn|ks|ks-arab|ku-arab|lki|lrc|luz|mzn|pnb|prd|ps|sd|sdh|skr-arab|ug|ug-arab|ur|ydd|yi ={{#if:||{{#if:right|right|rtl}}}} |#default ={{#if:||{{#if:left|left|ltr}}}} }}.
- {{dir|ar|right|left}}, for العربية (العربية), returns {{#switch:{{#if:||{{#if:ar|ar|⧼lang⧽}}}}
|aeb-arab|ar|arc|arz|azb|bcc|bgn|bqi|ckb|dv|en-rtl|fa|fa-af|glk|he|khw|kk-arab|kk-cn|ks|ks-arab|ku-arab|lki|lrc|luz|mzn|pnb|prd|ps|sd|sdh|skr-arab|ug|ug-arab|ur|ydd|yi ={{#if:||{{#if:right|right|rtl}}}} |#default ={{#if:||{{#if:left|left|ltr}}}} }}.
- {{dir|yi|right|left}}, for ייִדיש (ייִדיש), returns {{#switch:{{#if:||{{#if:yi|yi|⧼lang⧽}}}}
|aeb-arab|ar|arc|arz|azb|bcc|bgn|bqi|ckb|dv|en-rtl|fa|fa-af|glk|he|khw|kk-arab|kk-cn|ks|ks-arab|ku-arab|lki|lrc|luz|mzn|pnb|prd|ps|sd|sdh|skr-arab|ug|ug-arab|ur|ydd|yi ={{#if:||{{#if:right|right|rtl}}}} |#default ={{#if:||{{#if:left|left|ltr}}}} }}.
- {{dir|lang=yi|rtl=right|ltr=left}}, for ייִדיש (ייִדיש), returns {{#switch:{{#if:yi|yi|{{#if:||⧼lang⧽}}}}
|aeb-arab|ar|arc|arz|azb|bcc|bgn|bqi|ckb|dv|en-rtl|fa|fa-af|glk|he|khw|kk-arab|kk-cn|ks|ks-arab|ku-arab|lki|lrc|luz|mzn|pnb|prd|ps|sd|sdh|skr-arab|ug|ug-arab|ur|ydd|yi ={{#if:right|right|{{#if:||rtl}}}} |#default ={{#if:left|left|{{#if:||ltr}}}} }}.