Difference between revisions of "Template:Lang/doc"

From YUIkipedia
Jump to navigation Jump to search
(+interwiki)
 
m (1 revision)
(One intermediate revision by the same user not shown)
Line 1: Line 1:
<noinclude>{{Documentation subpage}}</noinclude><includeonly>{{Pp-template}}{{使用箇所の多いテンプレート|90,000以上}}</includeonly>
+
{{documentation subpage}}
本文内で日本語以外の表記を行う際に、言語コードを明示的に指定して表示させるためのテンプレートです。このテンプレートを使うことで漢字の[[グリフ]]([[字体]])の違いを表現したり、[[ハングル]]等の文字化けを防いだりできます。
+
The purpose of this template is to indicate that a given span of text belongs to a particular language (see [[language code]]). It often makes no visible changes to the text, but can help web browsers choose the right font, screen readers use the right pronunciation and more.
  
注:インド系文字([[ブラーフミー系文字]])などの一部の文字を表示するには本テンプレートでの言語コード指定に加えてお使いのコンピュータのオペレーティングシステムやウェブブラウザの設定が必要になる場合があります。詳しい情報は[[Help:特殊文字]]を参照してください。
+
<nowiki>{{</nowiki>lang|''Language tag''|''Text''}}
  
__TOC__
+
Use [[List of ISO 639 codes|ISO 639 language codes]]. Example (where <tt>fr</tt> is the code for [[French language|French]]):
== 使い方 ==
 
<nowiki>{{lang|言語タグ|文字列}}</nowiki>
 
  
== 言語タグ ==
+
<pre>
{{see also|IETF言語タグ}}
+
* She said: "{{lang|fr|''Je suis française.''}}"
 +
</pre>
  
言語タグは[http://tools.ietf.org/html/bcp47 BCP 47]で定義されています。言語タグはハイフンで区切られた一連の下位タグ (subtag) から構成されます。このうち language のみ必須で、それ以外は省略可です。下位タグは不要な場合には可能な限り省略することが推奨されます。
+
Results in your browser:
 +
* She said: "{{lang|fr|''Je suis française.''}}"
  
書式: ''language-script-region-variant-extension-privateuse''
+
There are also versions of this template for specific languages that also print the language's name, intended to be used the first time that language is used in the article. For example, "{{tlx|lang-es|Español}}" and "{{tlx|lang-ru|русский язык}}" gives "{{lang-es|Español}}" and "{{lang-ru|русский язык}}".
  
{| class="wikitable" border="1"
+
Language subtags can also be used to indicate writing script or regional variation of a language.  According to the [[World Wide Web Consortium|W3C]], "The golden rule when creating language tags is to keep the tag as short as possible",[http://www.w3.org/International/articles/language-tags/Overview.en.php] 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]].
|+ 言語タグの下位タグの一覧
 
! 下位タグ名 !! 指定内容 !! 説明
 
|-
 
! language
 
| [[ISO 639]](言語名コード) || 言語の特定を避けたい場合は und (undetermined、「非決定」の略)を指定できる。<br />小文字で書くことが推奨される。
 
|-
 
! script
 
| [[ISO 15924]](用字系コード) || 省略された場合にはその言語の基本の用字系が選択される。<br />1文字目を大文字で書くことが推奨される。
 
|-
 
! region
 
| [[ISO 3166-1]](国名コード)<br />[[ISO 3166]](地域名コード)|| 大文字で書くことが推奨される。
 
|-
 
! variant
 
|  || 方言など、上記の下位タグでカバーしきれない情報を示す。
 
|-
 
! extension
 
|  ||(予約領域)
 
|-
 
! privateuse
 
| ||(私的領域。ウィキペディアでは使用されていない)
 
|}
 
  
==言語タグの例==
+
=== Indicating writing script ===
*単純な例 (''language'')
+
If necessary, add the [[List of ISO 15924 codes|ISO 15924]] code to indicate the script.
**<code>en</code> : 英語
 
**<code>ko</code> : 韓国語
 
**<code>zh</code> : 中国語
 
*''language-region'' の例
 
**<code>en-GB</code> : イギリスで用いられている英語
 
**<code>ko-KP</code> : 朝鮮民主主義人民共和国で用いられている韓国語(南北における差異があまり大きくないため、通常は用いられない)
 
**<code>zh-TW</code> : 台湾で用いられている中国語
 
**<code>es-005</code> : 南米で用いられているスペイン語
 
*''language-script'' の例
 
**<code>ar-Latn</code> : アラビア語、ラテン文字転写
 
**<code>zh-Hans</code> : 中国語、簡体字
 
**<code>zh-Hant</code> : 中国語、繁体字
 
**<code>und-Hant</code> : 言語非決定、繁体字(伝統字)<ref>RFC3066では、"You SHOULD NOT use the UND (Undetermined) code unless the protocol in use forces you to give a value for the language tag, even if the language is unknown.  Omitting the tag is preferred."(「もし使用するプロトコルが言語タグについて値を与える事を強制するのでなければ、たとえその言語が不明であっても、UND (Undetermined) というコードを使用すべきではない。その場合、タグを省略すべきである。 」) としていることに注意。</ref>
 
*''language-script-region'' の例
 
**<code>zh-Hant-HK</code> : 香港で用いられている中国語、繁体字
 
*''language-variant'' ほかの例
 
**<code>sl-nedis</code> : スロベニア語 Nadiza 方言
 
**<code>de-CH-1901</code> : スイスで使用されるドイツ語、1901年版[[正書法]]利用
 
  
== 用途 ==
+
For example, [[Russian language|Russian]] is usually written in the [[Cyrillic alphabet]], therefore the '<tt>Cyrl</tt>' script code is superfluous and the language code will be <tt>ru</tt> instead of <tt>ru-Cyrl</tt>. However, when that text is [[transliteration|transliterated]] the <tt>Latn</tt> code (latin script) should be used because it isn't the default script for Russian: <tt>ru-Latn</tt>.  Example:
言語タグは以下の用途に用いられます。
 
*ウェブブラウザがどのフォントなどを用いるかを決定する判断材料として利用します。
 
*[[アクセシビリティ]]。スクリーンリーダーが正しく発音するのに利用します。
 
*スペルチェッカや文法チェッカ。
 
*ウェブブラウザがどの字体・引用符・ハイフンなどを用いるかを決定する判断材料として利用します。
 
*スタイルシートで特定の言語の色を変更できます([[#スタイルシートの適用]]を参照)。執筆者の手助けになります。
 
*検索エンジンが文章をインデックスする際に利用できます。
 
*ウィキペディアを再利用する出版社・開発者などが利用できます。
 
*ウィキペディアにおける利用言語の統計に利用できます。
 
  
== スタイルシートの適用 ==
+
<pre>
登録ユーザーは、個人設定のユーザーCSSを活用することによって、本テンプレートによって言語指定がされた文に特定のフォントを使用するよう指定することができます。
+
* Moscow ([[Russian language|Russian]]: {{lang|ru|Москва́}}, {{lang|ru-Latn|''Moskva''}})
 +
</pre>
 +
which is the same as
 +
<pre>
 +
* Moscow ({{lang-ru|Москва́}}, {{lang|ru-Latn|''Moskva''}})
 +
</pre>
  
例:ロシア語の文に特定のフォントを指定する
+
Results in your browser:
 +
* Moscow ({{lang-ru|Москва́}}, {{lang|ru-Latn|''Moskva''}})
  
  span[lang|=ru] { font-family: fonteskaya; }
+
<nowiki>{{lang|ru-Latn|''Moskva''}}</nowiki> is equivalent to <nowiki>{{transl|ru|''Moskva''}}</nowiki>. To specify you are using the [[ISO 9]] transliteration of Cyrillic, use <nowiki>{{transl|ru|ISO|''Moskva''}}</nowiki>:
 +
* Moscow ({{lang-ru|Москва́}}, [[ISO 9]]: {{transl|ru|ISO|''Moskva''}})
 +
 
 +
[[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 alphabet|Arabic]], [[Latin alphabet|Latin]] or [[Cyrillic alphabet|Cyrillic]] alphabets:
 +
<pre>
 +
* Tajik ({{rtl-lang|tg-Arab|تاجیکی}}, {{lang|tg-Latn|''tojikī''}}, {{lang|tg-Cyrl|тоҷикӣ}})
 +
</pre>
 +
Which results in your browser:
 +
* Tajik ({{rtl-lang|tg-Arab|تاجیکی}}, {{lang|tg-Latn|''tojikī''}}, {{lang|tg-Cyrl|тоҷикӣ}})
 +
Note the use of {{tl|rtl-lang}} instead of {{tl|lang}} when using the Arabic script (see below section [[#Writing direction|writing direction]]).
 +
 
 +
==== 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 <tt>und</tt> for Undetermined language. For example:
 +
 
 +
<pre>
 +
The {{lang|und-Hani|字}} Han character has 6 strokes.
 +
</pre>
 +
: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 <tt>Hani</tt>, which specifies generic Han characters (Hanzi, Kanji, Hanja).
 +
 
 +
compare {{tl|script}}
 +
<pre>
 +
The {{script|Hani|字}} Han character has 6 strokes.
 +
</pre>
 +
:The {{script|Hani|字}} 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 <tt>zh-Hant-TW</tt> will be used for [[Chinese language|Chinese]] text written with [[Traditional Chinese characters|Traditional Han characters]], containing words or expressions specific to [[Taiwan]]. <tt>zh-Hans</tt> is for simplified. Examples:
 +
 
 +
<pre>
 +
* {{lang|zh-Hant-TW|臺灣}}
 +
</pre>
 +
 
 +
Results in your browser:
 +
* {{lang|zh-Hant-TW|臺灣}}
 +
 
 +
=== Writing direction ===
 +
<s>{{tl|rtl-lang}} is a specific template for right-to-left languages like [[Arabic language|Arabic]] or [[Hebrew language|Hebrew]].</s>
  
例:言語指定された文すべてにおいて色を変更する
+
For right-to-left paragraphs (as opposed to rtl strings embedded in an English paragraph), use {{tl|rtl-para}}.
  
  span[lang] { color: green; }
+
== Rationale ==
 +
* Web browsers can use the information to choose an appropriate font.
 +
** This is great for [[CJK characters|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 [[User:Wikipeditor/CJK|this comparison table and screenshot]].
 +
* For [[web accessibility|accessibility]] purposes: [[screen reader]]s need language info to provide correctly audio output.
 +
* For [[spell checker]]s and grammar checkers.
 +
* To help browsers choosing appropriate [[quotation mark]]s, and making decisions about [[Hyphen|hyphenation]], [[Typographic ligature|ligature]]s, and spacing.
 +
* Users can apply styles to languages in their [[Style sheet (web development)|style sheet]]s (useful for editors).
 +
* Google and other [[Web search engine|search engine]]s can use this information when [[index (information technology)|indexing]] text.
 +
* Facilitates better data-scraping. parsing and re-use.
 +
* 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 ==
=== 例1:「骨」 ===
+
You can apply [[Cascading Style Sheets|CSS]] styles in your user style sheet.  Registered users can put styles into User:XXX/monobook.css, where ''XXX'' is the user name. 
「骨」という字のグリフは日本語と中国語では左右対称となっている。
 
  
{| class="wikitable" style="margin:0 auto; text-align:center"
+
These examples may work in [[Internet Explorer 8]]; prior versions do not support attribute selectors.  Alternatively, try [[List of web browsers|another browser]] such as [[Mozilla Firefox|Firefox]].
!!!日本語!!中国語!!中国語(台湾)!!韓国語
 
|-
 
|入力例||骨||<nowiki>{{Lang|zh|骨}}</nowiki>||<nowiki>{{Lang|zh-tw|骨}}</nowiki>||<nowiki>{{Lang|ko|骨}}</nowiki>
 
|-
 
|表示例||骨||{{Lang|zh|骨}}||{{Lang|zh-tw|骨}}||{{Lang|ko|骨}}
 
|}
 
  
=== 例2:「近」 ===
+
Example: to apply a font to Russian-language text:
「近」という字のグリフは日本語と中国語では1点[[チャク部|しんにょう]]だが、韓国語では2点しんにょうである。
 
  
また、中国語(台湾)ではくねくねとした1点しんにょうとなっている(または2点しんにょう)。
+
  span[lang|=ru] { font-family: fonteskaya; }
  
{| class="wikitable" style="margin:0 auto; text-align:center"
+
Example: to apply a colour to text marked with any language:
!!!日本語!!中国語!!中国語(台湾)!!韓国語
 
|-
 
|入力例||近||<nowiki>{{Lang|zh|近}}</nowiki>||<nowiki>{{Lang|zh-tw|近}}</nowiki>||<nowiki>{{Lang|ko|近}}</nowiki>
 
|-
 
|表示例||近||{{Lang|zh|近}}||{{Lang|zh-tw|近}}||{{Lang|ko|近}}
 
|}
 
  
=== 例3:「偉」 ===
+
  span[lang] { color: green; }
「偉」という字のグリフは日本語と中国語では「韋」の形が異なっている。
 
  
{| class="wikitable" style="margin:0 auto; text-align:center"
+
Do ''not'' use quotation marks in your user style sheet; Wikitext will screw them up.  They are recommended in CSS, but not required.
!!!日本語!!中国語!!中国語(台湾)!!韓国語
 
|-
 
|入力例||偉||<nowiki>{{Lang|zh|偉}}</nowiki>||<nowiki>{{Lang|zh-tw|偉}}</nowiki>||<nowiki>{{Lang|ko|偉}}</nowiki>
 
|-
 
|表示例||偉||{{Lang|zh|偉}}||{{Lang|zh-tw|偉}}||{{Lang|ko|偉}}
 
|}
 
  
==脚注==
+
== See also ==
<references />
+
* [[:Category:Multilingual support templates]]
 +
* [[List of ISO 639 codes]] (language codes)
 +
* [[List of ISO 15924 codes]] (script codes)
 +
* [[List of ISO romanizations|List of ISO transliterations]] (transliteration codes)
 +
* {{tl|transl}}  for romanisation of languages not natively written in the Latin alphabet.
 +
* {{tl|script}}
 +
* [[:Category:Language icon templates]], for visually marking external links to foreign-language content
  
== 関連項目 ==
+
== References ==
{{Commons|Template:Lang|Template:Lang}}
+
* [[World Wide Web Consortium|W3C]]
* [[Wikipedia:Template メッセージの一覧/汎用#多言語の文字]]
+
** [http://www.w3.org/International/articles/language-tags/Overview.en.php Language tags in HTML and XML]—overview
* {{tl|Llang}} - 言語名や読み方を併記できるテンプレート
+
** [http://www.w3.org/TR/i18n-html-tech-lang/ Internationalization Best Practices: Specifying Language in XHTML & HTML Content]—W3C Working Draft 21 July 2006
* {{tl|ラテン翻字}}
+
** [http://www.w3.org/International/articles/bcp47/ Understanding the New Language Tags]
* [[Help:特殊文字]]
+
** [http://www.w3.org/International/questions/qa-css-lang FAQ: Styling using the lang attribute]
* [[IETF言語タグ]]
+
* [[Internet Assigned Numbers Authority|IANA]]
 +
** [http://www.iana.org/assignments/language-subtag-registry IANA Language Subtag Registry]
 +
** [http://www.rfc-editor.org/rfc/rfc4646.txt Tags for Identifying Languages] (RFC 4646)
 +
** [http://www.rfc-editor.org/rfc/rfc4647.txt Matching of Language Tags] (RFC 4647)
 +
** [http://www.iana.org/assignments/language-tags Language tags]—(obsolete per RFC4646)
 +
* [[Mozilla Firefox]]
 +
** [https://bugzilla.mozilla.org/show_bug.cgi?id=192636 Bug with script selection]
  
== 外部リンク ==
 
*解説
 
**[http://tools.ietf.org/html/bcp47 IETF による BCP 47 の説明]
 
**[http://www.w3.org/International/articles/language-tags/Overview.en.php W3C による言語タグの解説](英語)
 
**[http://www.w3.org/TR/i18n-html-tech-lang/ Internationalization Best Practices: Specifying Language in XHTML & HTML Content](英語)
 
**[http://www.studyinghttp.net/rfc_ja/rfc3066.ja.html RFC 3066の和訳]
 
*コードの一覧
 
**[http://www.iana.org/assignments/language-subtag-registry IANA の言語下位タグのレジストリ]
 
**[http://unicode.org/iso15924/iso15924-codes.html ISO 15924(用字系コード)の一覧]
 
**[http://www.iso.org/iso/en/prods-services/iso3166ma/02iso-3166-code-lists/index.html ISO 3166 (地域コード)の一覧]
 
  
 
<includeonly>
 
<includeonly>
<!-- カテゴリは以下に記入してください -->
+
<!-- ADD CATEGORIES BELOW THIS LINE -->
{{DEFAULTSORT:{{PAGENAME}}}}
+
[[Category:Multilingual support templates|{{PAGENAME}}]]
[[Category:多言語支援テンプレート]]
+
<!-- ADD INTERWIKIS BELOW THIS LINE -->
[[Category:言語タグテンプレート|*]]
 
[[Category:条件文]]
 
 
 
<!-- 言語間リンクは以下に記入してください -->
 
 
[[ab:Шаблон:Lang]]
 
[[ab:Шаблон:Lang]]
 +
[[ace:Templat:Lang]]
 +
[[af:Sjabloon:Lang]]
 +
[[als:Vorlage:Lang]]
 +
[[am:መለጠፊያ:Lang]]
 +
[[an:Plantilla:Lang]]
 +
[[ang:Bysen:Lang]]
 
[[ar:قالب:Lang]]
 
[[ar:قالب:Lang]]
 +
[[ast:Plantía:Lang]]
 
[[av:Шаблон:Lang]]
 
[[av:Шаблон:Lang]]
 
[[ay:Plantilla:Lang]]
 
[[ay:Plantilla:Lang]]
 +
[[az:Şablon:Dillər]]
 
[[bar:Vorlage:Lang]]
 
[[bar:Vorlage:Lang]]
 
[[be-x-old:Шаблён:Мова]]
 
[[be-x-old:Шаблён:Мова]]
 
[[bg:Шаблон:lang]]
 
[[bg:Шаблон:lang]]
 +
<!-- [[bo:Charmenian]] I don’t remember from which interwiki series it comes but that page doesn’t exist! Nor bo:Template:Lang -->
 
[[ca:Plantilla:Lang]]
 
[[ca:Plantilla:Lang]]
 +
[[cr:Template:Lang]]
 
[[cs:Šablona:Jazyk]]
 
[[cs:Šablona:Jazyk]]
 
[[cv:Шаблон:Lang]]
 
[[cv:Шаблон:Lang]]
 
[[da:Skabelon:Lang]]
 
[[da:Skabelon:Lang]]
 
[[de:Vorlage:Lang]]
 
[[de:Vorlage:Lang]]
[[en:Template:Lang]]
+
<!-- [[en:Template:Lang]] -->
 
[[eo:Ŝablono:Lang]]
 
[[eo:Ŝablono:Lang]]
 
[[es:Plantilla:Lang]]
 
[[es:Plantilla:Lang]]
Line 165: Line 161:
 
[[fa:الگو:Lang]]
 
[[fa:الگو:Lang]]
 
[[fr:Modèle:Lang]]
 
[[fr:Modèle:Lang]]
 +
[[gl:Modelo:Lang]]
 
[[gu:ઢાંચો:Lang]]
 
[[gu:ઢાંચો:Lang]]
 
[[hi:साँचा:Lang]]
 
[[hi:साँचा:Lang]]
 
[[hsb:Předłoha:Lang]]
 
[[hsb:Předłoha:Lang]]
 +
<!-- [[ht:Modèl:Lang]] doesn’t offer the same feature  (puts text (parameter 2) in bold mise with a link to the parameter 1 page) -->
 
[[hu:Sablon:Lang]]
 
[[hu:Sablon:Lang]]
 
[[ia:Patrono:Lang]]
 
[[ia:Patrono:Lang]]
Line 183: Line 181:
 
[[nl:Sjabloon:Lang]]
 
[[nl:Sjabloon:Lang]]
 
[[no:Mal:Lang]]
 
[[no:Mal:Lang]]
 +
<!-- [[pl:Szablon:Lang]] doesn’t offer the same feature (only 1 param - for the language code, not the text itself) -->
 
[[pt:Predefinição:Lang]]
 
[[pt:Predefinição:Lang]]
 
[[qu:Plantilla:Lang]]
 
[[qu:Plantilla:Lang]]
Line 197: Line 196:
 
[[uk:Шаблон:Lang]]
 
[[uk:Шаблон:Lang]]
 
[[vi:Tiêu bản:Lang]]
 
[[vi:Tiêu bản:Lang]]
 +
[[xal:Зура:Lang]]
 
[[zh:Template:Lang]]
 
[[zh:Template:Lang]]
 
[[zh-min-nan:Template:Lang]]
 
[[zh-min-nan:Template:Lang]]

Revision as of 00:28, 21 March 2010

The purpose of this template is to indicate that a given span of text belongs to a particular language (see language code). It often makes no visible changes to the text, but can help web browsers choose the right font, screen readers use the right pronunciation and more.

{{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."

There are also versions of this template for specific languages 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 Cyrillic 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).

Undetermined language

The {{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 und for Undetermined language. 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 Hani, which specifies generic Han characters (Hanzi, Kanji, Hanja).

compare {{script}}

The {{script|Hani|字}} Han character has 6 strokes.
The 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 zh-Hant-TW will be used for Chinese text written with Traditional Han characters, containing words or expressions specific to Taiwan. zh-Hans is for simplified. 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}}.

Rationale

  • Web browsers can use the information to choose an appropriate font.
    • This is great for 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.
  • Facilitates better data-scraping. parsing and re-use.
  • 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 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 will screw them up. They are recommended in CSS, but not required.

See also

References