Template:Lang/doc

From blackwiki
< Template:Lang
Revision as of 11:43, 19 September 2014 by imported>Sardanaphalus (some rephrasings, replaced <tt>, ref ... to do: size option)
Jump to navigation Jump to search

The purpose of this template is to indicate, via 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 "Rationale" section below provides more information.

Syntax and usage

{{lang|ISO 639 language code|text}}

The ISO 639 code is usually a two or three-letter abbreviation, in lowercase, of the language's name. French, for example, has the code "fr":

Template:Plaincode 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 Template:Plaincode for Undetermined language should be used. For example:
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 Template:Plaincode, which specifies generic Han characters (Hanzi, Kanji, Hanja).

Compare {{script}}

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

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 Template:Plaincode will be used for Chinese text written with Traditional Han characters, containing words or expressions specific to Taiwan. Template:Plaincode is for simplified. Examples:

* {{lang|zh-Hant-TW|臺灣}}

Results in your browser:

  • 臺灣

Writing direction

{{rtl-lang}} is used to wrap strings of right-to-left text (from languages like Arabic or Hebrew) embedded in left-to-right text, and resets text direction to left-to-right at its conclusion. For whole paragraphs of right-to-left text, use {{rtl-para}}. The rtl- prefix is not needed in the {{lang-xx}} form, as this is implied by the language: there is no {{rtl-lang-ar}}, for instance: just use {{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 http://www.w3.org/TR/CSS21/fonts.html#font-family-prop 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, e.g. fr (the code for French).

Stringrequired
Text2

The text e.g. Je suis française.

Stringrequired

See also

Further information

References