Difference between revisions of "Template:dir"
Jump to navigation
Jump to search
(Created page with "{{#switch:{{lc:{{{1|{{int:lang}}}}}}}|ar|arc|arz|azb|bcc|ckb|bqi|dv|fa|fa-af|glk|ha|he|kk-arab|kk-cn|ks|ku-arab|mzn|pnb|prd|ps|sd|ug|ur|ydd|yi={{{2|rtl}}}|{{{3|ltr}}}}}") |
|||
Line 1: | Line 1: | ||
{{#switch:{{lc:{{{1|{{int:lang}}}}}}}|ar|arc|arz|azb|bcc|ckb|bqi|dv|fa|fa-af|glk|ha|he|kk-arab|kk-cn|ks|ku-arab|mzn|pnb|prd|ps|sd|ug|ur|ydd|yi={{{2|rtl}}}|{{{3|ltr}}}}} | {{#switch:{{lc:{{{1|{{int:lang}}}}}}}|ar|arc|arz|azb|bcc|ckb|bqi|dv|fa|fa-af|glk|ha|he|kk-arab|kk-cn|ks|ku-arab|mzn|pnb|prd|ps|sd|ug|ur|ydd|yi={{{2|rtl}}}|{{{3|ltr}}}}} | ||
+ | <noinclude>; Usage | ||
+ | : Outputs "<tt>rtl</tt>" for right-to-left languages else "<tt>ltr</tt>". | ||
+ | : The default returned values "<tt>rtl</tt>" and "<tt>ltr</tt>" can also be customized. | ||
+ | |||
+ | ; Syntax | ||
+ | :* <tt><nowiki>{{</nowiki>dir|''language-code''<nowiki>}}</nowiki></tt> | ||
+ | :*: The ''language-code'' parameter 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 <tt>{{uselang}}</tt>. | ||
+ | :* <tt><nowiki>{{</nowiki>dir|''language-code''|''return value for RTL scripts''|''return value for LTR scripts''<nowiki>}}</nowiki></tt> | ||
+ | :*: The 2nd and 3rd (optional) parameters allows changing the default return values for languages written in RTL and LTR scripts, whose default are respectively "<tt>rtl</tt>" and "<tt>ltr</tt>". | ||
+ | :*: 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: | ||
+ | : <tt>ar | arc | arz | bcc | ckb | bqi | dv | fa | fa-af | glk | ha | he | kk-arab | kk-cn | ks | ku-arab | mzn | pnb | prd | ps | sd | ug | ur | ydd | yi</tt> | ||
+ | |||
+ | ; Examples | ||
+ | :* <tt><nowiki>{{dir}}</nowiki></tt>, for the current user language which is {{#language:{{uselang}}|en}} (<span lang="{{uselang}}" dir="{{dir|{{uselang}}}}">{{#language:{{uselang}}}}</span>), returns <tt>{{dir}}</tt>. | ||
+ | :* <tt><nowiki>{{dir|en}}</nowiki></tt>, for {{#language:en|en}} (<span lang="en" dir="{{dir|en}}">{{#language:en}}</span>), returns <tt>{{dir|en}}</tt>. | ||
+ | :* <tt><nowiki>{{dir|ar}}</nowiki></tt>, for {{#language:ar|en}} (<span lang="ar" dir="{{dir|ar}}">{{#language:ar}}</span>), returns <tt>{{dir|ar}}</tt>. | ||
+ | :* <tt><nowiki>{{dir|yi}}</nowiki></tt>, for {{#language:yi|en}} (<span lang="yi" dir="{{dir|yi}}">{{#language:yi}}</span>), returns <tt>{{dir|yi}}</tt>. | ||
+ | :* <tt><nowiki>{{dir|2=right|3=left}}</nowiki></tt>, for the current user language which is {{#language:{{uselang}}|en}} (<span lang="{{uselang}}" dir="{{dir|{{uselang}}}}">{{#language:{{uselang}}}}</span>), returns <tt>{{dir|2=right|3=left}}</tt>. | ||
+ | :* <tt><nowiki>{{dir|en|right|left}}</nowiki></tt>, for {{#language:en|en}} (<span lang="en" dir="{{dir|en}}">{{#language:en}}</span>), returns <tt>{{dir|en|right|left}}</tt>. | ||
+ | :* <tt><nowiki>{{dir|ar|right|left}}</nowiki></tt>, for {{#language:ar|en}} (<span lang="ar" dir="{{dir|ar}}">{{#language:ar}}</span>), returns <tt>{{dir|ar|right|left}}</tt>. | ||
+ | :* <tt><nowiki>{{dir|yi|right|left}}</nowiki></tt>, for {{#language:yi|en}} (<span lang="yi" dir="{{dir|yi}}">{{#language:yi}}</span>), returns <tt>{{dir|yi|right|left}}</tt>. | ||
+ | </noinclude> |
Revision as of 14:21, 29 September 2015
ltr
- Usage
- Outputs "rtl" for right-to-left languages else "ltr".
- The default returned values "rtl" and "ltr" can also be customized.
- Syntax
-
- {{dir|language-code}}
- The language-code parameter 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 Template:uselang.
- {{dir|language-code|return value for RTL scripts|return value for LTR scripts}}
- The 2nd and 3rd (optional) parameters allows changing the default return values for languages written in RTL and LTR scripts, whose default are respectively "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.
- {{dir|language-code}}
- Note
- Currently it recognizes the following codes of languages usually written in a right-to-left script:
- ar | arc | arz | bcc | ckb | bqi | dv | fa | fa-af | glk | ha | he | kk-arab | kk-cn | ks | ku-arab | mzn | pnb | prd | ps | sd | ug | ur | ydd | yi
- Examples
-
- {{dir}}, for the current user language which is template:uselang (template:uselang), returns ltr
.
- {{dir|en}}, for English (English), returns ltr
.
- {{dir|ar}}, for العربية (العربية), returns rtl
.
- {{dir|yi}}, for ייִדיש (ייִדיש), returns rtl
.
- {{dir|2=right|3=left}}, for the current user language which is template:uselang (template:uselang), returns left
.
- {{dir|en|right|left}}, for English (English), returns left
.
- {{dir|ar|right|left}}, for العربية (العربية), returns right
.
- {{dir|yi|right|left}}, for ייִדיש (ייִדיש), returns right
.