(New page: <span lang="{{{1}}}" xml:lang="{{{1}}}">{{{2}}}</span><noinclude> {{documentation}}<!-- Add cats and interwikis to the /doc subpage, not here! -->{{usedwp}}</noinclude>)
Line 1: Line 1:
<span lang="{{{1}}}" xml:lang="{{{1}}}">{{{2}}}</span><noinclude>
<span lang="{{{1}}}" xml:lang="{{{1}}}">{{{2}}}</span><noinclude>
{{documentation}}<!-- Add cats and interwikis to the /doc subpage, not here! -->{{usedwp}}</noinclude>
{{documentation}}<!-- Add cats and interwikis to the /doc subpage, not here! -->{{usedwp}} </noinclude>

Latest revision as of 01:44, 3 October 2007


[edit] [purge] Template documentation

The following documentation is transcluded from Template:Lang/doc.


The purpose of this template is to indicate that a given span of text belongs to a particular language (see language code).

{{lang|Language tag|Text}}

Use ISO 639 language codes. Example (where fr is the code for French):

* She said: "{{lang|fr|''Je suis Française.''}}"

Results in your browser:

  • She said: "Je suis Française."

Also, there are also versions of this template for each specific language that also print the language's name, intended to be used the first time that language is used in the article. For example, "{{lang-es|Español}}" and "{{lang-ru|русский язык}}" gives "Spanish: Español" and "Russian: русский язык".

Language subtags can also be used to indicate writing script or regional variation of a language. According to the W3C, "The golden rule when creating language tags is to keep the tag as short as possible",[1] so such subtags should only be added if there is an important reason to use them. ISO 639-1 is preferred over ISO 639-2 and ISO 639-3.

Indicating writing script

If necessary, add the ISO 15924 code to indicate the script.

For example, Russian is usually written in the Cyrillic alphabet, therefore the 'Cyrl' script code is superfluous and the language code will be ru instead of ru-Cyrl. However, when that text is transliterated the Latn code (latin script) should be used because it isn't the default script for Russian: ru-Latn. Example:

* Moscow ([[Russian language|Russian]]: {{lang|ru|Москва́}}, {{lang|ru-Latn|''Moskva''}})

which is the same as

* Moscow ({{lang-ru|Москва́}}, {{lang|ru-Latn|''Moskva''}})

Results in your browser:

  • Moscow (Russian: Москва́, Moskva)

{{lang|ru-Latn|''Moskva''}} is equivalent to {{transl|ru|''Moskva''}}. To specify you are using the ISO 9 transliteration of Cyrillic, use {{transl|ru|ISO|''Moskva''}}:

IANA maintains a list specifying when the script tag should be suppressed [2]. In some cases the script must be always specified, like Tajik which can be equally written in Arabic, Latin or Cyrilic alphabets:

* Tajik ({{rtl-lang|tg-Arab|تاجیکی}}, {{lang|tg-Latn|''tojikī''}}, {{lang|tg-Cyrl|тоҷикӣ}})

Which results in your browser:

  • Tajik (تاجیکی‎, tojikī, тоҷикӣ)

Note the use of {{rtl-lang}} instead of {{lang}} when using the Arabic script (see below section writing direction).

Indicating regional variant

In some cases, maybe it will be needed to add wikipedia: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 zh-Hant-TW will be used for Chinese text written with Traditional Han characters, containing words or expressions specific to Taiwan. Examples:

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

Results in your browser:

  • 臺灣

Writing direction

{{rtl-lang}} is a specific template for right-to-left languages like Arabic or Hebrew.

for right-to-left paragraphs (as opposed to rtl strings embedded in an English paragraph), use {{rtl-para}}.


  • Web browsers can use the information to choose an appropriate font.
    • This is great for wikipedia:CJK where a character can be given its language-specific shape but will fall back to another form if no appropriate font is found or if the preferred font lacks that character, for example because the language does not make use of that character: see this comparison table and screenshot.
  • For accessibility purposes: screen readers need language info to provide correctly audio output.
  • For spell checkers and grammar checkers.
  • To help browsers choosing appropriate quotation marks, and making decisions about hyphenation, ligatures, and spacing.
  • Users can apply styles to languages in their style sheets (useful for editors).
  • Google and other search engines can use this information when indexing text.
  • Could be useful for application developers who re-publish Wikipedia.
  • Could be useful for research or compiling statistics about language use in Wikipedia.

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 will not work in Internet Explorer, because it doesn't support attribute selectors. Try 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; }

Note: don't use quotation marks in your your user style sheet. Wikitext will screw them up. They are recommended in CSS, but not required.

See also


This page uses content from the English language Wikipedia. The original content was at Template:Lang. The list of authors can be seen in the page history. As with this Familypedia wiki, the content of Wikipedia is available under the Creative Commons License.