Template:Lang/doc

From Wikisource
Jump to navigation Jump to search

Usage

[edit]

This template tags pieces of text with the appropriate language code and allows for the implementation of Web Fonts.

This template is a <span> template.
{{lang block}} is the <div> version of this template.

{{lang|language|text}}
{{lang
 | language  = 
 | text      = 
 | direction = 
 | font      = 
 | style     =
 | class     =
 | attr      =
 | inline    =
}}

Parameters

[edit]
  • language: (Also lang or the first unnamed parameter) The code for the language being displayed, using ISO 639. This can be two or three letters depending on the specificity of the language you are declaring. For example "French" is fr is, but "Old French" is fro.
  • text: (Also the second unnamed parameter) The text to be displayed.
  • direction: (Also dir) Text direction, can be ltr (left-to-right) or rtl (right-to-left). Left-to-right is standard; right-to-left is used for languages such as Arabic and Hebrew. If this is not set, the template will attempt to select the correct text direction based on the language parameter.
  • font: Uses the webfont extension. See Web Fonts below.
  • style: The code for other optional CSS style being applied, such as font-feature-setting: 'locl'; for localized glyph(s).
  • class: Any HTML classes to apply, such as class="plainlinks".
  • attr: The code for other optional HTML attributes being applied

Internal parameters

[edit]

This parameter is for internal use only, to distiguish between {{lang}} and {{lang block}}.
It shall not be used directly.

  • inline: The type of template:
    • inline=yes (default) will provide an inline template (<span> ... </span>); this is used internally in {{lang}}.
    • inline=no (or != yes) will provide a block template (<div> ... </div>); this is used internally in {{lang block}}.

This parameter can be used by /s templates to not close the tag, but instead leave it open, e.g. for crossing a page break.

  • noclose: The type of template:
    • noclose=yes (default) leave the tag open
    • Any other value: close the tag as normal

Examples

[edit]

Hebrew text and unnamed parameters

[edit]
{{lang|he|ארץ זבת חלב ודבש}}

ארץ זבת חלב ודבש

The same text without this template: ארץ זבת חלב ודבש

Arabic text and named parameters

[edit]
{{lang
 | language = ar
 | text     = المدينة‎
 | dir      = rtl
}}

المدينة‎

Arabic text and non-standard web font

[edit]
{{lang|ar|المدينة‎|font=Amiri}}

المدينة‎

Burmese text and different web fonts

[edit]
{{lang|my|အ​ကူ​အ​ညီ​}}

အ​ကူ​အ​ညီ​

{{lang|my|အ​ကူ​အ​ညီ​|font=Padauk-Regular}}

အ​ကူ​အ​ညီ​

{{lang|my|အ​ကူ​အ​ညီ​|font=Yunghkio}}

အ​ကူ​အ​ညီ​

English text (Latin script) with web font

[edit]
{{lang|text=Lorem ipsum|font=Rufscript}}

Lorem ipsum

{{lang|text=Lorem ipsum|font=Ubuntu}}

Lorem ipsum

{{lang|text=Lorem ipsum|font=UnifrakturMaguntia}}

Lorem ipsum

{{lang|en|Lorem ipsum|font=Linux Libertine}}

Lorem ipsum

Language attribute

[edit]

As stated under parameters, the language should be set with an ISO 639 language code.

However, if necessary, this can be specified even further with an ISO 15924 script code and/or an ISO 3166-1 country code. Script codes can be used if the text is in a script other than that associated with the language. Country codes can be used to specify the text's country of origin.

Use Text Attribute Code Notes
Language Χαίρε, ω χαίρε Ελευθεριά! el {{lang|el|Χαίρε, ω χαίρε Ελευθεριά!}} Greek text. "el" = Greek language.
Script Haire, o haire, Eleftheria! el-Latn {{lang|el-Latn|Haire, o haire, Eleftheria!}} Transliterated into Latin script. "Latn" = Latin script.
Country Χαίρε, ω χαίρε Ελευθεριά! el-GR {{lang|el-GR|Χαίρε, ω χαίρε Ελευθεριά!}} Greek origin. "GR" = Greece.
Script & Country Haire, o haire, Eleftheria! el-Latn-GR {{lang|el-Latn-GR|Haire, o haire, Eleftheria!}} Greek language in Latin script from Greece.
See IETF language tag on Wikipedia for more information.

Web Fonts

[edit]

This template makes use of the Universal Language Selector extension installed on this project. This extension allows for the proper display of languages where the standard font is either unavailable or of insufficient quality.

The language parameter will determine which font is used. In some cases, multiple fonts are available; the preferred font can be selected with the font parameter. If the font parameter is not used, the default font for that language will be selected. Currently no support for mobile devices.

Language ISO-639 Fonts
Ahirani ahr Lohit Devanagari
Akkadian akk Akkadian
Amharic am Abyssinica SIL
Arabic (Naskh script) ar Amiri
Scheherazade
Lateef
Nastaʿlīq script (Aran) Hussaini Nastaleeq
Assamese as Lohit Assamese
Bengali bn Lohit Bengali, Siyam Rupali
Bhojpuri bh Lohit Devanagari
Bishnupriya Manipuri bpy Lohit Bengali
Buginese bug Saweri
Burmese my Padauk-Regular
Myanmar3
TharLon
Yunghkio
Dzongkha dz Jomolhari
Gujarati gu Lohit Gujarati
Hebrew he Alef
Miriam CLM
Taamey Frank CLM
Biblical Hebrew hbo Taamey Frank CLM
Hindi hi Lohit Devanagari
Samyak Devanagari
Kannada kn Lohit Kannada
Kedage
Khmer km Hanuman, KhmerOSbattambang, KhmerOS, Nokora, Suwannaphum
Konkani kok Lohit Devanagari
Latin script (Latn)   Charis SIL
ComicNeue
Doulos SIL
Gentium Plus
Junicode
Linux Libertine
RailwaySans
Rufscript
Ubuntu
Latin fraktur script (Latf)   UnifrakturMaguntia
Makassarese mak Saweri
Malayalam ml AnjaliOldLipi
Meera
RaghuMalayalam
Maithili mai Lohit Devanagari
Marathi mr Lohit Devanagari
Samyak Devanagari
Min Dong Chinese cdo Charis SIL
Doulos SIL
Oriya (Odia) or Lohit Oriya
Utkal
Punjabi pa Lohit Punjabi
Saab
Persian (Farsi) fa IranianSans
IranianSerif
Sourashtra saz Pagul
Sanskrit sa Lohit Devanagari, Samyak Devanagari
Tamil ta Lohit Tamil
Thendral
Thenee
Telugu te Lohit Telugu
Pothana2000
Vemana2000
Tibetan bo BabelStone Tibetan Slim
Tigrinya ti Abyssinica SIL
Yi yi Nuosu SIL
See here for a list of all available fonts.

Language tagging

[edit]

Texts on Wikisource should be tagged to specify the language in a machine readable format. All pages on English Wikisource are automatically tagged as "English". Any piece of text that is not in English should be tagged as such with this template or one of its derivatives.

Language tagging on Meta-Wiki explains the best practice of language tagging.

Blocks split across pages

[edit]

For blocks in a different language split across multiple pages, use {{lang block/s}} to begin the block and {{lang block/e}} to end it. {{lang block/s}} takes the same parameters as {{lang}} except for |inline=, which is fixed as "no".

See also

[edit]

No description.

Template parameters

ParameterDescriptionTypeStatus
languagelanguage lang 1

The code for the language being displayed, using ISO 639.

Stringrequired
texttext 2

The text to be displayed.

Stringrequired
inlineinline

Determines if a span or block is generated.

Booleanoptional
fontfont

no description

Unknownoptional
fontsfonts

no description

Unknownoptional
stylestyle

no description

Unknownoptional
classclass

no description

Unknownoptional
attrattr

no description

Unknownoptional
noclosenoclose

no description

Unknownoptional
directiondirection

no description

Unknownoptional
dirdir

no description

Unknownoptional