Template:Lang/doc: Difference between revisions

m
m (1 revision imported)
Line 4: Line 4:
{{Lua|Module:Lang}}
{{Lua|Module:Lang}}
{{Language templates}}
{{Language templates}}
{{notice|text=After a [[Wikipedia:Templates for discussion/Log/2024 September 27#Replace and delete lang-?? templates|discussion in 2024]], most of the {{tld|lang-??}} templates were replaced by {{tlx|langx}}}}
The purpose of this template is to indicate that a piece of text belongs to a particular language other than that of the page as a whole (by default, English, on this Wikipedia). It can be used inline, or around block-level elements such as <code><nowiki><poem></nowiki></code>, paragraphs, lists, or divs.


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. See {{section link||Rationale}} for more information.
The template italicises the text by default (this can be suppressed, and does not apply to certain scripts) and can prompt [[web browser]]s to use a more appropriate font or screen readers to use a particular kind of pronunciation and so on. See {{section link||Rationale}} for more information.


== Syntax and usage ==
== Syntax and usage ==
Line 11: Line 13:
{{in5}}{{tlx|lang|{{var|language tag}}|{{var|text}}}}
{{in5}}{{tlx|lang|{{var|language tag}}|{{var|text}}}}


The {{var|language tag}} should consist of an [[ISO-639]] language code. See the [[List of ISO 639-1 codes|list of ISO 639-1 codes]] for two-letter codes; if you don't find the language you seek, then refer to the [[List of ISO 639-3 codes|list of ISO 639-3 codes]].
The {{var|language tag}} must be an [[ISO 639]] language code. See the [[list of ISO 639-1 codes]] for two-letter codes, and the [[list of ISO 639-3 codes]], which defines three-letter codes and aims to cover all known natural languages.


The template also supports properly formatted [[IETF language tag]]s using subtags that identify the language's script, region, and/or variant. The ISO 639 language code is a two- or three-letter abbreviation, in lowercase, of the language's name. French, for example, has the code <code>fr</code>:
The template also supports properly formatted [[IETF language tag]]s using subtags that identify the language's script, region, and/or variant. The ISO 639 language code is a two- or three-letter abbreviation, in lowercase, of the language's name. French, for example, has the code <code>fr</code>:
Line 23: Line 25:
=== Formatting ===
=== Formatting ===
==== Automatic italics ====
==== Automatic italics ====
{{tld|lang}} automatically applies italic styling <span style="font-weight: normal;">when the text in <code><nowiki>{{{2}}}</nowiki></code> is written entirely in the <code>Latn</code> script (the Latin alphabet and its extensions), either when that is the default encoding for the language or when it is triggered by a <code>{{var|xx}}-Latn</code> language code{{colon}}</span>
{{tld|lang}} automatically applies italic styling <span style="font-weight: normal;">when the text in {{param|2}} is written entirely in the <code>Latn</code> script (the Latin alphabet and its extensions), either when that is the default encoding for the language or when it is triggered by a <code>{{var|xx}}-Latn</code> language code{{colon}}</span>
* <code><nowiki>{{lang|fr|Je suis française.}}</nowiki></code> → {{lang|fr|Je suis française.}}
* <syntaxhighlight lang="wikitext" inline>{{lang|fr|Je suis française.}}</syntaxhighlight> → {{lang|fr|Je suis française.}}
* <code><nowiki>''{{lang|fr|Je suis française.}}''</nowiki></code> → ''{{lang|fr|Je suis française.}}'' – external markup is ignored
* <syntaxhighlight lang="wikitext" inline>''{{lang|fr|Je suis française.}}''</syntaxhighlight> → ''{{lang|fr|Je suis française.}}'' – external markup is ignored
* <code><nowiki>{{lang|he-Latn|la'az}} ({{lang|he|לעז}})</nowiki></code> → {{lang|he-Latn|la'az}} ({{lang|he|לעז}})
* <syntaxhighlight lang="wikitext" inline>{{lang|he-Latn|la'az}} ({{lang|he|לעז}})</syntaxhighlight> → {{lang|he-Latn|la'az}} ({{lang|he|לעז}})
* <code><nowiki>''{{lang|he-Latn|la'az}}''</nowiki> ({{!mxt|<nowiki>''{{lang|he|לעז}}''</nowiki>}})</code> → ''{{lang|he-Latn|la'az}}'' ({{!mxt|''{{lang|he|לעז}}''}}) – external markup is ignored around the <code>he-Latn</code> text, but will incorrectly italicize the Hebrew-character material.
* <code><nowiki>''{{lang|he-Latn|la'az}}''</nowiki> ({{!mxt|<nowiki>''{{lang|he|לעז}}''</nowiki>}})</code> → ''{{lang|he-Latn|la'az}}'' ({{!mxt|''{{lang|he|לעז}}''}}) – external markup is ignored around the <code>he-Latn</code> text, but will incorrectly italicize the Hebrew-character material.


When <code>Latn</code> script should not be italicized, there are multiple approaches{{colon}}
When <code>Latn</code> script should not be italicized, there are multiple approaches{{colon}}
{{para|italic|no}} <span style="font-weight: normal;">– renders <code><nowiki>{{{2}}}</nowiki></code> in upright font; italic markup around the template is ignored; italic markup inside the template causes an error message{{colon}}</span>
{{para|italic|no}} <span style="font-weight: normal;">– renders {{param|2}} in upright font; italic markup around the template is ignored; italic markup inside the template causes an error message{{colon}}</span>
* <code><nowiki>{{lang|fr|Je suis française.|italic=no}}</nowiki></code> → {{lang|fr|Je suis française.|italic=no}}
* <syntaxhighlight lang="wikitext" inline>{{lang|fr|Je suis française.|italic=no}}</syntaxhighlight> → {{lang|fr|Je suis française.|italic=no}}
* <code><nowiki>''{{lang|fr|Je suis française.|italic=no}}''</nowiki></code> → ''{{lang|fr|Je suis française.|italic=no}}''
* <syntaxhighlight lang="wikitext" inline>''{{lang|fr|Je suis française.|italic=no}}''</syntaxhighlight> → ''{{lang|fr|Je suis française.|italic=no}}''
* <code><nowiki>''{{lang|fr|Je suis ''française''.|italic=no}}''</nowiki></code> → ''{{lang|fr|Je suis ''française''.|italic=no|cat=no}}'' – italic markup in conflict with {{para|italic|no}}
* <syntaxhighlight lang="wikitext" inline>''{{lang|fr|Je suis ''française''.|italic=no}}''</syntaxhighlight> → ''{{lang|fr|Je suis ''française''.|italic=no|cat=no}}'' – italic markup in conflict with {{para|italic|no}}


{{para|italic|unset}} <span style="font-weight: normal;">– disables template-provided styling; <code><nowiki>{{{2}}}</nowiki></code> is styled according to external or internal wiki markup{{colon}}</span>
{{para|italic|unset}} <span style="font-weight: normal;">– disables template-provided styling; {{param|2}} is styled according to external or internal wiki markup{{colon}}</span>
* <code><nowiki>{{lang|fr|Je suis française.|italic=unset}}</nowiki></code> → {{lang|fr|Je suis française.|italic=unset}}
* <syntaxhighlight lang="wikitext" inline>{{lang|fr|Je suis française.|italic=unset}}</syntaxhighlight> → {{lang|fr|Je suis française.|italic=unset}}
* <code><nowiki>''{{lang|fr|Je suis française.|italic=unset}}''</nowiki></code> → ''{{lang|fr|Je suis française.|italic=unset}}''
* <syntaxhighlight lang="wikitext" inline>''{{lang|fr|Je suis française.|italic=unset}}''</syntaxhighlight> → ''{{lang|fr|Je suis française.|italic=unset}}''
* <code><nowiki>{{lang|fr|''Je suis'' English.|italic=unset}}</nowiki></code> → {{lang|fr|''Je suis'' English.|italic=unset}}
* <syntaxhighlight lang="wikitext" inline>{{lang|fr|''Je suis'' English.|italic=unset}}</syntaxhighlight> → {{lang|fr|''Je suis'' English.|italic=unset}}


{{tlx|noitalic}} <span style="font-weight: normal;">can also be used{{colon}}</span>
{{tlx|noitalic}} <span style="font-weight: normal;">can also be used{{colon}}</span>
* <code><nowiki>{{lang|fr|Je suis {{noitalic|English}}.}}</nowiki></code> → {{lang|fr|Je suis {{noitalic|English}}.}}
* <syntaxhighlight lang="wikitext" inline>{{lang|fr|Je suis {{noitalic|English}}.}}</syntaxhighlight> → {{lang|fr|Je suis {{noitalic|English}}.}}
{{hatnote|{{crossreference|See table "[[#italic parameter|lang {{!}}italic{{=}} parameter operation]]".}}}}
{{hatnote|{{crossreference|See table "[[#italic parameter|lang {{!}}italic{{=}} parameter operation]]".}}}}


==== Language-specific templates ====
==== Prefixed language template ====
There are 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:
There is a version of this template, {{tl|langx}}, which is 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 ...
* <syntaxhighlight lang="wikitext" inline>A '''kremlin''' ({{langx|ru|кремль}}, 'castle') is a major fortified central complex ...</syntaxhighlight> → A '''kremlin''' ({{langx|ru|кремль}}, 'castle') is a major fortified central complex ...


While {{tnull|lang-{{var|xx}}}} templates output text in italics for languages with Latin-based scripts, if plain text is required, such as for proper names, {{para|italic|no}} or {{tlx|noitalic}} may be used:
While the {{tnull|langx}} template outputs text in italics for languages with Latin-based scripts, if plain text is required, such as for proper names, {{para|italic|no}} or {{tlx|noitalic}} may be used:


* <code><nowiki>the border town of Ventimiglia ({{lang-fr|Vintimille}})</nowiki></code> → the border town of Ventimiglia ({{lang-fr|Vintimille}})
* <syntaxhighlight lang="wikitext" inline>the border town of Ventimiglia ({{langx|fr|Vintimille}})</syntaxhighlight> → the border town of Ventimiglia ({{langx|fr|Vintimille}})
* <code><nowiki>the border town of Ventimiglia ({{lang-fr|italic=no|Vintimille}})</nowiki></code> → the border town of Ventimiglia ({{lang-fr|italic=no|Vintimille}})
* <syntaxhighlight lang="wikitext" inline>the border town of Ventimiglia ({{langx|fr|italic=no|Vintimille}})</syntaxhighlight> → the border town of Ventimiglia ({{langx|fr|italic=no|Vintimille}})
* <code><nowiki>the border town of Ventimiglia ({{lang-fr|{{noitalic|Vintimille}}}})</nowiki></code> → the border town of Ventimiglia ({{lang-fr|{{noitalic|Vintimille}}}})
* <syntaxhighlight lang="wikitext" inline>the border town of Ventimiglia ({{langx|fr|{{noitalic|Vintimille}}}})</syntaxhighlight> → the border town of Ventimiglia ({{langx|fr|{{noitalic|Vintimille}}}})


When formatting foreign-language text to match style guidelines, it is best to exclude the styling markup from the template, so that any extraneous markup which is not from the foreign language does not receive incorrect metadata for that language. This includes: 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 when possible.
When formatting foreign-language text to match style guidelines, it is best to exclude the styling markup from the template, so that any extraneous markup which is not from the foreign language does not receive incorrect metadata for that language. This includes: 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 when possible.
Line 59: Line 61:
{{See also|Wikipedia:Manual of Style/Text formatting#Foreign terms}}
{{See also|Wikipedia:Manual of Style/Text formatting#Foreign terms}}


==== Proto languages ====
==== Proto-languages ====
* {{tlx|lang|cel-x-proto|kal-|_show_result=yes}}
* {{tlx|lang|cel-x-proto|kal-|_show_result=yes}}
* {{tlx|lang|cel-x-proto|kal-|proto{{=}}no|_show_result=yes}}
* {{tlx|lang|cel-x-proto|kal-|proto{{=}}no|_show_result=yes}}
* {{tlx|lang-cel-x-proto|kal-|_show_result=yes}}
* {{tlx|langx|cel-x-proto|kal-|_show_result=yes}}
* {{tlx|lang-cel-x-proto|kal-|proto{{=}}no|_show_result=yes}}
* {{tlx|langx|cel-x-proto|kal-|proto{{=}}no|_show_result=yes}}
* {{tlx|lang|en|accidently|_show_result=yes}}
* {{tlx|lang|en|accidently|_show_result=yes}}
* {{tlx|lang|en|accidently|proto{{=}}yes|_show_result=yes}}
* {{tlx|lang|en|accidently|proto{{=}}yes|_show_result=yes}}
Line 74: Line 76:


Note that text direction does not need to be specified when using the {{tnull|lang-{{var|xx}}}} templates, as this is implied by the template's language.
Note that text direction does not need to be specified when using the {{tnull|lang-{{var|xx}}}} templates, as this is implied by the template's language.
=== Exception for scientific names ===
Per [[MOS:SCIENTIFIC]], {{tq|scientific names are never marked up with {{tl|lang}} or related templates}}.


== Parameters ==
== Parameters ==
{{#lst:Template:Lang-x/doc/parameters|lang_parameters}}
{| class="wikitable"
===the function selector parameter===
|+ Lang supported parameters
{{tlx|lang}} uses the Lua function <code>lang()</code> [[Module:Lang]]. That module also supports all of the {{tnull|lang-??}} templates using the Lua functions <code>lang_xx_inherit()</code> and <code>lang_xx_italic()</code>. The module has other functions that may be useful. The function selector parameter {{para|fn}} tells module:lang which function to execute. The available functions are:
! style="width: 15%;" | Parameter
! Definition
! style="width: 10%;" | Yields to
! style="width: 12%;" | Alias
|-
| {{para|code}} || [[IETF language tag]] for the content in <code>text</code> || – || {{para|1}}
|-
| {{para|text}}|| non-English text || – || {{para|2}}
|-
| {{para|rtl}} || <kbd>yes</kbd> indicates that the writing system used for the content in {{para|text}} is right-to-left; accepted values are: <kbd>no</kbd> (default), <kbd>yes</kbd> || IETF script subtag in {{para|code}} (if provided) ||
|-
| {{para|italic}} || {{crossreference|see table "lang {{pipe}}italic{{=}} parameter operation"}}; accepted values are: <kbd>yes</kbd>, <kbd>no</kbd>, <kbd>unset</kbd>, <kbd>invert</kbd>, <kbd>default</kbd> || – || {{para|italics}}, {{para|i}}
|-
| {{para|size}}|| specifies font size of the content in <code>text</code>; use a value suitable for use with the CSS <code>font-size</code> property; this should almost always be a relative value supplied in <kbd>{{mxt|%}}</kbd> or <kbd>{{mxt|em}}</kbd> units, not a fixed <kbd>{{!mxt|px}}</kbd> value. || – ||
|-
| {{para|proto}} || accepted values are: <kbd>no</kbd> (default) or <kbd>yes</kbd> (default for private-use language tags with the <kbd>-x-proto</kbd> subtags); when <kbd>yes</kbd> (default or explicit), prefixes rendered text with an asterisk indicating 'unattested' || – ||
|-
| {{para|cat}} || inhibits automatic categorization; mirror version of {{para|nocat}}; accepted values are: <kbd>no</kbd>, <kbd>n</kbd>, <kbd>false</kbd>, <kbd>f</kbd>, <kbd>off</kbd>, <kbd>0</kbd> || – ||
|-
| {{para|nocat}} || inhibits automatic categorization; mirror version of {{para|cat}}; accepted values are: <kbd>yes</kbd>, <kbd>y</kbd>, <kbd>true</kbd>, <kbd>t</kbd>, <kbd>on</kbd>, <kbd>1</kbd> || – ||
|-
|}
 
{| class="wikitable" id="italic parameter"
|+ Lang {{pipe}}italic= parameter operation
|-
! {{pipe}}italic= value !! description !! example code !! result !! html markup
|-
| rowspan="4" | {{Plainlist|
* parameter not present;
* parameter present, not set;
* invalid value
}}
| rowspan="7" | {{Plainlist|
* module applies style from:
* &nbsp;&nbsp;auto-italics or
* &nbsp;&nbsp;script subtag <code>latn</code>;
* else inherits from external markup;
* invalid values treated as default
}}
| <syntaxhighlight lang="wikitext" inline="1">{{lang|ru|тундра}}</syntaxhighlight>
| {{lang|ru|тундра}}
| {{code|{{lang|ru|тундра}}}}
|-
| <code>{{deprecated code|red=yes|<nowiki>{{lang|ru|tûndra}}</nowiki>}}</code>
| {{lang|ru|tûndra}}
| {{code|{{lang|ru|tûndra}}}}<br />Incorrect markup; this requires {{para||ru-Latn}}.
|-
| <syntaxhighlight lang="wikitext" inline="1">{{lang|fr|toundra}}</syntaxhighlight>
| {{lang|fr|toundra}}
| {{code|{{lang|fr|toundra}}}}
|-
| <syntaxhighlight lang="wikitext" inline="1">{{lang|ru-Latn|tûndra}}</syntaxhighlight>
| {{lang|ru-Latn|tûndra}}
| {{code|{{lang|ru-Latn|tûndra}}}}
|-
| rowspan="3" | <kbd>default</kbd>
| <syntaxhighlight lang="wikitext" inline="1">{{lang|ru|тундра|italic=default}}</syntaxhighlight>
| {{lang|ru|тундра|italic=default}}
| {{code|{{lang|ru|тундра|italic=default}}}}
|-
| <syntaxhighlight lang="wikitext" inline="1">{{lang|fr|toundra|italic=default}}</syntaxhighlight>
| {{lang|fr|toundra|italic=default}}
| {{code|{{lang|fr|toundra|italic=default}}}}
|-
| <syntaxhighlight lang="wikitext" inline="1">{{lang|ru-Latn|tûndra|italic=default}}</syntaxhighlight>
| {{lang|ru-Latn|tûndra|italic=default}}
| {{code|{{lang|ru-Latn|tûndra|italic=default}}}}
|-
| rowspan="4" | <kbd>no</kbd>
| rowspan="4" | {{Plainlist|
* module applies upright style;
* overrides auto-italics
* overrides script subtag <code>latn</code>;
* overrides external markup
}}
| <syntaxhighlight lang="wikitext" inline="1">{{lang|ru|тундра|italic=no}}</syntaxhighlight> || {{lang|ru|тундра|italic=no}} || {{code|{{lang|ru|тундра|italic=no}}}}
|-
| <syntaxhighlight lang="wikitext" inline="1">{{lang|fr|toundra|italic=no}}</syntaxhighlight> || {{lang|fr|toundra|italic=no}} || {{code|{{lang|fr|toundra|italic=no}}}}
|-
| <syntaxhighlight lang="wikitext" inline="1">{{lang|ru-Latn|tûndra|italic=no}}</syntaxhighlight> || {{lang|ru-Latn|tûndra|italic=no}} || {{code|{{lang|ru-Latn|tûndra|italic=no}}}}
|-
| <syntaxhighlight lang="wikitext" inline="1">''{{lang|fr|toundra|italic=no}}''</syntaxhighlight> || ''{{lang|fr|toundra|italic=no}}'' || {{code|''{{lang|fr|toundra|italic=no}}''}}
|-
| rowspan="2" | <kbd>yes</kbd>
| rowspan="2" | {{Plainlist|
* module applies italic style;
* ignores auto-italics;
* ignores script subtag <code>latn</code>
}}
| <code>{{deprecated code|red=yes|<nowiki>{{lang|ru|тундра|italic=yes}}</nowiki>}}</code>
| {{lang|ru|тундра|italic=yes}}
| {{code|{{lang|ru|тундра|italic=yes}}}} Incorrect markup per [[MOS:BADITALICS]].
|-
| <syntaxhighlight lang="wikitext" inline="1">{{lang|ru-Latn|tûndra|italic=yes}}</syntaxhighlight>
| {{lang|ru-Latn|tûndra|italic=yes}}
| {{code|{{lang|ru-Latn|tûndra|italic=yes}}}}
|-
| rowspan="4"| <kbd>unset</kbd>
| rowspan="4" | {{Plainlist|
* module applies no style;
* inherits style from external markup;
* disables auto-italics
* overrides script subtag <code>latn</code>;
}}
| <syntaxhighlight lang="wikitext" inline="1">{{lang|ru|тундра|italic=unset}}</syntaxhighlight>
| {{lang|ru|тундра|italic=unset}}
| {{code|{{lang|ru|тундра|italic=unset}}}}
|-
| <code>{{deprecated code|red=yes|<nowiki>''{{lang|ru|тундра|italic=unset}}''</nowiki>}}</code>
| ''{{lang|ru|тундра|italic=unset}}''
| {{code|''{{lang|ru|тундра|italic=unset}}''}} Incorrect markup per [[MOS:BADITALICS]].
|-
| <syntaxhighlight lang="wikitext" inline="1">{{lang|ru-Latn|tûndra|italic=unset}}</syntaxhighlight>
| {{lang|ru-Latn|tûndra|italic=unset}}
| {{code|{{lang|ru-Latn|tûndra|italic=unset}}}}
|-
| <syntaxhighlight lang="wikitext" inline="1">''{{lang|ru-Latn|tûndra|italic=unset}}''</syntaxhighlight>
| ''{{lang|ru-Latn|tûndra|italic=unset}}''
| {{code|''{{lang|ru-Latn|tûndra|italic=unset}}''}}
|-
| rowspan="4" | <kbd>invert</kbd>
| rowspan="4" | {{Plainlist|
* module applies no style;
* inverts style in internal markup;{{efn|name=invertunset}}
* disables auto-italics
* overrides script subtag <code>latn</code>;
}}
| <code>{{deprecated code|red=yes|<nowiki>{{lang|ru|тундра|italic=invert}}</nowiki>}}</code>
| {{lang|ru|тундра|italic=invert}}
| {{code|{{lang|ru|тундра|italic=invert}}}} Incorrect markup per [[MOS:BADITALICS]].
|-
| <syntaxhighlight lang="wikitext" inline="1">{{lang|ru|''тундра''|italic=invert}}</syntaxhighlight>
| {{lang|ru|''тундра''|italic=invert}}
| {{code|{{lang|ru|''тундра''|italic=invert}}}}
|-
| <syntaxhighlight lang="wikitext" inline="1">{{lang|ru-Latn|tûndra|italic=invert}}</syntaxhighlight>
| {{lang|ru-Latn|tûndra|italic=invert}}
| {{code|{{lang|ru-Latn|tûndra|italic=invert}}}}
|-
| <syntaxhighlight lang="wikitext" inline="1">{{lang|ru-Latn|''tûndra''|italic=invert}}</syntaxhighlight>
| {{lang|ru-Latn|''tûndra''|italic=invert}}
| {{code|{{lang|ru-Latn|''tûndra''|italic=invert}}}}
|-
|}
 
===Notes===
{{Notelist|refs=
{{efn|name=invertunset|compare {{para|italic|invert}} to {{para|italic|unset}}:
:<syntaxhighlight lang="wikitext" inline="1">{{Lang|de|... ein neues Opernprojekt in Angriff: ''Das Käthchen von Heilbronn'', nach Heinrich von Kleists gleichnamigem Drama.|italic=invert}}</syntaxhighlight>
::{{Lang|de|... ein neues Opernprojekt in Angriff: ''Das Käthchen von Heilbronn'', nach Heinrich von Kleists gleichnamigem Drama.|italic=invert}}
:<syntaxhighlight lang="wikitext" inline="1">{{Lang|de|''... ein neues Opernprojekt in Angriff: ''Das Käthchen von Heilbronn'', nach Heinrich von Kleists gleichnamigem Drama.''|italic=unset}}</syntaxhighlight>
::{{Lang|de|''... ein neues Opernprojekt in Angriff: ''Das Käthchen von Heilbronn'', nach Heinrich von Kleists gleichnamigem Drama.''|italic=unset}}
}}
}}
 
===The function selector parameter===
{{tlx|lang}} uses the Lua function <code>lang()</code> [[Module:Lang]]. That module also supports all of the {{tnull|lang-??}} templates using the Lua functions <code>lang_xx_inherit()</code> and <code>lang_xx_italic()</code>. The module has other functions that may be useful. The function selector parameter {{para|fn}} tells module:lang which function to execute. The available functions are:
*<code>is_ietf_tag</code> – returns <code>true</code> if the provided [[IETF language tag]] is valid; nil else
*<code>is_ietf_tag</code> – returns <code>true</code> if the provided [[IETF language tag]] is valid; nil else
**<code><nowiki>{{lang|fn=is_ietf_tag|nv}}</nowiki></code> →{{lang|fn=is_ietf_tag|nv}}←
**<code><nowiki>{{lang|fn=is_ietf_tag|nv}}</nowiki></code> →{{lang|fn=is_ietf_tag|nv}}←
Line 86: Line 248:
**<code><nowiki>{{lang|fn=is_lang_name|xxxxx}}</nowiki></code> →{{lang|fn=is_lang_name|xxxxx}}←
**<code><nowiki>{{lang|fn=is_lang_name|xxxxx}}</nowiki></code> →{{lang|fn=is_lang_name|xxxxx}}←
*<code>lang</code> – the function that renders {{tlx|lang}}; listed here for completeness, this particular usage is more-or-less pointless
*<code>lang</code> – the function that renders {{tlx|lang}}; listed here for completeness, this particular usage is more-or-less pointless
*<code>lang_xx_inherit</code> – the function that renders {{tnull|lang-??}} template where the text is not italicized; can be used when a {{tnull|lang-??}} template, for example {{tlx|lang-aao}}, does not exist for a particular language:
**<code><nowiki>{{lang|fn=lang_xx_inherit|code=aao|Algerian Saharan Arabic text}}</nowiki></code> → {{lang|fn=lang_xx_inherit|code=aao|Algerian Saharan Arabic text}}
*<code>lang_xx_italic</code> – the function that renders {{tnull|lang-??}} template where the text is italicized; can be used when a {{tnull|lang-??}} template, for example {{tlx|lang-svc}}, does not exist for a particular language:
**<code><nowiki>{{lang|fn=lang_xx_italic|code=svc|Vincentian Creole English text}}</nowiki></code> → {{lang|fn=lang_xx_italic|code=svc|Vincentian Creole English text}}
*<code>name_from_tag</code> – returns the language name associated with the provided IETF language tag:
*<code>name_from_tag</code> – returns the language name associated with the provided IETF language tag:
**<code><nowiki>{{lang|fn=name_from_tag|apa}}</nowiki></code> → {{lang|fn=name_from_tag|apa}}
**<code><nowiki>{{lang|fn=name_from_tag|apa}}</nowiki></code> → {{lang|fn=name_from_tag|apa}}
*<code>tag_from_name</code> – returns the ISO 639 language code (sometimes IETF language tag) associated with the provided language name:
*<code>tag_from_name</code> – returns the ISO 639 language code (sometimes IETF language tag) associated with the provided language name:
**<code><nowiki>{{lang|fn=tag_from_name|havasupai}}</nowiki></code> → {{lang|fn=tag_from_name|havasupai}}
**<code><nowiki>{{lang|fn=tag_from_name|havasupai}}</nowiki></code> → {{lang|fn=tag_from_name|havasupai}}
*<code>transl</code> – the function that renders {{tlx|transl}}; listed here for completeness, this particular usage is more-or-less pointless
*<code>xlit</code> – the function that renders {{tlx|transliteration}}; listed here for completeness, this particular usage is more-or-less pointless
**<code><nowiki>{{lang|fn=transl|ar|DIN|al-Ḫawārizmī}}</nowiki></code> → {{lang|fn=transl|ar|DIN|al-Ḫawārizmī}}
**<code><nowiki>{{lang|fn=xlit|ar|DIN|al-Ḫawārizmī}}</nowiki></code> → {{lang|fn=xlit|ar|DIN|al-Ḫawārizmī}}


== Indicating writing script ==
== Indicating writing script ==
Line 114: Line 272:
To specify a transliteration scheme, such as the [[ISO 9|ISO transliteration standard for Cyrillic]], use {{tlc|transliteration|ru|ISO|Moskva}}.
To specify a transliteration scheme, such as the [[ISO 9|ISO transliteration standard for Cyrillic]], use {{tlc|transliteration|ru|ISO|Moskva}}.


=== Undetermined language ===
=== Glyphs not connected to a particular language ===
 
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:
 
* <code><nowiki>The Chinese character {{lang|und-Hani|字}} has 6 strokes.</nowiki></code>
: The Chinese character {{lang|und-Hani|字}} has 6 strokes.


[[Chinese characters]] ({{aka}} ''Han characters'') have been used used to write Chinese, Japanese, Korean, Vietnamese, and [[Chinese family of scripts|numerous other languages]]. In this case the character does not represent a use specific to any language in particular. Note that the script code used is <code>Hani</code>, which specifies Chinese characters generally, as opposed to <code>Hant</code> and <code>Hans</code> for traditional or simplified characters respectively.
The {{tlf|lang}} template is not 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 template {{tl|script}} should be used:
 
Compare the use of {{tl|script}}:


* <code><nowiki>The Chinese character {{script|Hani|字}} has 6 strokes.</nowiki></code>
* <code><nowiki>The Chinese character {{script|Hani|字}} has 6 strokes.</nowiki></code>
: The Chinese character {{script|Hani|字}} has 6 strokes.
: The Chinese character {{script|Hani|字}} has 6 strokes.


=== Languages with no code ===
[[Chinese characters]] ({{aka}} ''Han characters'') have been used to write Chinese, Japanese, Korean, Vietnamese, and [[Chinese family of scripts|numerous other languages]]. In this case the character does not represent a use specific to any language in particular. Note that the script code used is <code>Hani</code>, which specifies Chinese characters generally, as opposed to <code>Hant</code> and <code>Hans</code> for traditional or simplified characters respectively.
The code <code>mis</code>, for "Miscellaneous", to indicate any language not listed in ISO-639.
 
== Languages with no code ==
The code <code>mis</code>, for “miscellaneous", is used to indicate that the language does not appear in ISO-639.


== Indicating regional variant ==
== Indicating regional variant ==
Line 141: Line 294:


== Private-use language tags ==
== Private-use language tags ==
This template supports various private-use [[IETF language tag]]s. Private-use tags contain the <code>-x-</code> singleton and are used by the template to identify languages that are different, for one reason or another, from the base language identified by the ISO 639 language tag.
This template supports various private-use [[IETF language tag]]s. Private-use tags contain the <code>-x-</code> singleton and are used by the template to identify languages that are different, for one reason or another, from the base language identified by the ISO 639 language tag.
{{#invoke:Lang/documentor tool|private_tags}}
{{#invoke:Lang/documentor tool|private_tags}}


== Links ==
== Links ==


If the {{tl|lang}} template will have to be combined with links one might be tempted to move the {{tl|lang}} template into the link so that it would only frame the link's text label, not the syntax elements of the links or other stylistic elements of some types of links. However, this does not work. The {{tl|lang}} will have to wrap the entire link, regardless of whether it is an internal or external link, or a link provided through an {{tl|ill}} interwiki link template:
{{tld|lang}} emits a language-specific category link when used in article space (one of the categories in {{cl|Articles containing non-English-language text}}). Category wikilinks within wikilinks are not accepted by MediaWiki.


Works:
This example is a simulation because {{tld|lang}} does not categorize in the Template namespace:
* <code><nowiki>{{lang|en|[[Book of hours]]}}</nowiki></code> → {{lang|en|[[Book of hours]]}}
:<syntaxhighlight lang="wikitext" inline="1">[[Book of hours|{{lang|de|Stundenbuch}}]]</syntaxhighlight>
* <code><nowiki>{{lang|de|[[Book of hours|Stundenbuch]]}}</nowiki></code> → {{lang|de|[[Book of hours|Stundenbuch]]}}
::<syntaxhighlight lang="wikitext" inline="1">[[Book of hours|<span title="German-language text"><i lang="de">Stundenbuch</i></span>[[Category:Articles containing German-language text]]]]</syntaxhighlight>
* <code><nowiki>{{lang|he-LA|{{ill|Machsor Lipsiae|de}}}}</nowiki></code> → {{lang|he-LA|{{ill|Machsor Lipsiae|de}}}}
:::<nowiki>[[Book of hours|</nowiki><span title="German-language text"><i lang="de">Stundenbuch</i></span>]]
 
To create a working link, set {{para|nocat|yes}}:
Does not work:
:<syntaxhighlight lang="wikitext" inline="1">[[Book of hours|{{lang|de|Stundenbuch|nocat=yes}}]]</syntaxhighlight>
* <code><nowiki>[[{{lang|en|Book of hours}}]]</nowiki></code> → [[{{lang|en|Book of hours}}]] (never works)
::<syntaxhighlight lang="wikitext" inline="1">[[Book of hours|<span title="German-language text"><i lang="de">Stundenbuch</i></span>]]</syntaxhighlight>
* <code><nowiki>[[Book of hours|{{lang|de|Stundenbuch}}]]</nowiki></code> → [[Book of hours|{{lang|de|Stundenbuch}}]] (does not work in article space, works on talk and some other types of pages)
:::[[Book of hours|<span title="German-language text"><i lang="de">Stundenbuch</i></span>]]
* <code><nowiki>{{ill|Machsor Lipsiae|de|lt={{lang|he-LA|Machsor Lipsiae}}}}</nowiki></code> → {{ill|Machsor Lipsiae|de|lt={{lang|he-LA|Machsor Lipsiae}}}} (does not work in article space, works on talk and some other types of pages)
When using {{tld|lang}} with {{tlx|Interlanguage link}}, use that template's link-text parameter {{para|lt}}:
:<syntaxhighlight lang="wikitext" inline="1">{{ill|Ehōmaki|ja|恵方巻|lt={{lang|ja-Latn|ehōmaki|nocat=yes}}}}</syntaxhighlight>
::{{code|lang=html|{{ill|Ehōmaki|ja|恵方巻|lt={{lang|ja-Latn|ehōmaki|nocat=yes}}}}}}
:::{{ill|Ehōmaki|ja|恵方巻|lt={{lang|ja-Latn|ehōmaki|nocat=yes}}}}
When using {{tld|lang}} with non-English wiktionary links:
:<syntaxhighlight lang="wikitext" inline="1">[[wikt:Κλεοπάτρα#Ancient Greek|{{lang|grc|Κλεοπάτρα|nocat=yes}}]]</syntaxhighlight>
::{{code|lang=html|[[wikt:Κλεοπάτρα#Ancient Greek|{{lang|grc|Κλεοπάτρα|nocat=yes}}]]}}
:::[[wikt:Κλεοπάτρα#Ancient Greek|{{lang|grc|Κλεοπάτρα|nocat=yes}}]]
In general, when using {{tld|lang}} with wikilinks, markup the wikilink's display (piped) text, not the entire wikilink.


== Rationale ==
== Rationale ==
Line 170: Line 331:
* Users can apply styles to languages in their [[style sheet (web development)|style sheet]]s (useful for editors).
* Users can apply styles to languages in their [[style sheet (web development)|style sheet]]s (useful for editors).
* [[Web search engine|Search engine]]s can use this information when [[search engine indexing|indexing]] text.
* [[Web search engine|Search engine]]s can use this information when [[search engine indexing|indexing]] text.
* Facilitates better data-scraping, parsing and reuse.
* Facilitates better data-scraping, parsing, and reuse.
* Useful for application developers who re-publish Wikipedia (also see {{section link|Wikipedia:Manual of Style/Accessibility|Other languages}}).
* Useful for application developers who re-publish Wikipedia (also see {{section link|Wikipedia:Manual of Style/Accessibility|Other languages}}).
* Useful for research or compiling statistics about language use in Wikipedia.
* Useful for research or compiling statistics about language use in Wikipedia.
Line 182: Line 343:
<syntaxhighlight lang="css">
<syntaxhighlight lang="css">
[lang|=ru] { font-family: fonteskaya; }
[lang|=ru] { font-family: fonteskaya; }
/*   or   */
/* or */
:lang(ru) { font-family: fonteskaya; }
:lang(ru) { font-family: fonteskaya; }
</syntaxhighlight>
</syntaxhighlight>
Line 213: Line 374:


:lang(ur) {
:lang(ur) {
    font-family: "Noto Nastaliq Urdu Regular", "Noto Nastaliq Urdu";
  font-family: "Noto Nastaliq Urdu Regular", "Noto Nastaliq Urdu";
}
}
</syntaxhighlight>
</syntaxhighlight>


Line 296: Line 456:
== See also ==
== See also ==
* {{tl|Langr}}, variant of this template that forces "roman" (non-italic) output, e.g. for proper names of places and institutions
* {{tl|Langr}}, variant of this template that forces "roman" (non-italic) output, e.g. for proper names of places and institutions
* {{tlf|Lang-{{var|xx}}}}, a series of templates using the same language codes, which display the name of the language before the marked-up text
* {{tl|Langx}}, variant of this template that displays the name of the language before the marked-up text
* {{tl|IPA}}
* {{tl|IPA}}
* {{tl|Title language}}
* {{tl|Title language}}
Line 311: Line 471:
* {{tl|mw lang}} (similar to <nowiki>{{ISO 639 name}}</nowiki> for MediaWiki-supported languages)
* {{tl|mw lang}} (similar to <nowiki>{{ISO 639 name}}</nowiki> for MediaWiki-supported languages)
* {{tl|interlanguage link}}
* {{tl|interlanguage link}}
* [[Wikipedia:Translation]] (a discussion on the translation of information from articles from other languages' Wikipedias)


== References ==
== References ==
Anonymous user