Difference between revisions of "Template:Lang/doc"

From blackwiki
Jump to navigation Jump to search
imported>Redrose64
imported>Quoth-22
(Rewrote some sections for grammar and clarity, made example styles consistent, added more examples, tried to clarify process of picking between ISO 639-1 and 639-2 language codes)
Line 2: Line 2:
 
{{High-risk|540000}}
 
{{High-risk|540000}}
 
{{COinS safe|n|addtext=The features of this template will be added to the citation templates in the next update.}}
 
{{COinS safe|n|addtext=The features of this template will be added to the citation templates in the next update.}}
The purpose of this template is to indicate, via [[List of ISO 639 codes|a code]], that a span of text belongs to a particular language. It often makes no visible changes to the text, but can prompt web browsers to use a more appropriate font, or screen readers to use a particular kind of pronunciation; and so on. The {{section link||Rationale}}, below, provides more information.
+
The purpose of this template is to indicate that a span of text belongs to a particular language. It often makes no visible changes to the text, but can prompt web browsers to use a more appropriate font, or screen readers to use a particular kind of pronunciation, and so on. The {{section link||Rationale}}, below, provides more information.
  
 
== Syntax and usage ==
 
== Syntax and usage ==
: {{tlx|lang |{{var|[[List of ISO 639 codes|ISO 639 language code]]}} |{{var|text}}}}
 
  
The [[ISO 639]] code is usually a two- or three-letter abbreviation, in lowercase, of the language's name. [[French language|French]], for example, has the code "fr":
+
: {{tlx|lang|{{var|language tag}}|{{var|text}}}}
: <code><nowiki>She said: "''{{lang|fr|Je suis française.}}''"</nowiki></code>
+
 
produces:
+
The {{var|language tag}} should consist of an [[List of ISO 639 codes|ISO 639]] language code, optionally extended to indicate a language's script or region. The language code is usually a two- or three-letter abbreviation, in lowercase, of the language's name. [[French language|French]], for example, has the code <code>fr</code>:
 +
 
 +
* <code><nowiki>She said: "''{{lang|fr|Je suis française.}}''"</nowiki></code>
 
: She said: "''{{lang|fr|Je suis française.}}''"
 
: She said: "''{{lang|fr|Je suis française.}}''"
  
By default, this template will place articles into the relevant subcategory of {{cl|Articles containing non-English-language text}}. To suppress this –&nbsp;e.g. when using {{braces|lang}} within a [[Help:Link#Wikilinks|wikilink]] or the ''title'' parameter of a citation&nbsp;– add the parameter {{para|nocat|true}}. If {{braces|lang}} is used to identify a language read from right to left, e.g. [[Arabic language|Arabic]], the template {{tl|rtl-lang}} may be used afterward to ensure the standard (English) left-to-right formatting is resumed. It also supports the {{para|nocat}} parameter.
+
Because all languages represented by two-letter codes in [[ISO 639‑1]] can also be represented by their newer three-letter equivalents in [[ISO 639‑2]] and above, it is recommended to use the shortest language tag possible that sufficiently describes the target language.<ref>[https://www.w3.org/International/articles/language-tags/index.en "Language tags in HTML and XML"] at [[World Wide Web Consortium]]</ref> So while French could be represented by 639‑2's <code>fra</code> code, 639‑1's <code>fr</code> should still take precedence. Likewise, script and region information should only be included when they make a necessary distinction.
  
It is better to incorporate only the foreign-language text (linked if appropriate) inside the template, so that extraneous markup that is not from the non-English language in question does not receive incorrect metadata for that language.  For example:
+
It is better to only include the foreign-language text (linked if appropriate) inside the template, so that any extraneous markup which is not from the foreign language does not receive incorrect metadata for that language:
* Use <code><nowiki>''{{lang|it|[[goriziana]]}}''</nowiki></code>
 
* Not <code>{{dc|1=<nowiki>{{lang|it|''[[goriziana]]''}}</nowiki>}}</code>
 
This includes italicization as foreign; English-language quotation marks around titles of work in language that use other quotation character glyphs; italicization of titles in languages that do not use that convention; and emphasis that is not found (in one style or another) in the original non-English text; among other cases. If in doubt, put such markup outside the {{tnull|lang}}.
 
  
There are also versions of this template for specific languages, intended for use the first time one of those languages appears in an article, that print the language's name and, for languages using the Latin alphabet, italicize the content automatically. For example, {{nowrap|{{tlf|lang-es|español}}}} and {{nowrap|{{tlf|lang-ru|русский язык}}}} yield, respectively, "{{lang-es|español}}" and "{{lang-ru|русский язык}}" (without the quotation marks).
+
* Use <code>{{mxt|1=<nowiki>''{{lang|it|[[goriziana]]}}''</nowiki>}}</code>
 +
* Not <code>{{!mxt|1=<nowiki>{{lang|it|''[[goriziana]]''}}</nowiki>}}</code>
  
Language subtags can be used to indicate a regional variant of and/or a particular script used for a language. According to the [[World Wide Web Consortium]], "the golden rule when creating language tags is to keep the tag as short as possible",<ref>[http://www.w3.org/International/articles/language-tags/Overview.en.php Overview for Language Tags] at [[World Wide Web Consortium]]</ref> so such subtags should only be added if there is good reason to use them. [[ISO 639‑1]] is preferred over [[ISO 639‑2]] and [[ISO 639‑3]].
+
This includes italicization of foreign words; English-language quotation marks around titles of works in languages that use other quotation character glyphs; italicization of titles in languages which do not use that convention; and emphasis that is not found (in one style or another) in the original foreign text; among other cases. If in doubt, put such markup outside the template.
 +
 
 +
By default, this template will place articles into the relevant subcategory of {{cl|Articles containing non-English-language text}}. To suppress this – e.g. when using {{tlf|lang}} within a [[Help:Link#Wikilinks|wikilink]] or the ''title'' parameter of a citation – add the parameter {{para|nocat|true}}.
 +
 
 +
There are also language-specific versions of this template, such as {{tl|lang-fr}} and {{tl|lang-ru}}, which are intended to be used the first time a language appears in an article. These templates will print the language's name and, when appropriate, italicize their content:
 +
 +
* <code><nowiki>A '''kremlin''' ({{lang-ru|кремль}}, ''castle'') is a major fortified central complex...</nowiki></code>
 +
: A '''kremlin''' ({{lang-ru|кремль}}, ''castle'') is a major fortified central complex...
  
 
== Italics ==
 
== Italics ==
  
By default, {{tnull|lang|{{var|LanguageCode}}|...}} outputs plain text, while {{tnull|lang-{{var|LanguageCode}}|...}} templates (e.g. {{tl|lang-de}}) output text in italics, except for languages that do not use a Latin-based script. If, with the latter, plain text is required (e.g. for proper names), {{tl|noitalic}} may be used. For example,
+
By default, {{tlf|lang}} outputs plain text, while {{tlf|lang-xx}} templates (e.g. {{tl|lang-de}}) output text in italics for languages using Latin-based scripts. If plain text is required with the latter, such as for proper names, {{tl|noitalic}} may be used:
: <code>... the border town of Ventimiglia (<nowiki>{{lang-fr|{{noitalic|Vintimille}}}}</nowiki>)</code>
+
 
produces:
+
* <code>... the border town of Ventimiglia (<nowiki>{{lang-fr|{{noitalic|Vintimille}}}}</nowiki>)</code>
 
: ... the border town of Ventimiglia ({{lang-fr|{{noitalic|Vintimille}}}})
 
: ... the border town of Ventimiglia ({{lang-fr|{{noitalic|Vintimille}}}})
  
 
== Indicating writing script ==
 
== Indicating writing script ==
  
If necessary, add the [[List of ISO 15924 codes|ISO 15924]] code to indicate the script.  
+
If necessary, an [[List of ISO 15924 codes|ISO 15924]] script code can be appended to a language code to indicate the use of a specific script. For instance, [[Tajik language|Tajik]] (<code>tg</code>) is a language which can be found written in [[Arabic script|Arabic]] (<code>Arab</code>), [[Latin script|Latin]] (<code>Latn</code>), and [[Cyrillic script|Cyrillic]] (<code>Cyrl</code>) scripts, making it necessary to always specify which script is in use. In such a case, taking care to preserve the script's capitalization, we could end up with the following code (language tags in bold):
 +
 
 +
* <code><nowiki>Tajik ({{rtl-lang|</nowiki>'''tg-Arab'''<nowiki>|تاجیکی}}, ''{{lang|</nowiki>'''tg-Latn'''<nowiki>|toçikī}}'', {{lang|</nowiki>'''tg-Cyrl'''<nowiki>|тоҷикӣ}})</nowiki></code>
 +
: Tajik ({{rtl-lang|tg-Arab|تاجیکی}}, ''{{lang|tg-Latn|toçikī}}'', {{lang|tg-Cyrl|тоҷикӣ}})
  
For example, [[Russian language|Russian]] is usually written in the [[Cyrillic script]], therefore the <code>Cyrl</code> script code is superfluous and the language code will be <code>ru</code> instead of <code>ru-Cyrl</code>. However, when that text is [[transliteration|transliterated]] the <code>transl</code> code (transliteration) should be used because it isn't the default script for Russian: <code>ru-Latn</code>. Example:
+
Many languages, however, are so commonly written in one particular script that specifying the script is unnecessary. [[Russian language|Russian]], for instance, is almost exclusively written in Cyrillic, so there is no need to specify <code>ru-Cyrl</code>, just as <code>en-Latn</code> would be redundant for English. The [[Internet Assigned Numbers Authority|IANA]]'s [http://www.iana.org/assignments/language-subtag-registry/language-subtag-registry language subtag registry] contains up-to-date information on which languages have redundant, or "suppressed", script codes.
  
<pre>
+
=== Transliteration ===
* Moscow ([[Russian language|Russian]]: {{lang|ru|Москва́}}, ''{{transl|ru|Moskva}}'')
 
</pre>
 
which is the same as
 
<pre>
 
* Moscow ({{lang-ru|Москва́}}, ''{{transl|ru|Moskva}}'')
 
</pre>
 
  
Results in your browser:
+
To mark a language which has been [[transliteration|transliterated]] from one script into another, append the new script's code to the code of the original language. So if transliterating from Russian Cyrillic to a Latin script, the language tag on the transliteration would be <code>ru-Latn</code>. As a convenience for transliterating to Latin scripts, and to work around browser styling issues with some language and script combinations, {{tl|transl}} should be used in place of {{tlf|lang}}:
* Moscow ({{lang-ru|Москва́}}, ''{{transl|ru|Moskva}}'')
 
  
Instead of using <code><nowiki>''{{transl|ru|Moskva}}''</nowiki></code> the <code><nowiki>''{{lang|ru-Latn|Moskva}}''</nowiki></code> can be used, but if you specified a font and a size for the target language in your [[Special:Mypage/vector.css|custom CSS]] (see [[Help:User style]]), the transliteration will appear in that specified style. To specify a transliteration scheme, for example, you are using the [[ISO 9]] transliteration of Cyrillic, use <code><nowiki>''{{transl|ru|ISO|Moskva}}''</nowiki></code>:
+
* <code><nowiki>Moscow ({{lang|ru|Москва́}}, ''{{transl|ru|Moskva}}'')</nowiki></code>
* Moscow ({{lang-ru|Москва́}}; [[ISO 9]]: ''{{transl|ru|ISO|Moskva}}'')
+
: Moscow ({{lang|ru|Москва́}}, ''{{transl|ru|Moskva}}'')
  
The [[Internet Assigned Numbers Authority|IANA]] maintains a list specifying when the script tag should be suppressed [http://www.iana.org/assignments/language-subtag-registry]. In some cases, the script must be always specified, like [[Tajik language|Tajik]] which can be equally written in [[Arabic script|Arabic]], [[Latin script|Latin]] or [[Cyrillic script|Cyrillic]] alphabets:
+
To specify a transliteration scheme, such as the [[ISO 9|ISO transliteration standard for Cyrillic]], use {{tlc|transl|ru|ISO|Moskva}}.
<pre>
 
* Tajik ({{rtl-lang|tg-Arab|تاجیکی}}, ''{{transl|tg|tojikī}}'', {{lang|tg-Cyrl|тоҷикӣ}})
 
</pre>
 
Which results in your browser:
 
* Tajik ({{rtl-lang|tg-Arab|تاجیکی}}, ''{{transl|tg|tojikī}}'', {{lang|tg-Cyrl|тоҷикӣ}})
 
Note the use of {{tl|rtl-lang}} instead of {{tl|lang}} when using the Arabic script (see {{section link||Writing direction}}).
 
  
===Undetermined language===
+
=== Undetermined language ===
The <nowiki>{{</nowiki>lang}} template is not only used to specify the language of foreign words, but also to specify a single symbol or character in a specific script, for example when discussing about a specific writing system. Many times the character / symbol is used in several languages, but when the article refers to the [[grapheme]] itself the [[ISO 639‑2]] and [[ISO 639‑3]] language code <code>und</code> for Undetermined language should be used. For example:
 
  
<pre>
+
The {{tlf|lang}} template is not only used to specify the language of foreign words, but can also be used to specify a single symbol or character in a script, unrelated to any specific language. Many times the character or symbol is used in several languages, but when the article refers to the [[grapheme]] itself the [[ISO 639‑2]] language code <code>und</code>, for Undetermined language, should be used:
The {{lang|und-Hani|字}} Han character has 6 strokes.
+
 
</pre>
+
* <code><nowiki>The {{lang|und-Hani|字}} Han character has 6 strokes.</nowiki></code>
:The {{lang|und-Hani|字}} Han character has 6 strokes.
+
: The {{lang|und-Hani|字}} Han character has 6 strokes.
  
 
Han characters are used in Chinese, Japanese, sometimes Korean, and formerly Vietnamese, and in this case the character is not used for any specific language. Note that the script code used is <code>Hani</code>, which specifies generic Han characters (Hanzi, Kanji, Hanja).
 
Han characters are used in Chinese, Japanese, sometimes Korean, and formerly Vietnamese, and in this case the character is not used for any specific language. Note that the script code used is <code>Hani</code>, which specifies generic Han characters (Hanzi, Kanji, Hanja).
  
Compare {{tl|script}}
+
Compare {{tl|script}} usage:
<pre>
+
 
The {{script|Hani|字}} Han character has 6 strokes.
+
* <code><nowiki>The {{script|Hani|字}} Han character has 6 strokes.</nowiki></code>
</pre>
+
: The {{script|Hani|字}} Han character has 6 strokes.
:The {{script|Hani|字}} Han character has 6 strokes.
 
  
 
== Indicating regional variant ==
 
== Indicating regional variant ==
  
In some cases, maybe it will be needed to add [[ISO 3166-1 alpha-2]] country codes (specific usage of that country). Of course the three codes can appear in the same tag, for example the code <code>zh-Hant-TW</code> will be used for [[Chinese language|Chinese]] text written with [[Traditional Chinese characters|Traditional Han characters]], containing words or expressions specific to [[Taiwan]]. <code>zh-Hans</code> is for simplified. Examples:
+
When it is necessary to indicate region-specific language, an [[ISO 3166-1 alpha-2]] country code, or [[UN M.49]] region code, should be added to the language tag, taking care to preserve capitalization. For example, [[Portuguese language|Portuguese]] (<code>pt</code>) as used in [[Brazil]] (<code>BR</code>) could be represented as <code>pt-BR</code>, and [[Spanish language|Spanish]] as used in [[Latin America]] as <code>es-419</code>. Additionally, language, script, and region codes can all appear in the same tag. For instance, the code <code>zh-Hant-TW</code> should be used for [[Chinese language|Chinese]] text written with [[Traditional Chinese characters|Traditional Han characters]], containing words or expressions specific to [[Taiwan]]:
  
<pre>
+
* <code><nowiki>Taiwan ({{lang|zh-Hant-TW|臺灣}}, ''{{transl|zh|Táiwān}}'')</nowiki></code>
* {{lang|zh-Hant-TW|臺灣}}
+
: Taiwan ({{lang|zh-Hant-TW|臺灣}}, ''{{transl|zh|Táiwān}}'')
</pre>
 
 
 
Results in your browser:
 
* {{lang|zh-Hant-TW|臺灣}}
 
  
 
== Writing direction ==
 
== Writing direction ==
  
To embed a string of right-to-left text (from languages like [[Arabic language|Arabic]] or [[Hebrew language|Hebrew]]) within the usual left-to-right context, you should add the {{para|rtl|yes}} parameter, so the writing direction is correctly indicated to browsers.
+
To embed a string of right-to-left text (from languages like [[Arabic language|Arabic]] or [[Hebrew language|Hebrew]]) within the usual left-to-right context, you should add the {{para|rtl|yes}} parameter, so the writing direction can be correctly communicated to browsers. ''Alternatively'', you can use the {{tl|rtl-lang}} template to accomplish the same result, or {{tl|rtl-para}} for marking up whole paragraphs of right-to-left text.
 
 
''Alternatively'' you can use {{tlx|rtl-lang}} which basically is a shortcut giving the same result, or {{tlx|rtl-para}} for whole paragraphs of right-to-left text.
 
  
Either of these approaches wrap the text in a container with the dir="rtl" attribute. In order to ensure correct rendering in legacy browsers that don't fully support [[HTML 5]] [[bi-directional text|bidirectional isolation]], it also adds the [[Left-to-right mark|&amp;lrm;]] character at the end of the span (see the [http://www.w3.org/International/articles/inline-bidi-markup details] at [[W3C]]).
+
Either of these approaches will wrap the text in a container with the <code>dir="rtl"</code> attribute. In order to ensure correct rendering in browsers that don't fully support [[HTML 5]] [[bi-directional text|bidirectional isolation]], they may also add a [[left-to-right mark]] at the end of the text (see the [http://www.w3.org/International/articles/inline-bidi-markup W3C] for details).
  
Note that the text direction doesn't have to be specified when using the {{tl|lang-xx}} template, as this is implied by the language. Therefore there is no {{tl|rtl-lang-ar}} – just use {{tlx|lang-ar}}.
+
Note that text direction doesn't have to be specified when using the {{tl|lang-xx}} templates, as this is implied by the template's language. There is therefore no {{tl|rtl-lang-ar}}, only {{tl|lang-ar}}.
  
 
== Rationale ==
 
== Rationale ==
Line 161: Line 149:
 
* [[World Wide Web Consortium|W3C]]
 
* [[World Wide Web Consortium|W3C]]
 
** [http://www.w3.org/International/articles/language-tags/Overview.en.php Language tags in HTML and XML] – Overview
 
** [http://www.w3.org/International/articles/language-tags/Overview.en.php Language tags in HTML and XML] – Overview
** [http://www.w3.org/TR/i18n-html-tech-lang/ Internationalization Best Practices: Specifying Language in XHTML & HTML Content] – W3C Working Draft 21 July 2006
+
** [http://www.w3.org/TR/i18n-html-tech-lang/ Authoring HTML: Language declarations] – Latest W3C Working Draft
 
** [http://www.w3.org/International/articles/bcp47/ Understanding the New Language Tags]
 
** [http://www.w3.org/International/articles/bcp47/ Understanding the New Language Tags]
 
** [http://www.w3.org/International/questions/qa-css-lang FAQ: Styling using the lang attribute]
 
** [http://www.w3.org/International/questions/qa-css-lang FAQ: Styling using the lang attribute]

Revision as of 01:08, 29 April 2016

The purpose of this template is to indicate that a span of text belongs to a particular language. It often makes no visible changes to the text, but can prompt web browsers to use a more appropriate font, or screen readers to use a particular kind of pronunciation, and so on. The Script error: No such module "Section link"., below, provides more information.

Syntax and usage

{{lang|language tag|text}}

The language tag should consist of an ISO 639 language code, optionally extended to indicate a language's script or region. The language code is usually a two- or three-letter abbreviation, in lowercase, of the language's name. French, for example, has the code fr:

  • She said: "''{{lang|fr|Je suis française.}}''"
She said: "Je suis française."

Because all languages represented by two-letter codes in ISO 639‑1 can also be represented by their newer three-letter equivalents in ISO 639‑2 and above, it is recommended to use the shortest language tag possible that sufficiently describes the target language.[1] So while French could be represented by 639‑2's fra code, 639‑1's fr should still take precedence. Likewise, script and region information should only be included when they make a necessary distinction.

It is better to only include the foreign-language text (linked if appropriate) inside the template, so that any extraneous markup which is not from the foreign language does not receive incorrect metadata for that language:

  • Use ''{{lang|it|[[goriziana]]}}''
  • Not {{lang|it|''[[goriziana]]''}}

This includes italicization of foreign words; English-language quotation marks around titles of works in languages that use other quotation character glyphs; italicization of titles in languages which do not use that convention; and emphasis that is not found (in one style or another) in the original foreign text; among other cases. If in doubt, put such markup outside the template.

By default, this template will place articles into the relevant subcategory of Category:Articles containing non-English-language text. To suppress this – e.g. when using {{lang}} within a wikilink or the title parameter of a citation – add the parameter |nocat=true.

There are also language-specific versions of this template, such as {{lang-fr}} and {{lang-ru}}, which are intended to be used the first time a language appears in an article. These templates will print the language's name and, when appropriate, italicize their content:

  • A '''kremlin''' ({{lang-ru|кремль}}, ''castle'') is a major fortified central complex...
A kremlin (Russian: кремль, castle) is a major fortified central complex...

Italics

By default, {{lang}} outputs plain text, while {{lang-xx}} templates (e.g. {{lang-de}}) output text in italics for languages using Latin-based scripts. If plain text is required with the latter, such as for proper names, {{noitalic}} may be used:

  • ... the border town of Ventimiglia ({{lang-fr|{{noitalic|Vintimille}}}})
... the border town of Ventimiglia (French: Vintimille)

Indicating writing script

If necessary, an ISO 15924 script code can be appended to a language code to indicate the use of a specific script. For instance, Tajik (tg) is a language which can be found written in Arabic (Arab), Latin (Latn), and Cyrillic (Cyrl) scripts, making it necessary to always specify which script is in use. In such a case, taking care to preserve the script's capitalization, we could end up with the following code (language tags in bold):

  • Tajik ({{rtl-lang|tg-Arab|تاجیکی}}, ''{{lang|tg-Latn|toçikī}}'', {{lang|tg-Cyrl|тоҷикӣ}})
Tajik (Template:Rtl-lang, toçikī, тоҷикӣ)

Many languages, however, are so commonly written in one particular script that specifying the script is unnecessary. Russian, for instance, is almost exclusively written in Cyrillic, so there is no need to specify ru-Cyrl, just as en-Latn would be redundant for English. The IANA's language subtag registry contains up-to-date information on which languages have redundant, or "suppressed", script codes.

Transliteration

To mark a language which has been transliterated from one script into another, append the new script's code to the code of the original language. So if transliterating from Russian Cyrillic to a Latin script, the language tag on the transliteration would be ru-Latn. As a convenience for transliterating to Latin scripts, and to work around browser styling issues with some language and script combinations, {{transl}} should be used in place of {{lang}}:

  • Moscow ({{lang|ru|Москва́}}, ''{{transl|ru|Moskva}}'')
Moscow (Москва́, Template:Transl)

To specify a transliteration scheme, such as the ISO transliteration standard for Cyrillic, use {{transl|ru|ISO|Moskva}}.

Undetermined language

The {{lang}} template is not only used to specify the language of foreign words, but can also be used to specify a single symbol or character in a script, unrelated to any specific language. Many times the character or symbol is used in several languages, but when the article refers to the grapheme itself the ISO 639‑2 language code und, for Undetermined language, should be used:

  • The {{lang|und-Hani|字}} Han character has 6 strokes.
The Han character has 6 strokes.

Han characters are used in Chinese, Japanese, sometimes Korean, and formerly Vietnamese, and in this case the character is not used for any specific language. Note that the script code used is Hani, which specifies generic Han characters (Hanzi, Kanji, Hanja).

Compare {{script}} usage:

  • The {{script|Hani|字}} Han character has 6 strokes.
The Template:Script Han character has 6 strokes.

Indicating regional variant

When it is necessary to indicate region-specific language, an ISO 3166-1 alpha-2 country code, or UN M.49 region code, should be added to the language tag, taking care to preserve capitalization. For example, Portuguese (pt) as used in Brazil (BR) could be represented as pt-BR, and Spanish as used in Latin America as es-419. Additionally, language, script, and region codes can all appear in the same tag. For instance, the code zh-Hant-TW should be used for Chinese text written with Traditional Han characters, containing words or expressions specific to Taiwan:

  • Taiwan ({{lang|zh-Hant-TW|臺灣}}, ''{{transl|zh|Táiwān}}'')
Taiwan (臺灣, Template:Transl)

Writing direction

To embed a string of right-to-left text (from languages like Arabic or Hebrew) within the usual left-to-right context, you should add the |rtl=yes parameter, so the writing direction can be correctly communicated to browsers. Alternatively, you can use the {{rtl-lang}} template to accomplish the same result, or {{rtl-para}} for marking up whole paragraphs of right-to-left text.

Either of these approaches will wrap the text in a container with the dir="rtl" attribute. In order to ensure correct rendering in browsers that don't fully support HTML 5 bidirectional isolation, they may also add a left-to-right mark at the end of the text (see the W3C for details).

Note that text direction doesn't have to be specified when using the {{lang-xx}} templates, as this is implied by the template's language. There is therefore no {{rtl-lang-ar}}, only {{lang-ar}}.

Rationale

Applying styles

You can apply CSS styles in your user style sheet. Registered users can put styles into User:XXX/monobook.css, where XXX is the user name.

These examples may work in Internet Explorer 8; prior versions do not support attribute selectors. Alternatively, try another browser such as Firefox.

Example: to apply a font to Russian-language text:

 span[lang|=ru] { font-family: fonteskaya; }

Example: to apply a colour to text marked with any language:

 span[lang] { color: green; }

Do not use quotation marks in your user style sheet; wikitext would screw them up. They are recommended in CSS, but not required other than for font families containing generic-family keywords ('inherit', 'serif', 'sans-serif', 'monospace', 'fantasy', and 'cursive'). See here for details.

TemplateData

This is the TemplateData documentation for this template used by VisualEditor and other tools; see the monthly parameter usage report for this template.

TemplateData for Lang

Indicate that a given span of text belongs to a particular language. Use by browsers which use different styles for different languages.

Template parameters

ParameterDescriptionTypeStatus
Language code1

A language tag or an ISO 639 language code.

Example
fr (the code for French)
Stringrequired
Text2

The text belonging to the language specified.

Example
Je suis française.
Stringrequired

See also

Further information

References

  1. "Language tags in HTML and XML" at World Wide Web Consortium
  2. Heilmann, Chris (13 Mar 2008). "Yahoo! search results now with natural language support". Yahoo! Developer Network Blog. Archived from the original on 25 Jan 2009. Retrieved 28 Feb 2015. Unknown parameter |dead-url= ignored (|url-status= suggested) (help)
  3. 3.0 3.1 3.2 Ishida, Richard (18 November 2014). "Why use the language attribute?". World Wide Web Consortium. Retrieved 1 Mar 2015.
  4. "6.4 Ligatures: the font-variant-ligatures property". CSS Fonts Module Level 3 W3C Candidate Recommendation 3 October 2013.