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
(added {{High-use}} and updated /doc)
 
(2 intermediate revisions by the same user not shown)
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.
+
{{High-use}}
 +
{{Lua|Module:ISO 639 name}}
  
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.  
+
'''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]]. The template should not be transcluded directly from article namespace.  
  
'''Examples:'''
+
==Examples==
 +
* {{Tlx|Lang2iso|German}} returns: {{Lang2iso|German}}
 +
* {{Tlx|Lang2iso|Greek}} returns: {{Lang2iso|Greek}}
 +
* {{Tlx|Lang2iso|Spanish}} returns: {{Lang2iso|Spanish}}
  
* <nowiki>{{Lang2iso|German}}</nowiki> returns "{{Lang2iso|German}}"
+
==Purpose==
* <nowiki>{{Lang2iso|Greek}}</nowiki> returns "{{Lang2iso|Greek}}"
+
Since most users will know a language's name but not its ISO code, this template 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 {{Tlx|Lang|de|Mädchen}}, one can type: {{Tlx|Lang|{{Tlx|Lang2iso|subst=y|German}}|Mädchen}}.
* <nowiki>{{Lang2iso|Spanish}}</nowiki> returns "{{Lang2iso|Spanish}}"
 
  
'''Purpose:'''
+
This also reduces the number of parameters that need to be passed to some language routines (such as those similar to [[Template:Language with name]]) since the ISO language code can now be derived from the ISO language name.
 
 
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:
 
 
 
:<nowiki>{{lang|de|Mädchen}}</nowiki>
 
 
 
one can type:
 
 
 
:<nowiki>{{lang|{{subst:lang2iso|German}}|Mädchen}}</nowiki>
 
 
 
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||<!--

Latest revision as of 16:48, 3 October 2020

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. The template should not be transcluded directly from article namespace.

Examples

Purpose

Since most users will know a language's name but not its ISO code, this template 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:Language with name) since the ISO language code can now be derived from the ISO language name.

See also