Fyrimynd:Lang
{{{2}}}
Henda fyrimynd eigur ikki at verða nýtt í sitat-fyrimyndum sum t.d. Citation Style 1 og Citation Style 2, av tí at tað inniheldur merking ið oyðileggur COinS metadata, ið tey framleiða; sí COinS in Wikipedia. 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 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, below, provides more information.
Syntax and usage
rætta{{lang |ISO 639 málkotur |text}}
ISO 639 kotan er vanliga ein tvey ella tríggir bóktavakota við lítlum bókstavum fyri navnið á einum máli. Franskt, til dømis hevur kotuna "fr":
Hon segði: "''{{lang|fr|Je suis française.}}''"
tað gevur:
- Hon segði: "Je suis française."
By default, this template will place articles into the relevant subcategory of Bólkur:Greinir ið innihalda ikki-føroyskt mál. To suppress this – e.g. when using {{lang}} within a wikilink or the title parameter of a citation – add the parameter |nocat=true
. If {{lang}} is used to identify a language read from right to left, e.g. Arabic, the template {{rtl-lang}} may be used afterward to ensure the standard (English) left-to-right formatting is resumed. It also supports the |nocat=
parameter.
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:
- Use
''{{lang|it|[[goriziana]]}}''
- Not
{{lang|it|''[[goriziana]]''}}
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 {{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, {{lang-es|español}} and {{lang-ru|русский язык}} yield, respectively, "Spanskt: español" and "Russiskt: русский язык" (without the quotation marks).
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",[1] 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.
Italics
rættaBy default, {{lang|[language code]|…}} outputs plain text, while {{lang-[language code]|…}} templates (e.g. {{lang-de}}) output text in italics. If, with the latter, plain text is required (e.g. for proper names), {{noitalic}} may be used. For example,
... the border town of Ventimiglia ({{lang-fr|{{noitalic|Vintimille}}}})
produces:
- ... the border town of Ventimiglia (Franskt: Vintimille)
Indicating writing script
rættaIf necessary, add the ISO 15924 code to indicate the script.
For example, Russian is usually written in the Cyrillic script, 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 transl
code (transliteration) should be used because it isn't the default script for Russian: ru-Latn
. Example:
* Moscow ([[Russian language|Russian]]: {{lang|ru|Москва́}}, ''{{transl|ru|Moskva}}'')
which is the same as
* Moscow ({{lang-ru|Москва́}}, ''{{transl|ru|Moskva}}'')
Results in your browser:
- Moscow (Russiskt: Москва́, Moskva)
Instead of using ''{{transl|ru|Moskva}}''
the ''{{lang|ru-Latn|Moskva}}''
can be used, but if you specified a font and a size for the target language in your 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 ''{{transl|ru|ISO|Moskva}}''
:
The IANA maintains a list specifying when the script tag should be suppressed [1]. 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|تاجیکی}}, ''{{transl|tg|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 § Writing direction).
Undetermined language
rættaThe {{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 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 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
rættaIn 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
rætta{{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
rætta- Web browsers can use the information in such multilingual support templates 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 Han unification § Examples of language dependent characters and these comparison table and screen photo.
- For accessibility – screen readers need language info to speak text in the correct language – and to satisfy Wikipedia accessibility guidelines.[2]
- For spell checkers and grammar checkers.
- To help browsers choosing appropriate quotation marks,[3] and making decisions about hyphenation,[3] ligatures,[4] and spacing.[3]
- Users can apply styles to languages in their style sheets (useful for editors).
- Search engines can use this information when indexing text.
- Facilitates better data-scraping, parsing and re-use.
- Useful for application developers who re-publish Wikipedia (also see Wikipedia:Manual of Style/Accessibility § Other languages).
- Useful for research or compiling statistics about language use in Wikipedia.
Applying styles
rættaYou 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
rættaLang
Indicate that a given span of text belongs to a particular language. Use by browsers which use different styles for different languages.
Parameter | Description | Type | Status | |
---|---|---|---|---|
Language code | 1 | A language tag or an ISO 639 language code, e.g. fr (the code for French). | String | required |
Text | 2 | The text e.g. Je suis française. | String | required |
Sí eisini
rætta- Category:Multilingual support templates
- Listi yvir ISO 639 kotur (language codes)
- {{ISO 639 name}}
- List of ISO 15924 codes (script codes)
- List of ISO transliterations (transliteration codes)
- {{Cleanup-lang}} (for articles which should use this template, but do not yet)
- {{transl}} (for romanisation of languages not natively written in the Latin alphabet
- {{Unicode}}, {{script}} (for specific characters)
- Category:Language icon templates (for visually marking external links to foreign-language content)
Further information
rætta- W3C
- Language tags in HTML and XML – Overview
- Internationalization Best Practices: Specifying Language in XHTML & HTML Content – W3C Working Draft 21 July 2006
- Understanding the New Language Tags
- FAQ: Styling using the lang attribute
- IANA
- Mozilla Firefox
References
rætta- ↑ Overview for Language Tags at World Wide Web Consortium
- ↑ Heilmann, Chris (13 Mar 2008). "Yahoo! search results now with natural language support". Yahoo! Developer Network Blog. Talgilda eintakið, gjørt eftir tí talgilda frumeintakinum , varð goymt í skjalasavni á netinum tann 25 Jan 2009. http://web.archive.org/web/20090125024422/http://developer.yahoo.net/blog/archives/2008/03/yahoo_search_re.html. Heintað 28 Feb 2015.
- ↑ 3.0 3.1 3.2 Ishida, Richard (18 November 2014). "Why use the language attribute?". World Wide Web Consortium. http://www.w3.org/International/questions/qa-lang-why. Heintað 1 Mar 2015.
- ↑ "6.4 Ligatures: the font-variant-ligatures property". CSS Fonts Module Level 3 W3C Candidate Recommendation 3 October 2013. http://www.w3.org/TR/css3-fonts/#font-variant-ligatures-prop.
Dokumentatiónin omanfyri er tikin frá Fyrimynd:Lang/doc. (rætta | søga) Editors can experiment in this template's sandkassi (upprætta | mirror) and testcases (upprætta) pages. Please add categories to the /doc subpage. Undirsíður til hesa/hetta fyrimyndina. |