Template:Dir: Difference between revisions
Jump to navigation
Jump to search
Mediawiki>Shirayuki properly test rtl/ltr parameters when they are effectively set per translatewiki:Template:Dir |
Richardpruen (talk | contribs) m 1 revision imported: NASA licence |
||
| (4 intermediate revisions by 3 users not shown) | |||
| Line 1: | Line 1: | ||
{{#switch:{{ | {{#switch:{{{1}}}|aaf-arab|aao|abh|abq-arab|abv|ace-arab|acm|acq|acw|acx|acy-arab|adf|ady-arab|aeb|aeb-arab|aec|afb|aic|ajp|apc|apd|ar|ara|arb|arc|arq|ars|ary|arz|auz|avl|ayh|ayl|ayn|ayp|az-arab|azb|bal|bbz|bcc|bej-arab|ber-arab|bft|bgn|bgp|bjm|bjn-arab|bms-arab|bqi|bqp|brh-arab|bsk|cja-arab|cjm-arab|ckb|ckb-arab|crh-arab|deh|dgo-arab|dng-arab|doi-arab|dv|dyu-arab|en-rtl|fa|fa-af|ff-arab|ffm-arab|fub-arab|fuc-arab|fuf-arab|fuh-arab|fui-arab|fuv-arab|gbz-arab|gda|gju-arab|glk|gwc|ha-arab|hac|haz|he|hnd|hno|jat|kbd-arab|kbl-arab|kby-arab|kcn|kfr|khw|kk-arab|kk-cn|kls-arab|kmr-arab|knc-arab|kr-arab|krt-arab|ks|ks-arab|ktl|ku-arab|ky-arab|lad-hebr|lah|lki|lrc|lrk|luz|mad-arab|man-arab|mge-arab|mhj|mki-arab|mne-arab|mnk-arab|mrt-arab|ms-arab|mve|mvy|mwr-arab|mzb|mzn|nqo|ota|pa-arab|pbt|pbu|pga|phl|phn|phr|phv|pnb|prd|prs|ps|pst|raj-arab|rif-arab|rmt-arab|scl|sd|sdb|sdf|sdh|shi-arab|shu|shy-arab|skr|skr-arab|sqr|ssh|su-arab|sw-arab|swh|tg-arab|tig-arab|tk-arab|tly|tly-arab|trw|tt-arab|txj-arab|ug|ug-arab|ur|uz-arab|uzs|wbl|wlc-arab|wne|wni-arab|wo-arab|xhe|xng-arab|xpu|ydd|ydg|yhd|yhd-arab|yhd-hebr|yi|yih|zdj-arab={{{2|rtl}}}|{{{3|ltr}}}}}<noinclude> | ||
|aeb|aeb-arab|aic|ar|arc|arq|ary|arz|azb|bcc|bgn|bqi|bqp|ckb|ckb-arab|dv|en-rtl|fa|fa-af|glk|ha-arab|haz|he|khw|kk-arab|kk-cn|ks|ks-arab|ku-arab|lki|lrc|luz|mzn|nqo|ota|phn|pnb|prd|prs|ps|sd|sdh|skr|skr-arab|tg-arab|tly|ug|ug-arab|ur|uz-arab| | |||
{{Documentation}} | |||
| | |||
</noinclude> | |||
}}<noinclude>{{ | |||
Latest revision as of 14:08, 28 October 2022
ltr
| This template is used on approximately 26,000 pages and changes may be widely noticed. Test changes in the template's /sandbox or /testcases subpages, or in your own user subpage. Consider discussing 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 | Tunisian Arabic |
| aeb-arab | Tunisian Arabic (Arabic script) |
| aic | aic |
| ar | Arabic |
| arc | Aramaic |
| arq | Algerian Arabic |
| ary | Moroccan Arabic |
| arz | Egyptian Arabic |
| azb | South Azerbaijani |
| bcc | Southern Balochi |
| bgn | Western Balochi |
| bqi | Bakhtiari |
| bqp | bqp |
| ckb | Central Kurdish |
| ckb-arab | Central Kurdish (Arabic script) |
| dv | Divehi |
| en-rtl | en-x-rtl |
| fa | Persian |
| fa-af | Dari |
| glk | Gilaki |
| ha-arab | Hausa (Arabic script) |
| haz | Hazaragi |
| 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 |
| ota | Ottoman Turkish |
| phn | Phoenician |
| pnb | Western Punjabi |
| prd | prd |
| prs | Dari |
| ps | Pashto |
| sd | Sindhi |
| sdh | Southern Kurdish |
| skr | Saraiki |
| skr-arab | Saraiki (Arabic script) |
| tg-arab | tg-Arab |
| tly | Talysh |
| ug | Uyghur |
| ug-arab | Uyghur (Arabic script) |
| ur | Urdu |
| uz-arab | uz-Arab |
| xpu | Punic |
| ydd | ydd |
| yi | Yiddish |
- Examples
-
- {{dir}}, for the current user language which is English (English), returns
ltr. - {{dir|en}}, for English (English), returns
ltr. - {{dir|lang=en}}, for English (English), returns
ltr. - {{dir|ar}}, for Arabic (العربية), returns
rtl. - {{dir|yi}}, for Yiddish (ייִדיש), returns
rtl. - {{dir|2=right|3=left}}, for the current user language which is English (English), returns
left. - {{dir|rtl=right|ltr=left}}, for the current user language which is English (English), returns
ltr. - {{dir|en|right|left}}, for English (English), returns
left. - {{dir|ar|right|left}}, for Arabic (العربية), returns
right. - {{dir|yi|right|left}}, for Yiddish (ייִדיש), returns
right. - {{dir|lang=yi|rtl=right|ltr=left}}, for Yiddish (ייִדיש), returns
ltr.
- {{dir}}, for the current user language which is English (English), returns
TemplateData
This is the TemplateData for this template used by TemplateWizard, VisualEditor and other tools. See a monthly parameter usage report for Template:Dir in articles based on its TemplateData.
TemplateData for Dir
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 | 1 | The language to get the direction for, by default the interface language
| Line | required |
| Right-to-Left | 2 | Return value for right-to-left languages
| String | optional |
| Left-to-Right | 3 | Return value for left-to-right languages
| String | optional |