Difference between revisions of "Template:Lang2iso/doc"

From blackwiki
Jump to navigation Jump to search
imported>Vanisaac
m (→‎See also: clean up per WP:CAT#T and WP:AWBREQ add template:Sandbox other)
imported>Gonnym
(update doc)
Line 1: Line 1:
 
{{Documentation subpage}}
 
{{Documentation subpage}}
 
<!-- PLEASE ADD CATEGORIES AT THE BOTTOM OF THIS PAGE. -->
 
<!-- PLEASE ADD CATEGORIES AT THE BOTTOM OF THIS PAGE. -->
This template, '''Lang2iso''', should not be transcluded directly from article namespace.
+
{{Lua|Module:ISO 639 name}}
 
+
'''Template:Lang2iso''', should not be transcluded directly from article namespace. Template:Lang2iso takes an English-language language name (such as "Abkhazian" or "Sinhalese") and converts it into a two-letter [[ISO 639]] language code. This table's values are based on [[List of ISO 639-1 codes]].   
It takes an English-language language name (such as "Abkhazian" or "Sinhalese") and converts it into a two-letter [[ISO 639]] language code. This table's values are based on [[List of ISO 639-1 codes]].  (Some additions to ISO 639-1 codes are identified below.)  If the provided language name is not identified, then the default value of "en" is returned.
 
 
 
'''Examples:'''
 
  
 +
==Examples==
 
* <nowiki>{{Lang2iso|German}}</nowiki> returns "{{Lang2iso|German}}"
 
* <nowiki>{{Lang2iso|German}}</nowiki> returns "{{Lang2iso|German}}"
 
* <nowiki>{{Lang2iso|Greek}}</nowiki> returns "{{Lang2iso|Greek}}"
 
* <nowiki>{{Lang2iso|Greek}}</nowiki> returns "{{Lang2iso|Greek}}"
 
* <nowiki>{{Lang2iso|Spanish}}</nowiki> returns "{{Lang2iso|Spanish}}"
 
* <nowiki>{{Lang2iso|Spanish}}</nowiki> returns "{{Lang2iso|Spanish}}"
  
'''Purpose:'''
+
==Purpose==
 
 
 
Since most users will know a language's name but not its ISO code, this template/macro is meant to facilitate invocations of other templates such as [[Template:Lang]].  Thus, instead of recalling (or having to know) that the ISO code for German is "de" and transcluding:
 
Since most users will know a language's name but not its ISO code, this template/macro is meant to facilitate invocations of other templates such as [[Template:Lang]].  Thus, instead of recalling (or having to know) that the ISO code for German is "de" and transcluding:
  
Line 22: Line 19:
  
 
This also reduces the number of parameters that need to be passed to some language routines (such as those similar to [[Template:langWithName]]) since the ISO Language Code can now be derived from the ISO Language Name.
 
This also reduces the number of parameters that need to be passed to some language routines (such as those similar to [[Template:langWithName]]) since the ISO Language Code can now be derived from the ISO Language Name.
 
'''Additions to ISO 639-1 Alpha-2 codes:'''
 
{{see|List of ISO 639-3 codes}}
 
Not all languages have ISO 639-1 codes.  Thus, as time goes on, users are encouraged to add ISO 639-2 or ISO 639-3 codes.  Thus far, the following additions to ISO 639-1 have been added:
 
 
<u>ISO codes</u>
 
* "Devanāgarī", "Devanagari", "Devanagiri" and "Devangari" return "deva" (per [[ISO 15924]])
 
* "Klingon" and "Klingonese" return "tlh" (per [[List of ISO 639-2 codes|ISO 639-2]])
 
* "Manipuri" returns "mni" (per [[List of ISO 639-2 codes|ISO 639-2]])
 
* "Prakrit" returns "pra" (per [[List of ISO 639-2 codes|ISO 639-2]])
 
* "Simplified Chinese" returns "hans" (per [[ISO 15924]])
 
* "Traditional Chinese" returns "hant" (per [[ISO 15924]])
 
  
 
==See also==
 
==See also==
*{{tl|ISO 639 name}}
+
* {{tl|ISO 639 name}}
  
 
<includeonly>{{Sandbox other||<!--
 
<includeonly>{{Sandbox other||<!--

Revision as of 12:02, 27 August 2020

Template:Lang2iso, should not be transcluded directly from article namespace. Template:Lang2iso takes an English-language language name (such as "Abkhazian" or "Sinhalese") and converts it into a two-letter ISO 639 language code. This table's values are based on List of ISO 639-1 codes.

Examples

  • {{Lang2iso|German}} returns "de"
  • {{Lang2iso|Greek}} returns "el"
  • {{Lang2iso|Spanish}} returns "es"

Purpose

Since most users will know a language's name but not its ISO code, this template/macro is meant to facilitate invocations of other templates such as Template:Lang. Thus, instead of recalling (or having to know) that the ISO code for German is "de" and transcluding:

{{lang|de|Mädchen}}

one can type:

{{lang|{{subst:lang2iso|German}}|Mädchen}}

This also reduces the number of parameters that need to be passed to some language routines (such as those similar to Template:langWithName) since the ISO Language Code can now be derived from the ISO Language Name.

See also